Skip to content

Commit

Permalink
RemoteDevice: added {keep,remove}_on_down functions
Browse files Browse the repository at this point in the history
Added functions that can set/unset device's flag to
either keep or remove IPv6 addresses on shutting-down
device.
  • Loading branch information
enhaut committed Jul 19, 2024
1 parent 9aaf9db commit 7d8fbf9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lnst/Controller/Namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,9 @@ def _update_device_id(self, value, name):
return

dev._id = name

def keep_addrs_on_dev_down(self, device: Device) -> None:
self.run(f"echo 1 > /proc/sys/net/ipv6/conf/{device.name}/keep_addr_on_down")

def remove_addrs_on_dev_down(self, device: Device):
self.run(f"echo 0 > /proc/sys/net/ipv6/conf/{device.name}/keep_addr_on_down")
7 changes: 7 additions & 0 deletions lnst/Devices/RemoteDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ def __repr__(self):

return "{}({})".format(self._dev_cls.__name__, ", ".join(args))

def keep_addrs_on_down(self) -> None:
self.netns.run(f"echo 1 > /proc/sys/net/ipv6/conf/{self.name}/keep_addr_on_down")

def remove_addrs_on_down(self):
self.netns.run(f"echo 0 > /proc/sys/net/ipv6/conf/{self.name}/keep_addr_on_down")


class PairedRemoteDevice(RemoteDevice):
"""RemoteDevice class for paired Devices (such as veth)"""
def __init__(self, peer, dev_cls, args=[], kwargs={}):
Expand Down

0 comments on commit 7d8fbf9

Please sign in to comment.