Skip to content

Commit

Permalink
update nlcache after sysctl_set accept_ra/autoconf
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 5fb3acc commit e0c123d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ifupdown2/addons/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ def _sysctl_config(self, ifaceobj):
self.sysctl_set('net.ipv6.conf.%s.accept_ra'
%('/'.join(ifaceobj.name.split("."))),
accept_ra)
self.cache.update_link_inet6_accept_ra(ifaceobj.name, accept_ra)

running_autoconf = self.cache.get_link_inet6_autoconf(ifaceobj)
if running_autoconf == '':
Expand All @@ -1041,6 +1042,8 @@ def _sysctl_config(self, ifaceobj):
self.sysctl_set('net.ipv6.conf.%s.autoconf'
%('/'.join(ifaceobj.name.split("."))),
autoconf)
self.cache.update_link_inet6_autoconf(ifaceobj.name, autoconf)

except Exception as e:
if not setting_default_value:
ifaceobj.status = ifaceStatus.ERROR
Expand Down
10 changes: 8 additions & 2 deletions ifupdown2/addons/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,20 @@ def _up(self, ifaceobj):
if 'inet6' in ifaceobj.addr_family:
running_accept_ra = self.cache.get_link_inet6_accept_ra(ifaceobj)
if running_accept_ra != '2':
accept_ra = '2'
self.sysctl_set('net.ipv6.conf.%s.accept_ra'
%('/'.join(ifaceobj.name.split("."))),
2)
accept_ra)
self.cache.update_link_inet6_accept_ra(ifaceobj.name, accept_ra)

running_autoconf = self.cache.get_link_inet6_autoconf(ifaceobj)
if running_autoconf != '1':
autoconf = '1'
self.sysctl_set('net.ipv6.conf.%s.autoconf'
%('/'.join(ifaceobj.name.split("."))),
1)
autoconf)
self.cache.update_link_inet6_autoconf(ifaceobj.name, autoconf)

except Exception as e:
self.logger.error("%s: %s" % (ifaceobj.name, str(e)))
ifaceobj.set_status(ifaceStatus.ERROR)
Expand Down
21 changes: 21 additions & 0 deletions ifupdown2/lib/nlcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,27 @@ def get_link_inet6_autoconf(self, ifaceobj):
autoconf = ''
return autoconf

def update_link_inet6_accept_ra(self, ifname, accept_ra):
try:
with self._cache_lock:
try:
self._link_cache[ifname].attributes[Link.IFLA_AF_SPEC].value[socket.AF_INET6][Link.IFLA_INET6_CONF]['accept_ra'] = accept_ra
except Exception as e:
pass
except Exception:
pass

def update_link_inet6_autoconf(self, ifname, autoconf):
try:
with self._cache_lock:
try:
self._link_cache[ifname].attributes[Link.IFLA_AF_SPEC].value[socket.AF_INET6][Link.IFLA_INET6_CONF]['autoconf'] = autoconf
except Exception as e:
pass
except Exception:
pass


#####################################################
#####################################################
#####################################################
Expand Down

0 comments on commit e0c123d

Please sign in to comment.