summaryrefslogtreecommitdiff
path: root/python/vyos/utils
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-07-22 18:06:36 +0200
committerGitHub <noreply@github.com>2024-07-22 18:06:36 +0200
commit405ae90fd9cb44e997897c0c58253e752b220c43 (patch)
treee404c54cf43003a698ee627ac9262aa86b516bbd /python/vyos/utils
parent5ae173c05defa1e230552271018133816ca00467 (diff)
parentac8dc93755b8e25434f36ab9a665c1a6a9e5bc3b (diff)
downloadvyos-1x-405ae90fd9cb44e997897c0c58253e752b220c43.tar.gz
vyos-1x-405ae90fd9cb44e997897c0c58253e752b220c43.zip
Merge pull request #3837 from vyos/mergify/bp/sagitta/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.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py
index a3bd5c58f..8befe370f 100644
--- a/python/vyos/utils/network.py
+++ b/python/vyos/utils/network.py
@@ -70,6 +70,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.