On Thu, 2016-01-14 at 12:52 +0100, Radek Vykydal wrote:
Resolves: rhbz#831002
The connection is estabilished by NM automatically.
We just need to keep on doing what we used to do for configs without
vlan:
- waiting for the right device to become online in loader
- set ip=ibft for dracut
- write out ifcfg file (with NM_CONTROLLED=no, BOOTPROTO=ibft)
The ifcfg file with BOOTPROTO=ibft will be ignored by NM (ifcfg-rh
plugin) now
when NM handles iBFT configuration automatically. To be safe we keep
the former
behaviour wrt ifcfg files created by Anaconda as much as possible.
TODO: rise required iscsi-initiator-utils version
TODO: rise required NM version
---
loader/ibft.c | 2 ++
loader/ibft.h | 1 +
loader/loader.c | 1 +
loader/net.c | 27 +++++++++++++++++++++++----
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/loader/ibft.c b/loader/ibft.c
index b3a3827..7cabdd3 100644
--- a/loader/ibft.c
+++ b/loader/ibft.c
@@ -103,3 +103,5 @@ ibft_iface_charfunc(iface, iface_name)
ibft_iface_charfunc(dns1, primary_dns)
ibft_iface_charfunc(dns2, secondary_dns)
+/* Get the iBFT vlan id */
+ibft_iface_charfunc(vlan, vlan)
diff --git a/loader/ibft.h b/loader/ibft.h
index a922c91..b2cd3ef 100644
--- a/loader/ibft.h
+++ b/loader/ibft.h
@@ -38,6 +38,7 @@ char* ibft_iface_gw();
char* ibft_iface_iface();
char* ibft_iface_dns1();
char* ibft_iface_dns2();
+char* ibft_iface_vlan();
#endif
diff --git a/loader/loader.c b/loader/loader.c
index a8cbb1b..cc501bb 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2308,6 +2308,7 @@ int main(int argc, char ** argv) {
logMessage(INFO, "failed to enable VLAN for
NetworkManager");
}
+ setenv("IBFT_DEBUG","1",1);
/* Start NetworkManager now so it's always available to talk to.
*/
if (iface_start_NetworkManager(loaderData.dhcpTimeout))
logMessage(INFO, "failed to start NetworkManager");
diff --git a/loader/net.c b/loader/net.c
index 6195418..305fc3c 100644
--- a/loader/net.c
+++ b/loader/net.c
@@ -2190,6 +2190,21 @@ int chooseNetworkInterface(struct loaderData_s
* loaderData) {
"%s will be configured using
iBFT values",
devices[i]);
}
+ if (ibft_iface_vlan()) {
+ logMessage(DEBUGLVL, "vlan id configured
in iBFT: %s", ibft_iface_vlan());
+ int vlanid;
+ errno = 0;
+ vlanid = strtol((const char *)
ibft_iface_vlan(), NULL, 10);
+ if (errno == EINVAL || errno == ERANGE)
{
+ logMessage(ERROR, "strtol error %s:
%d: %m", __func__, __LINE__);
+ abort();
+ }
+ if (vlanid >= 0 && vlanid < 4096) {
+ loaderData->vlanid = vlanid;
+ } else {
+ logMessage(DEBUGLVL, "vlan id out of
range: %d", vlanid);
+ }
+ }
return LOADER_NOOP;
}
@@ -2407,10 +2422,14 @@ int activateDevice(struct loaderData_s *
loaderData, iface_t * iface) {
}
if (is_iface_activated(devicename)) {
- logMessage(INFO, "device %s is already activated",
devicename);
- if ((rc = disconnectDevice(devicename)) != 0) {
- logMessage(ERROR, "device disconnection failed with
return code %d", rc);
- return -1;
+ if (!strcmp(loaderData->ipv4, "ibft")) {
+ logMessage(INFO, "device %s is already activated by
NM using iBFT", devicename);
+ } else {
+ logMessage(INFO, "device %s is already activated",
devicename);
+ if ((rc = disconnectDevice(devicename)) != 0) {
+ logMessage(ERROR, "device disconnection failed
with return code %d", rc);
+ return -1;
+ }
}
}
From what I can tell this looks good to me. ACK