diff options
author | Christian Breunig <christian@breunig.cc> | 2024-07-24 11:19:16 +0200 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-07-24 23:52:14 +0000 |
commit | 28fedd4e76bbea2b174159ee7b67ddda5e952ab5 (patch) | |
tree | d5f6f1e02bc37877a5b1d0422909435ff49d0a72 /python/vyos | |
parent | 92740091d793114504feeacc210360220cae9e08 (diff) | |
download | vyos-1x-28fedd4e76bbea2b174159ee7b67ddda5e952ab5.tar.gz vyos-1x-28fedd4e76bbea2b174159ee7b67ddda5e952ab5.zip |
smoketest: T6592: verify no interface stalls in conntrack ct_iface_map on deletion
Now that interfaces are deleted from ct_iface_map during deletion it's time to
also add a smoketest ensuring there is no entry in the ct_iface_map once an
interface was deleted from the CLI.
(cherry picked from commit 1c42ee9d16dd49fff2cbde652bf24a38f364526c)
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/utils/network.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 8406a5638..8fce08de0 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -569,3 +569,31 @@ def ipv6_prefix_length(low, high): return plen + i + 1 return None + +def get_nft_vrf_zone_mapping() -> dict: + """ + Retrieve current nftables conntrack mapping list from Kernel + + returns: [{'interface': 'red', 'vrf_tableid': 1000}, + {'interface': 'eth2', 'vrf_tableid': 1000}, + {'interface': 'blue', 'vrf_tableid': 2000}] + """ + from json import loads + from jmespath import search + from vyos.utils.process import cmd + output = [] + tmp = loads(cmd('sudo nft -j list table inet vrf_zones')) + # {'nftables': [{'metainfo': {'json_schema_version': 1, + # 'release_name': 'Old Doc Yak #3', + # 'version': '1.0.9'}}, + # {'table': {'family': 'inet', 'handle': 6, 'name': 'vrf_zones'}}, + # {'map': {'elem': [['eth0', 666], + # ['dum0', 666], + # ['wg500', 666], + # ['bond10.666', 666]], + vrf_list = search('nftables[].map.elem | [0]', tmp) + if not vrf_list: + return output + for (vrf_name, vrf_id) in vrf_list: + output.append({'interface' : vrf_name, 'vrf_tableid' : vrf_id}) + return output |