# devmapper
LIBS += $(shell pkg-config --libs devmapper)
@@ -57,7 +57,7 @@ METHOBJS = method.o cdinstall.o hdinstall.o nfsinstall.o urlinstall.o
OBJS = copy.o log.o moduleinfo.o loadermisc.o modules.o windows.o
lang.o kbd.o driverdisk.o selinux.o
mediacheck.o kickstart.o driverselect.o
- getparts.o dirbrowser.o fwloader.o
+ getparts.o dirbrowser.o fwloader.o ibft.o
$(HWOBJS) $(METHOBJS)
LOADEROBJS = loader.o loader-pcmcia.o
NETOBJS = net.o urls.o ftp.o telnet.o telnetd.o
diff --git a/loader/ibft.c b/loader/ibft.c
new file mode 100644
index 0000000..b3a3827
--- /dev/null
+++ b/loader/ibft.c
@@ -0,0 +1,105 @@
+/*
+ File name: ibft.c
+ Date: 2008/09/02
+ Author: Martin Sivak <msivak@redhat.com>
+
+ Copyright (C) 2008 Red Hat
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ in a file called COPYING along with this program; if not, write to
+ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+ 02139, USA.
+*/
+
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <libiscsi.h>
+#include "ibft.h"
+
+struct libiscsi_network_config ibft_context;
+int ibft_ispresent = 0;
+int ibft_initialized = 0;
+
+int ibft_init(void)
+{
+ int ret;
+
+ memset(&ibft_context, 0, sizeof(ibft_context));
+
+ ret = libiscsi_get_firmware_network_config(&ibft_context );
+
+ /* ret == 0 -> OK */
+ ibft_ispresent = !ret;
+ ibft_initialized = 1;
+
+ return ibft_initialized;
+}
+
+/* Is iBFT available on this system */
+int ibft_present()
+{
+ if(!ibft_initialized)
+ ibft_init();
+
+ return ibft_ispresent;
+}
+
+/* Is the iBFT network configured to use DHCP */
+int ibft_iface_dhcp()
+{
+ if(!ibft_initialized)
+ ibft_init();
+
+ if(!ibft_present())
+ return -1;
+
+ return ibft_context.dhcp;
+}
+
+#define ibft_iface_charfunc(name, var) char* ibft_iface_##name()
+{
+ if(!ibft_initialized)
+ ibft_init();
+
+ if(!ibft_present())
+ return NULL;
+
+ if(!strlen(ibft_context.var))
+ return NULL;
+
+ return ibft_context.var;
+}
+
+
+/* Get the iBFT MAC address */
+ibft_iface_charfunc(mac, mac_address)
+
+/* Get the iBFT ip address */
+ibft_iface_charfunc(ip, ip_address)
+
+/* Get the iBFT subnet mask */
+ibft_iface_charfunc(mask, netmask)
+
+/* Get the iBFT gateway */
+ibft_iface_charfunc(gw, gateway)
+
+/* Get the iBFT iface name */
+ibft_iface_charfunc(iface, iface_name)
+
+/* Get the iBFT dns servers */
+ibft_iface_charfunc(dns1, primary_dns)
+ibft_iface_charfunc(dns2, secondary_dns)
+
diff --git a/loader/ibft.h b/loader/ibft.h
new file mode 100644
index 0000000..a922c91
--- /dev/null
+++ b/loader/ibft.h
@@ -0,0 +1,45 @@
+/*
+ File name: ibft.h
+ Date: 2008/09/02
+ Author: Martin Sivak
+
+ Copyright (C) 2008 Red Hat
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ in a file called COPYING along with this program; if not, write to
+ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
+ 02139, USA.
+*/
+
+
+#ifndef __IBFT_H__
+#define __IBFT_H__
+
+
+int ibft_init();
+int ibft_present();
+
+int ibft_iface_dhcp();
+
+char* ibft_iface_mac();
+char* ibft_iface_ip();
+char* ibft_iface_mask();
+char* ibft_iface_gw();
+char* ibft_iface_iface();
+char* ibft_iface_dns1();
+char* ibft_iface_dns2();
+
+
+#endif
+
+/* end of ibft.h */
diff --git a/loader/net.c b/loader/net.c
index 4d08d34..7ee0053 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -53,6 +53,7 @@
#include "method.h"
#include "net.h"
#include "windows.h"
+#include "ibft.h"
uint64_t flags;
int ipv4method;
int ipv6method;
+ int isiBFT;
} iface_t;
/* Function prototypes */
diff --git a/iw/netconfig_dialog.py b/iw/netconfig_dialog.py
index 4818171..c87da21 100644
--- a/iw/netconfig_dialog.py
+++ b/iw/netconfig_dialog.py
@@ -67,8 +67,8 @@ class NetworkConfigurator:
val = combo.get_model().get_value(active, 1)
netdev = self.network.available()[val]
- bootproto = netdev.get('BOOTPROTO')
- if not bootproto or bootproto == "dhcp":
+ bootproto = netdev.get("BOOTPROTO")
+ if not bootproto or bootproto == "dhcp" or bootproto == "ibft":
self.xml.get_widget("dhcpCheckbutton").set_active( True)
else:
self.xml.get_widget("dhcpCheckbutton").set_active( False)
This does not seem right ibft does not automatically mean dhcp.
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");
+ }
Note: when NM and initrd start supporting ibft, the simple switching to dhcp
here is wrong, we then still want to see ibft as ibft, as the settings in the
NIC firmware may later be changed to static.
+ /* 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
+
logMessage(INFO, "dnsservers is %s", loaderData->dns);
}
@@ -1221,7 +1260,15 @@ int writeEnabledNetInfo(iface_t *iface) {
fprintf(fp, "ONBOOT=yes
");
if (!FL_NOIPV4(flags)) {
- if (iface->ipv4method == IPV4_DHCP_METHOD) {
+ if (iface->ipv4method == IPV4_IBFT_METHOD) {
+ /* When initrd and NM support iBFT, we should just write
+ * BOOTPROTO=ibft and let NM deal with it. Until than,
+ * just use static and do it ourselves. */
+ fprintf(fp, "BOOTPROTO=static
");
+ if(ibft_iface_ip()) fprintf(fp, "IPADDR=%s
", ibft_iface_ip());
+ if(ibft_iface_mask()) fprintf(fp, "NETMASK=%s
", ibft_iface_mask());
+ if(ibft_iface_gw()) fprintf(fp, "GATEWAY=%s
", ibft_iface_gw());
+ else if (iface->ipv4method == IPV4_DHCP_METHOD) {
fprintf(fp, "BOOTPROTO=dhcp
");
} else if (iface->ipv4method == IPV4_MANUAL_METHOD) {
fprintf(fp, "BOOTPROTO=static
");
The note from above about ibft-dhcp != dhcp applies here too.