Re: [PATCH] RHEL5 iBFT forward port to Fedora - part 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Martin Sivak wrote:
Hi,

I have a patch which adds the NIC selection part of the whole iBFT functionality and some other pieces, right now unsupported by NM, but I might have forgotten something.. so scream at me, if you see anything horrible ;)



diff --git a/iscsi.py b/iscsi.py
index 5feae15..02bc08e 100644
--- a/iscsi.py
+++ b/iscsi.py
@@ -461,6 +461,7 @@ class iscsi(object):
                 os.makedirs(fulldir, 0660)

         self._startIscsiDaemon()
+        self.startIBFT()

         if intf:
             w.pop()


Note that due to some changes I made wrt iscsi in Fedora currently startup only gets called from addTarget, so this code path will no longer automatically execute.

startup used to be called from partitionObjectsInitialize(), but I've removed it being called from there as that let to lots of start stop start iscsi madness.

For iBFT we will need to call it some place sane, so that it gets done only once (and not start stop start for each iscsi target added).


<snip>

--- a/loader/net.c
+++ b/loader/net.c
@@ -53,6 +53,7 @@
 #include "method.h"
 #include "net.h"
 #include "windows.h"
+#include "ibft.h"

 /* boot flags */
 extern uint64_t flags;

I do not see ibft.h getting added by this patch

@@ -237,8 +238,26 @@ void setupIfaceStruct(iface_t * iface, struct loaderData_s * loaderData) {
     }

     if (loaderData->ipinfo_set && loaderData->ipv4 != NULL) {
+	/* this is iBFT configured device */
+	if (!strncmp(loaderData->ip, "ibft", 4)) {
+	    char *devmacaddr = nl_mac2str(loaderData->netDev);
+	    iface->ipv4method = IPV4_IBFT_METHOD;
+	    iface->isiBFT = 1;
+
+	    /* Problems with getting the info from iBFT or iBFT uses dhcp*/
+	    if(!devmacaddr || !ibft_present() || ibft_iface_dhcp()){
+		iface->ipv4method = IPV4_DHCP_METHOD;
+		logMessage(INFO, "iBFT is not present or is configured to use DHCP");
+	    }
+	    /* MAC address doesn't match */
+	    else if(strcasecmp(ibft_iface_mac(), devmacaddr)){
+		iface->ipv4method = IPV4_DHCP_METHOD;
+		logMessage(INFO, "iBFT doesn't know what NIC to use - falling back to DHCP");
+	    }
+	    if(devmacaddr) free(devmacaddr);
+	}
         /* this is how we specify dhcp */
-        if (!strncmp(loaderData->ipv4, "dhcp", 4)) {
+        else if (!strncmp(loaderData->ipv4, "dhcp", 4)) {
             iface->dhcptimeout = loaderData->dhcpTimeout;
             iface->ipv4method = IPV4_DHCP_METHOD;
         } else if (inet_pton(AF_INET, loaderData->ipv4, &addr) >= 1) {
@@ -289,6 +308,24 @@ void setupIfaceStruct(iface_t * iface, struct loaderData_s * loaderData) {
     }
 #endif

+    /* iBFT configured DNS */
+    if(iface->ipv4method == IPV4_IBFT_METHOD){
+	if(iface->numdns<MAXNS){
+	    if(ibft_iface_dns1() && inet_pton(AF_INET, ibft_iface_dns1(), &addr)>=1){
+		iface->dns[iface->numdns] = strdup(ibft_iface_dns1());
+		iface->numdns++;
+		logMessage(INFO, "adding iBFT dns server %s", ibft_iface_dns1());
+	    }
+	}
+	if(iface->numdns<MAXNS){
+	    if(ibft_iface_dns2() && inet_pton(AF_INET, ibft_iface_dns2(), &addr)>=1){
+		iface->dns[iface->numdns] = strdup(ibft_iface_dns2());
+		iface->numdns++;
+		logMessage(INFO, "adding iBFT dns server %s", ibft_iface_dns2());
+	    }
+	}
+    }
+
     if (loaderData->dns) {
         char * buf;
         char ret[INET6_ADDRSTRLEN+1];
@@ -320,6 +357,8 @@ void setupIfaceStruct(iface_t * iface, struct loaderData_s * loaderData) {
             }
         }

+
+
         logMessage(INFO, "dnsservers is %s", loaderData->dns);
     }

@@ -1221,7 +1260,9 @@ int writeEnabledNetInfo(iface_t *iface) {
     fprintf(fp, "ONBOOT=yes\n");

     if (!FL_NOIPV4(flags)) {
-        if (iface->ipv4method == IPV4_DHCP_METHOD) {
+        if (iface->ipv4method == IPV4_IBFT_METHOD) {
+            fprintf(fp, "BOOTPROTO=ibft\n");
+        else if (iface->ipv4method == IPV4_DHCP_METHOD) {
             fprintf(fp, "BOOTPROTO=dhcp\n");
         } else if (iface->ipv4method == IPV4_MANUAL_METHOD) {
             fprintf(fp, "BOOTPROTO=static\n");
@@ -1580,6 +1621,7 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
     char **deviceNames;
     char *ksMacAddr = NULL, *seconds = strdup("10"), *idstr = NULL;
     struct device **devs;
+    int lookForLink = 0;
     struct newtWinEntry entry[] = {{N_("Seconds:"), (char **) &seconds, 0},
                                    {NULL, NULL, 0 }};

@@ -1669,8 +1711,60 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
         return LOADER_NOOP;
     }

+    while((loaderData->netDev && (loaderData->netDev_set == 1)) &&
+	    !strcmp(loaderData->netDev, "ibft")){
+	char *devmacaddr = NULL;
+	char *ibftmacaddr = "";
+
+	/* get MAC from the iBFT table */
+	if(!(ibftmacaddr = ibft_iface_mac())){ /* iBFT not present or error */
+	    lookForLink = 0;
+	    break;
+	}
+
+	logMessage(INFO, "looking for iBFT configured device %s with link", ibftmacaddr);
+	lookForLink = 0;
+
+	for (i = 0; devs[i]; i++) {
+	    if (!devs[i]->device)
+		continue;
+	    devmacaddr = nl_mac2str(devs[i]->device);
+	    if(!strcasecmp(devmacaddr, ibftmacaddr)){
+ logMessage(INFO, "%s has the right MAC (%s), checking for link", devmacaddr, devices[i]);
+		free(devmacaddr);
+		if(get_link_status(devices[i]) == 1){
+		    lookForLink = 0;
+		    loaderData->netDev = devices[i];
+		    logMessage(INFO, "%s has link, using it", devices[i]);
+
+		    /* set the IP method to ibft if not requested differently */
+		    if(loaderData->ip==NULL){
+			loaderData->ip = strdup("ibft");
+			logMessage(INFO, "%s will be configured using iBFT values", devices[i]);
+		    }
+		    return LOADER_NOOP;
+		}
+		else{
+		    logMessage(INFO, "%s has no link, skipping it", devices[i]);
+		}
+
+		break;
+	    }
+	    else{
+		free(devmacaddr);
+	    }
+	}
+
+	break;
+    }
+
+
     if ((loaderData->netDev && (loaderData->netDev_set == 1)) &&
         !strcmp(loaderData->netDev, "link")) {
+	lookForLink = 1;
+    }
+
+    if(lookForLink){
         logMessage(INFO, "looking for first netDev with link");
         for (rc = 0; rc < 5; rc++) {
             for (i = 0; i < deviceNums; i++) {

I do not understand what the purpose of lookForLink is here, before the

     if ((loaderData->netDev && (loaderData->netDev_set == 1)) &&
         !strcmp(loaderData->netDev, "link")) {

It is always 0, so the "if(lookForLink){" is equivalent to

     if ((loaderData->netDev && (loaderData->netDev_set == 1)) &&
         !strcmp(loaderData->netDev, "link")) {


To my knowledge, there is no way to tell NM over D-Bus that you want a
NIC configured a particular way.  The way it's set up is to retain
knowledge about the network interfaces it is set to control.  For
interfaces that have an ifcfg-DEVICE file, there is another daemon
called nm-system-settings that constantly monitors those files for
changes and feeds the new/changed data in to NetworkManager.  It looks
like this:

   NetworkManager (main daemon)
        |
        +-- nm-system-settings (monitors /etc files for changes)
                 |
                 +--- uses plugins such as ifcfg-fedora or ifcfg-suse

In loader, I set everything up to talk to network manager via the ifcfg
files since that was the easiest to maintain.  I'm glad I've done that
for now because the other APIs for NetworkManager keep changing.

What happens when BOOTPROTO=ibft is set?  Right now, the ifcfg-fedora
plugin for nm-system-settings reads the ifcfg files and can handle
BOOTPROTO=static and BOOTPROTO=dhcp.  It takes appropriate action
depending on those settings.  If BOOTPROTO=ibft is simply another kind
of configuration path, it might be easy to modify the ifcfg-fedora
plugin in NetworkManager to handle that.

Erm, why not just write BOOTPROTO=none (what you call static is none AFAIK) or BOOTPROTO=dhcp depending on the iBFT info, teaching nm-system-settings about BOOTPROTO=ibft is of little use unless you plan to teach it to actually read the info from the BIOS in that scenario, so that changes in the BIOS propagate to the OS.

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux