Skip to content

Commit

Permalink
address: use default accept_ra|autoconf from net.ipv6.conf.all. sysctl
Browse files Browse the repository at this point in the history
  • Loading branch information
aderumier authored and Alexandre Derumier committed May 11, 2023
1 parent 7122284 commit 5fb3acc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ifupdown2/addons/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ def __init__(self, *args, **kargs):
attr="check_l3_svi_ip_forwarding")
)

try:
self.default_accept_ra = str(self.sysctl_get('net.ipv6.conf.all.accept_ra'))
except Exception:
self.default_accept_ra = 1

try:
self.default_autoconf = str(self.sysctl_get('net.ipv6.conf.all.autoconf'))
except Exception:
self.default_autoconf = 1

def __policy_get_default_mtu(self):
default_mtu = policymanager.policymanager_api.get_attr_default(
module_name=self.__class__.__name__,
Expand Down Expand Up @@ -1009,19 +1019,23 @@ def _sysctl_config(self, ifaceobj):

try:
running_accept_ra = self.cache.get_link_inet6_accept_ra(ifaceobj)
if running_accept_ra == '':
running_accept_ra = self.default_accept_ra
accept_ra = ifaceobj.get_attr_value_first('accept-ra')
if accept_ra is None:
accept_ra = '0'
accept_ra = self.default_accept_ra

if running_accept_ra != accept_ra:
self.sysctl_set('net.ipv6.conf.%s.accept_ra'
%('/'.join(ifaceobj.name.split("."))),
accept_ra)

running_autoconf = self.cache.get_link_inet6_autoconf(ifaceobj)
if running_autoconf == '':
running_autoconf = self.default_autoconf
autoconf = ifaceobj.get_attr_value_first('autoconf')
if autoconf is None:
autoconf = '0'
autoconf = self.default_autoconf

if running_autoconf != autoconf:
self.sysctl_set('net.ipv6.conf.%s.autoconf'
Expand Down

0 comments on commit 5fb3acc

Please sign in to comment.