]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
don't change interface forwarding value if not defined
authorAlexandre Derumier <aderumier@odiso.com>
Sat, 4 May 2019 13:12:00 +0000 (15:12 +0200)
committerAlexandre Derumier <aderumier@odiso.com>
Sat, 4 May 2019 13:12:00 +0000 (15:12 +0200)
ifupdown2/addons/address.py

index d3a76cf714e54b341d647714cd2c637bb251f8dd..a2f86f3b9edf5d1f40bcba55b06738a560357919 100644 (file)
@@ -715,49 +715,42 @@ class address(moduleBase):
                 self.log_error('%s: \'ip6-forward\' is not supported for '
                                'bridge port' %ifaceobj.name)
             return
-        setting_default_value = False
-        if not ipforward:
-            setting_default_value = True
-            ipforward = (self.ipforward or
-                         self.get_mod_subattr('ip-forward', 'default'))
-        ipforward = utils.boolean_support_binary(ipforward)
-        # File read has been used for better performance
-        # instead of using sysctl command
-        running_ipforward = self.read_file_oneline(
-                                '/proc/sys/net/ipv4/conf/%s/forwarding'
-                                %ifaceobj.name)
-        if ipforward != running_ipforward:
-            try:
-                self.sysctl_set('net.ipv4.conf.%s.forwarding'
-                                %('/'.join(ifaceobj.name.split("."))),
-                                ipforward)
-            except Exception as e:
-                if not setting_default_value:
+
+        if ipforward:
+            ipforward = utils.boolean_support_binary(ipforward)
+            # File read has been used for better performance
+            # instead of using sysctl command
+            running_ipforward = self.read_file_oneline(
+                                    '/proc/sys/net/ipv4/conf/%s/forwarding'
+                                   %ifaceobj.name)
+
+            if ipforward != running_ipforward:
+                try:
+
+                    self.sysctl_set('net.ipv4.conf.%s.forwarding'
+                                    %('/'.join(ifaceobj.name.split("."))),
+                                    ipforward)
+                except Exception as e:
                     ifaceobj.status = ifaceStatus.ERROR
                     self.logger.error('%s: %s' %(ifaceobj.name, str(e)))
 
-        setting_default_value = False
-        if not ip6forward:
-            setting_default_value = True
-            ip6forward = (self.ip6forward or
-                          self.get_mod_subattr('ip6-forward', 'default'))
-        ip6forward = utils.boolean_support_binary(ip6forward)
-        # File read has been used for better performance
-        # instead of using sysctl command
-        running_ip6forward = self.read_file_oneline(
-                                '/proc/sys/net/ipv6/conf/%s/forwarding'
-                                %ifaceobj.name)
-        if ip6forward != running_ip6forward:
-            try:
-                self.sysctl_set('net.ipv6.conf.%s.forwarding'
-                                %('/'.join(ifaceobj.name.split("."))),
-                                ip6forward)
-            except Exception as e:
-                # There is chance of ipv6 being removed because of,
-                # for example, setting mtu < 1280
-                # In such cases, log error only if user has configured
-                # ip6-forward
-                if not setting_default_value:
+        if ip6forward:
+            ip6forward = utils.boolean_support_binary(ip6forward)
+            # File read has been used for better performance
+            # instead of using sysctl command
+            running_ip6forward = self.read_file_oneline(
+                                    '/proc/sys/net/ipv6/conf/%s/forwarding'
+                                    %ifaceobj.name)
+            if ip6forward != running_ip6forward:
+                try:
+                    self.sysctl_set('net.ipv6.conf.%s.forwarding'
+                                    %('/'.join(ifaceobj.name.split("."))),
+                                    ip6forward)
+                except Exception as e:
+                    # There is chance of ipv6 being removed because of,
+                    # for example, setting mtu < 1280
+                    # In such cases, log error only if user has configured
+                    # ip6-forward
                     ifaceobj.status = ifaceStatus.ERROR
                     self.logger.error('%s: %s' %(ifaceobj.name, str(e)))