From: Donatas Abraitis Date: Mon, 20 Nov 2023 10:14:43 +0000 (+0200) Subject: bgpd: Optimize prefix-list lookup for debug messages X-Git-Tag: base_10.0~243^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=22f6b2bafe37536bdcbfdaf5b199436d6f4c076e;p=matthieu%2Ffrr.git bgpd: Optimize prefix-list lookup for debug messages Pass prefix-list pointers at configuration time. Signed-off-by: Donatas Abraitis --- diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 059f921ed1..138ffedb29 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; diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h index 4e930c244c..1fc2a87e2c 100644 --- a/bgpd/bgp_debug.h +++ b/bgpd/bgp_debug.h @@ -97,6 +97,8 @@ extern struct list *bgp_debug_zebra_prefixes; struct bgp_debug_filter { char *host; char *plist_name; + struct prefix_list *plist_v4; + struct prefix_list *plist_v6; struct prefix *p; };