From b6fbedf471a68c651efede9cc2abf3ef2530b057 Mon Sep 17 00:00:00 2001 From: Shaun Voigt Date: Mon, 6 Apr 2020 17:36:32 +0930 Subject: [PATCH 1/5] Fix for IPv6 Addresses disappear with FRR #421 --- daemon/core/nodes/netclient.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 0ad62e50..36902d52 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -4,7 +4,7 @@ Clients for dealing with bridge/interface commands. import json from typing import Callable -from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, TC_BIN +from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, TC_BIN, SYSCTL_BIN class LinuxNetClient: @@ -168,6 +168,10 @@ class LinuxNetClient: ) else: self.run(f"{IP_BIN} address add {address} dev {device}") + if ':' in address: + # IPv6 addresses are removed by default on interface down. + # Make sure that the IPv6 address we add is not removed + self.run(f"{SYSCTL_BIN} -w net.ipv6.conf.{device}.keep_addr_on_down=1") def delete_address(self, device: str, address: str) -> None: """ From 953bd80e2ea06aa41d5ed6953062658480329b1a Mon Sep 17 00:00:00 2001 From: Shaun Voigt Date: Mon, 6 Apr 2020 17:54:42 +0930 Subject: [PATCH 2/5] isort - sort imports --- daemon/core/nodes/netclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 36902d52..bea2b0e8 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -4,7 +4,7 @@ Clients for dealing with bridge/interface commands. import json from typing import Callable -from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, TC_BIN, SYSCTL_BIN +from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, SYSCTL_BIN, TC_BIN class LinuxNetClient: From ba1885350945b5ae500a975719e852bab55763e6 Mon Sep 17 00:00:00 2001 From: Shaun Voigt Date: Mon, 6 Apr 2020 18:03:27 +0930 Subject: [PATCH 3/5] resolve black formatting --- daemon/core/nodes/netclient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index bea2b0e8..99e6569a 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -168,10 +168,10 @@ class LinuxNetClient: ) else: self.run(f"{IP_BIN} address add {address} dev {device}") - if ':' in address: - # IPv6 addresses are removed by default on interface down. + if ":" in address: + # IPv6 addresses are removed by default on interface down. # Make sure that the IPv6 address we add is not removed - self.run(f"{SYSCTL_BIN} -w net.ipv6.conf.{device}.keep_addr_on_down=1") + self.run(f"{SYSCTL_BIN} -w net.ipv6.conf.{device}.keep_addr_on_down=1") def delete_address(self, device: str, address: str) -> None: """ From 8dfdd6171df7a1fa317c12ae16f229fa28355ee9 Mon Sep 17 00:00:00 2001 From: Shaun Voigt Date: Tue, 7 Apr 2020 07:44:23 +0930 Subject: [PATCH 4/5] check for ipv6 address using netaddr.valid_ipv6 --- daemon/core/nodes/netclient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 99e6569a..84727e7d 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -3,6 +3,7 @@ Clients for dealing with bridge/interface commands. """ import json from typing import Callable +import netaddr from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, SYSCTL_BIN, TC_BIN @@ -168,7 +169,7 @@ class LinuxNetClient: ) else: self.run(f"{IP_BIN} address add {address} dev {device}") - if ":" in address: + if netaddr.valid_ipv6(address.split("/")[0]): # IPv6 addresses are removed by default on interface down. # Make sure that the IPv6 address we add is not removed self.run(f"{SYSCTL_BIN} -w net.ipv6.conf.{device}.keep_addr_on_down=1") From 6c9c2cbeb0179fb9866839dc08f890002bdb870d Mon Sep 17 00:00:00 2001 From: Shaun Voigt Date: Tue, 7 Apr 2020 07:50:26 +0930 Subject: [PATCH 5/5] resolve isort --- daemon/core/nodes/netclient.py | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 84727e7d..12ab8dc1 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -3,6 +3,7 @@ Clients for dealing with bridge/interface commands. """ import json from typing import Callable + import netaddr from core.constants import ETHTOOL_BIN, IP_BIN, OVS_BIN, SYSCTL_BIN, TC_BIN