summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-09-04 15:51:00 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2023-09-04 15:51:00 +0000
commit500d59cb1fe12916ae529fa20860f1518d68244b (patch)
treef1c3d8236101aa34c4e4093e23be6bc8c2d8e265 /python/vyos/util.py
parente74b38c4d862feed7a401723c1f0b1c9d9a03324 (diff)
downloadvyos-1x-500d59cb1fe12916ae529fa20860f1518d68244b.tar.gz
vyos-1x-500d59cb1fe12916ae529fa20860f1518d68244b.zip
T5533: Fix VRRP IPv6 FAULT state due to IPv6 tentative state
Checks if an IPv6 address on a specific network interface is in the tentative state. IPv6 tentative addresses are not fully configured and are undergoing Duplicate Address Detection (DAD) to ensure they are unique on the network. inet6 2001:db8::3/125 scope global tentative It tentative state the group enters in FAULT state. Fix it.
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 20c743b35..e83a17e18 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -920,6 +920,34 @@ def is_ipv6_enabled() -> bool:
""" Check if IPv6 support on the system is enabled or not """
return (sysctl_read('net.ipv6.conf.all.disable_ipv6') == '0')
+def is_ipv6_tentative(iface: str, ipv6_address: str) -> bool:
+ """Check if IPv6 address is in tentative state.
+ This function checks if an IPv6 address on a specific network interface is
+ in the tentative state. IPv6 tentative addresses are not fully configured
+ and are undergoing Duplicate Address Detection (DAD) to ensure they are
+ unique on the network.
+ Args:
+ iface (str): The name of the network interface.
+ ipv6_address (str): The IPv6 address to check.
+ Returns:
+ bool: True if the IPv6 address is tentative, False otherwise.
+ """
+ import json
+ from vyos.util import rc_cmd
+
+ rc, out = rc_cmd(f'ip -6 --json address show dev {iface} scope global')
+ if rc:
+ return False
+
+ data = json.loads(out)
+ for addr_info in data[0]['addr_info']:
+ if (
+ addr_info.get('local') == ipv6_address and
+ addr_info.get('tentative', False)
+ ):
+ return True
+ return False
+
def interface_exists(interface) -> bool:
import os
return os.path.exists(f'/sys/class/net/{interface}')