Change in vdsm[master]: net: Disable IPv6 when IPV6INIT=no

edwardh at redhat.com edwardh at redhat.com
Tue Mar 1 10:26:42 UTC 2016


Edward Haas has uploaded a new change for review.

Change subject: net: Disable IPv6 when IPV6INIT=no
......................................................................

net: Disable IPv6 when IPV6INIT=no

Setting IPV6INIT=no in the ifcfg-* files does not disable IPv6, it just
instructs initscripts to ignore any IPv6 related settings.
We consider this an initscripts limitation and are forced to 'fix'
through vdsm.

The solution presented in this patch uses an icfg hook.
VDSM distributes the file /usr/libexec/vdsm/ifcfg_trail_hook and on each
ifcfg-* that is owned by VDSM, a source call to the hook is added.
Currently, ifcfg_trail_hook performs only one action: Checking IPV6INIT
and applying the kernel IPv6 state accordingly.

This patch does not handle the following scenarios:
- When upgrading from an older version, the initial boot will not
  include the hook reference in the ifcfg-* files, therefore the IPv6
  state will not be changed.
- A change that does not trigger a creation of a clean ifcfg-* file, will
  not include the hook refference in the file.
  Bridge changes (edits) is an example of such changes.
  When there is no change between the setup request to the current
  config is another example.
  * It should be fixed in a following patch, stating the IPv6 state.

Change-Id: I19c444928ffc0296446e7e11cb98c26d77da0ec2
Signed-off-by: Edward Haas <edwardh at redhat.com>
---
M debian/vdsm.install
M lib/vdsm/network/configurators/ifcfg.py
M tests/functional/networkTests.py
M vdsm.spec.in
M vdsm/Makefile.am
A vdsm/ifcfg_trail_hook
6 files changed, 55 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/54206/1

diff --git a/debian/vdsm.install b/debian/vdsm.install
index 2688f4a..a7d2bf0 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -32,6 +32,7 @@
 ./usr/libexec/vdsm/vdsm-gencerts.sh
 ./usr/libexec/vdsm/vdsmd_init_common.sh
 ./usr/libexec/vdsm/wait_for_ipv4s
+./usr/libexec/vdsm/ifcfg_trail_hook
 ./usr/share/man/man8/vdsmd.8
 ./usr/share/vdsm/API.py
 ./usr/share/vdsm/alignmentScan.py
diff --git a/lib/vdsm/network/configurators/ifcfg.py b/lib/vdsm/network/configurators/ifcfg.py
index 395dd31..0dd082d 100644
--- a/lib/vdsm/network/configurators/ifcfg.py
+++ b/lib/vdsm/network/configurators/ifcfg.py
@@ -544,6 +544,8 @@
                 cfg += 'DHCPV6C=yes\n'
             cfg += 'IPV6_AUTOCONF=%s\n' % _to_ifcfg_bool(ipv6.ipv6autoconf)
 
+        cfg += '. /usr/libexec/vdsm/ifcfg_trail_hook'
+
         ifcfg_file = NET_CONF_PREF + name
         hook_dict = {'ifcfg_file': ifcfg_file,
                      'config': cfg}
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index c469408..dd0dccd 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -1920,6 +1920,7 @@
                     self.assertEqual(IPv6_GATEWAY, test_net['ipv6gateway'])
                 else:
                     self.assertEqual([], test_net['ipv6addrs'])
+                    self.assertEqual(1, sysctl.is_disabled_ipv6())
                 delete = {NETWORK_NAME: {'remove': True}}
                 status, msg = self.setupNetworks(delete, {}, {})
                 self.assertEqual(status, SUCCESS, msg)
@@ -2006,6 +2007,7 @@
             return None, None
 
         with veth_pair() as (left, right):
+            sysctl.disable_ipv6(left, disable=False)
             addrAdd(left, IP_ADDRESS, IP_CIDR)
             addrAdd(left, IPv6_ADDRESS, IPv6_CIDR, 6)
             linkSet(left, ['up'])
@@ -2054,6 +2056,7 @@
     @RequireVethMod
     def testDhcpReplaceNicWithBridge(self):
         with veth_pair() as (left, right):
+            sysctl.disable_ipv6(left, disable=False)
             addrAdd(left, IP_ADDRESS, IP_CIDR)
             addrAdd(left, IPv6_ADDRESS, IPv6_CIDR, 6)
             linkSet(left, ['up'])
@@ -2149,6 +2152,7 @@
     @RequireVethMod
     def testDhclientLeases(self, family, dateFormat):
         with veth_pair() as (server, client):
+            sysctl.disable_ipv6(server, disable=False)
             addrAdd(server, IP_ADDRESS, IP_CIDR)
             addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, 6)
             linkSet(server, ['up'])
@@ -2182,6 +2186,7 @@
             finally:
                 addrFlush(nic)
 
+            sysctl.disable_ipv6(nic, disable=False)
             addrAdd(nic, IPv6_ADDRESS, IPv6_CIDR, family=6)
             try:
                 linkSet(nic, ['up'])
@@ -2757,6 +2762,7 @@
     def test_drop_initial_network_nic_ip_config(self):
         with dummyIf(1) as nics:
             nic, = nics
+            sysctl.disable_ipv6(nic, disable=False)
             addrAdd(nic, IP_ADDRESS, IP_CIDR)
             addrAdd(nic, IPv6_ADDRESS, IPv6_CIDR, family=6)
             try:
@@ -2781,6 +2787,7 @@
     def test_drop_initial_bond_slaves_ip_config(self):
         with dummyIf(2) as nics:
             nic_1, nic_2 = nics
+            sysctl.disable_ipv6(nic_1, disable=False)
             addrAdd(nic_1, IP_ADDRESS, IP_CIDR)
             addrAdd(nic_1, IPv6_ADDRESS, IPv6_CIDR, family=6)
             try:
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 24576e2..242a142 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -910,6 +910,7 @@
 %{_libexecdir}/%{vdsm_name}/vdsm-gencerts.sh
 %{_libexecdir}/%{vdsm_name}/vdsmd_init_common.sh
 %{_libexecdir}/%{vdsm_name}/wait_for_ipv4s
+%{_libexecdir}/%{vdsm_name}/ifcfg_trail_hook
 %{_datadir}/%{vdsm_name}/supervdsm_api/__init__.py*
 %{_datadir}/%{vdsm_name}/supervdsm_api/hwinfo.py*
 %{_datadir}/%{vdsm_name}/supervdsm_api/network.py*
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index d037eb6..debbc16 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -40,7 +40,9 @@
 	$(NULL)
 
 dist_vdsmexec_SCRIPTS = \
-	ovirt_functions.sh
+	ovirt_functions.sh \
+	ifcfg_trail_hook \
+	$(NULL)
 
 nodist_vdsmexec_SCRIPTS = \
 	vdsm-gencerts.sh \
diff --git a/vdsm/ifcfg_trail_hook b/vdsm/ifcfg_trail_hook
new file mode 100644
index 0000000..ab3fc99
--- /dev/null
+++ b/vdsm/ifcfg_trail_hook
@@ -0,0 +1,41 @@
+# Copyright 2015 Red Hat, Inc.
+#
+# 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
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+# ifcfg_trail_hook is aimed to extend initscripts and make it possible
+# for VDSM to add functionality per device.
+# It mainly targets limitations of initscripts.
+# VDSM adds this file to all ifcfg-* files under its ownership
+
+disable_ipv6 ()
+{
+    if [[ "$IPV6INIT" = [nN0]* ]]; then
+        /sbin/sysctl -e -w "net.ipv6.conf.$DEVICE.disable_ipv6=1" >/dev/null 2>&1
+        if [ $? -ne 0 ]; then
+                net_log $"Cannot disable IPv6 on '$DEVICE'"
+        fi
+    else
+        /sbin/sysctl -e -w "net.ipv6.conf.$DEVICE.disable_ipv6=0" >/dev/null 2>&1
+        if [ $? -ne 0 ]; then
+                net_log $"Cannot enable IPv6 on '$DEVICE'"
+        fi
+    fi
+}
+
+disable_ipv6
+


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19c444928ffc0296446e7e11cb98c26d77da0ec2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>


More information about the vdsm-patches mailing list