Change in vdsm[ovirt-3.6.3]: restore-nets: disable IPv6 based on ifcfg files

osvoboda at redhat.com osvoboda at redhat.com
Fri Mar 4 15:03:03 UTC 2016


Hello Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/54362

to review the following change.

Change subject: restore-nets: disable IPv6 based on ifcfg files
......................................................................

restore-nets: disable IPv6 based on ifcfg files

Disabling IPv6 on networks in the kernel must be done even
before actual restoration is performed because there is probably going to
be a link-local address already (or "worse", initscripts may have acquired
a global address through autoconfiguration) and thus the network's state
would differ from the persisted config, causing needless restoration.

Change-Id: Ic3010e4a163cb8b7622b3b7425fa8fca09d602c7
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
Backport-To: 3.6
Reviewed-on: https://gerrit.ovirt.org/54226
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/vdsm-restore-net-config
1 file changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/54362/1

diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index 7ede6f0..5d22dde 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -34,6 +34,7 @@
 from vdsm.constants import P_VDSM_RUN
 from vdsm.netconfpersistence import RunningConfig, PersistentConfig, \
     KernelConfig, CONF_PERSIST_DIR, BaseConfig
+from vdsm import sysctl
 from vdsm.utils import monotonic_time
 import hostdev
 
@@ -124,6 +125,8 @@
 
     _wait_for_for_all_devices_up(
         available_config.networks.keys() + available_config.bonds.keys())
+    if netinfo.ipv6_supported():
+        _restore_disable_ipv6()
     changed_config = _filter_changed_nets_bonds(available_config)
     nets = changed_config.networks
     bonds = changed_config.bonds
@@ -341,6 +344,32 @@
                not l.oper_up)
 
 
+def _ifcfg_dev_name(file_name):
+    """Return the device name from the full path to its ifcfg- file."""
+    return os.path.basename(file_name)[6:]
+
+
+def _ipv6_ifcfg(link_name):
+    def ipv6init(content):
+        return all(line != 'IPV6INIT=no' for line in content.splitlines())
+    return _ifcfg_predicate(link_name, ipv6init)
+
+
+def _restore_disable_ipv6():
+    """
+    Disable IPv6 on networks with no IPv6 configuration. This must be done even
+    before actual restoration is performed because there is probably going to
+    be a link-local address already (or "worse", initscripts may have acquired
+    a global address through autoconfiguration) and thus the network's state
+    would differ from the persisted config, causing needless restoration.
+    This is implemented for unified persistence only.
+    """
+    for filename in _owned_ifcfg_files():
+        device = _ifcfg_dev_name(filename)
+        if not _ipv6_ifcfg(device):
+            sysctl.disable_ipv6(device)
+
+
 def _owned_ifcfg(link_name):
     return _ifcfg_predicate(link_name, _owned_ifcfg_content)
 


-- 
To view, visit https://gerrit.ovirt.org/54362
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3010e4a163cb8b7622b3b7425fa8fca09d602c7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6.3
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list