From 8ae77f3b1281008232c38cc9baef25213edcb742 Mon Sep 17 00:00:00 2001 From: Kalash Nainwal Date: Tue, 28 Jan 2025 17:23:59 -0800 Subject: [PATCH] fixing the neighbor table entry match to correctly show neighbor name in unified frr config mgmt mode --- utilities_common/bgp_util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utilities_common/bgp_util.py b/utilities_common/bgp_util.py index 5ecedb061c..dd10550e58 100644 --- a/utilities_common/bgp_util.py +++ b/utilities_common/bgp_util.py @@ -149,8 +149,18 @@ def get_bgp_neighbor_ip_to_name(ip, static_neighbors, dynamic_neighbors): :param dynamic_neighbors: subnet of dynamically defined neighbors dict :return: name of neighbor """ + # Direct IP match if ip in static_neighbors: return static_neighbors[ip] + # Try to find the key where IP is the second element of any tuple key. + # This is to handle the case where the key is a tuple like (vrfname, IP) + # when unified routing config mode is enabled + elif matching_key := next( + (key for key in static_neighbors.keys() + if isinstance(key, tuple) and len(key) == 2 and key[1] == ip), + None + ): + return static_neighbors[matching_key] elif is_ipv4_address(ip): for subnet in dynamic_neighbors[constants.IPV4]: if ipaddress.IPv4Address(ip) in ipaddress.IPv4Network(subnet):