diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-11-20 11:14:43 +0100 |
---|---|---|
committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-11-22 07:06:33 +0100 |
commit | 22f6b2bafe37536bdcbfdaf5b199436d6f4c076e (patch) | |
tree | 46b8adb12082627b623d98362637c28de80b38af /bgpd/bgp_debug.c | |
parent | bgpd: Add an ability to filter UPDATEs using neighbor with prefix-list (diff) | |
download | frr-22f6b2bafe37536bdcbfdaf5b199436d6f4c076e.tar.xz frr-22f6b2bafe37536bdcbfdaf5b199436d6f4c076e.zip |
bgpd: Optimize prefix-list lookup for debug messages
Pass prefix-list pointers at configuration time.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_debug.c')
-rw-r--r-- | bgpd/bgp_debug.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 059f921ed..138ffedb2 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -305,15 +305,26 @@ static void bgp_debug_list_add_entry(struct list *list, const char *host, if (host) { filter->host = XSTRDUP(MTYPE_BGP_DEBUG_STR, host); + filter->plist_name = NULL; + filter->plist_v4 = NULL; + filter->plist_v6 = NULL; filter->p = NULL; } else if (p) { filter->host = NULL; + filter->plist_name = NULL; + filter->plist_v4 = NULL; + filter->plist_v6 = NULL; filter->p = prefix_new(); prefix_copy(filter->p, p); } - if (plist_name) + if (plist_name) { filter->plist_name = XSTRDUP(MTYPE_BGP_DEBUG_STR, plist_name); + filter->plist_v4 = prefix_list_lookup(AFI_IP, + filter->plist_name); + filter->plist_v6 = prefix_list_lookup(AFI_IP6, + filter->plist_name); + } listnode_add(list, filter); } @@ -2560,8 +2571,8 @@ static bool bgp_debug_per_peer(char *host, const struct prefix *p, struct prefix_list *plist; afi_t afi = family2afi(p->family); - plist = prefix_list_lookup(afi, - filter->plist_name); + plist = (afi == AFI_IP) ? filter->plist_v4 + : filter->plist_v6; if (!plist) continue; |