From: Donald Sharp Date: Sun, 15 Aug 2021 14:15:38 +0000 (-0400) Subject: bgpd: Limit processing to what is needed in rpki validation X-Git-Tag: base_8.1~188^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=35a1e798f8bacf1bcfec7cfabe7c05432323ca23;p=matthieu%2Ffrr.git bgpd: Limit processing to what is needed in rpki validation The processing was looping over all bgp instances then over all peers then over all safi's to find a match for a prefix received in order to validate it. Suppose you have 100 peers each sending you the same prefix. This code will cause it to look at each node 100 times since we look at for each peer. This is especially egregarious because we never ever do anything with the peer when we are looping over them. Remove the peer loop, significantly reduce processing. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index a8bccecacf..451264ef7d 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -388,33 +388,25 @@ static int bgpd_sync_callback(struct thread *thread) afi_t afi = (rec.prefix.ver == LRTR_IPV4) ? AFI_IP : AFI_IP6; for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { - struct peer *peer; - struct listnode *peer_listnode; - - for (ALL_LIST_ELEMENTS_RO(bgp->peer, peer_listnode, peer)) { - safi_t safi; - - for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { - if (!peer->bgp->rib[afi][safi]) - continue; + safi_t safi; - struct bgp_dest *match; - struct bgp_dest *node; + for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { + if (!bgp->rib[afi][safi]) + continue; - match = bgp_table_subtree_lookup( - peer->bgp->rib[afi][safi], prefix); - node = match; + struct bgp_dest *match; + struct bgp_dest *node; - while (node) { - if (bgp_dest_has_bgp_path_info_data( - node)) { - revalidate_bgp_node(node, afi, - safi); - } + match = bgp_table_subtree_lookup(bgp->rib[afi][safi], + prefix); + node = match; - node = bgp_route_next_until(node, - match); + while (node) { + if (bgp_dest_has_bgp_path_info_data(node)) { + revalidate_bgp_node(node, afi, safi); } + + node = bgp_route_next_until(node, match); } } }