diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-07-22 10:49:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-22 10:49:33 +0200 |
| commit | a3d76254f4d47665f56261c9089a8a34761e0e18 (patch) | |
| tree | 1ca3d162d7a6c859c079afb3ffe09248b6a954af /python/vyos/utils | |
| parent | 5be256235052592dab254f55f5f329feb5e955b0 (diff) | |
| parent | 2b35ea81627277cd680ecd4ba79e944cc785c94b (diff) | |
| download | vyos-1x-a3d76254f4d47665f56261c9089a8a34761e0e18.tar.gz vyos-1x-a3d76254f4d47665f56261c9089a8a34761e0e18.zip | |
Merge pull request #3836 from vyos/mergify/bp/circinus/pr-3834
interfaces: T6592: moving an interface between VRF instances failed (backport #3834)
Diffstat (limited to 'python/vyos/utils')
| -rw-r--r-- | python/vyos/utils/network.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 829124b57..8406a5638 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -83,6 +83,19 @@ def get_interface_vrf(interface): return tmp['master'] return 'default' +def get_vrf_tableid(interface: str): + """ Return VRF table ID for given interface name or None """ + from vyos.utils.dict import dict_search + table = None + tmp = get_interface_config(interface) + # Check if we are "the" VRF interface + if dict_search('linkinfo.info_kind', tmp) == 'vrf': + table = tmp['linkinfo']['info_data']['table'] + # or an interface bound to a VRF + elif dict_search('linkinfo.info_slave_kind', tmp) == 'vrf': + table = tmp['linkinfo']['info_slave_data']['table'] + return table + def get_interface_config(interface): """ Returns the used encapsulation protocol for given interface. If interface does not exist, None is returned. @@ -537,21 +550,21 @@ def ipv6_prefix_length(low, high): return None xor = bytearray(a ^ b for a, b in zip(lo, hi)) - + plen = 0 while plen < 128 and xor[plen // 8] == 0: plen += 8 - + if plen == 128: return plen - + for i in range((plen // 8) + 1, 16): if xor[i] != 0: return None - + for i in range(8): msk = ~xor[plen // 8] & 0xff - + if msk == bytemasks[i]: return plen + i + 1 |
