From d4019ee902c6caaa2413b08e58fff1fb05e5c86a Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Fri, 10 Aug 2018 11:37:41 +0200 Subject: [PATCH] LinkUtils: addrgen: move disable_ipv6 check before MTU check if disable_ipv6 is on there's no need to check for the MTU Signed-off-by: Julien Fortin --- ifupdown2/ifupdownaddons/LinkUtils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ifupdown2/ifupdownaddons/LinkUtils.py b/ifupdown2/ifupdownaddons/LinkUtils.py index c1133fe..a0c7c63 100644 --- a/ifupdown2/ifupdownaddons/LinkUtils.py +++ b/ifupdown2/ifupdownaddons/LinkUtils.py @@ -2662,16 +2662,15 @@ class LinkUtils(utilsBase): self.logger.debug('%s: ipv6 addrgen already %s' % (ifname, 'off' if addrgen else 'on')) return - if int(self._link_cache_get([ifname, 'mtu'])) < 1280: - self.logger.info('%s: ipv6 addrgen is disabled on device with MTU ' - 'lower than 1280: cannot set addrgen %s' % (ifname, 'off' if addrgen else 'on')) - return - disabled_ipv6 = self.read_file_oneline('/proc/sys/net/ipv6/conf/%s/disable_ipv6' % ifname) if not disabled_ipv6 or int(disabled_ipv6) == 1: self.logger.info('%s: cannot set addrgen: ipv6 is disabled on this device' % ifname) return + if int(self._link_cache_get([ifname, 'mtu'])) < 1280: + self.logger.info('%s: ipv6 addrgen is disabled on device with MTU ' + 'lower than 1280: cannot set addrgen %s' % (ifname, 'off' if addrgen else 'on')) + return except (KeyError, TypeError): self.logger.debug('%s: ipv6 addrgen probably not supported or disabled on this device' % ifname) return