Skip to content

Commit

Permalink
bgpd: Optimize prefix-list lookup for debug messages
Browse files Browse the repository at this point in the history
Pass prefix-list pointers at configuration time.

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Nov 20, 2023
1 parent c2d832a commit edea70a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgp_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit edea70a

Please sign in to comment.