]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Limit processing to what is needed in rpki validation
authorDonald Sharp <sharpd@nvidia.com>
Sun, 15 Aug 2021 14:15:38 +0000 (10:15 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 16 Aug 2021 15:04:06 +0000 (11:04 -0400)
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 <sharpd@nvidia.com>
bgpd/bgp_rpki.c

index a8bccecacf01d122f45766a196d315bcabc4fe0c..451264ef7dcdc5cb7576ed52914abb0bbe3a818d 100644 (file)
@@ -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);
                        }
                }
        }