From a6d1af3c943600e971662b5b8992a576804ec060 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Thu, 14 Dec 2023 17:29:39 +0000 Subject: T5749: Add a more scrict search for get_vrf method The current implementation is wrong as it searches `master` in the iproute2 JSON output. It is a worng as it could include bridges or bonding interfaces Add the more strict search `info_slave_kind == vrf` (cherry picked from commit 2ebac5af10a36668ed3b8cfa6e5a9f61cf5d1068) --- python/vyos/ifconfig/interface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 8783ccc1e..a038ef28d 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -113,7 +113,7 @@ class Interface(Control): }, 'vrf': { 'shellcmd': 'ip -json -detail link list dev {ifname}', - 'format': lambda j: jmespath.search('[*].master | [0]', json.loads(j)), + 'format': lambda j: jmespath.search('[?linkinfo.info_slave_kind == `vrf`].master | [0]', json.loads(j)), }, } -- cgit v1.2.3