summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-09-27 01:36:03 +0200
committerDonald Sharp <sharpd@nvidia.com>2021-09-27 02:17:40 +0200
commit0e5cdd59eb0f080c4c82b5b54597b16a94775732 (patch)
treeebd356e66b20c9a39c20e66cc78df4df5552f9a7 /bgpd
parentMerge pull request #9638 from proelbtn/fix-multipath-srv6-sid (diff)
downloadfrr-0e5cdd59eb0f080c4c82b5b54597b16a94775732.tar.xz
frr-0e5cdd59eb0f080c4c82b5b54597b16a94775732.zip
bgpd: Don't lookup paf structure get straight to the point
The paf data structure is stored based upon an internal bgp enum. The code is looking over all AFI/SAFI's and doing a paf_af_find which then calls afindex to find the right paf structure. Let's just loop over the peer->peer_af_array[] and cut straight to the chase. Under some loads the paf_af_find was taking up 6% of the run time. This removes it entirely. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_packet.c18
-rw-r--r--bgpd/bgp_vty.c10
2 files changed, 22 insertions, 6 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 4fdb92ce7..bb2dbc942 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -337,11 +337,13 @@ static void bgp_write_proceed_actions(struct peer *peer)
struct peer_af *paf;
struct bpacket *next_pkt;
struct update_subgroup *subgrp;
+ enum bgp_af_index index;
- FOREACH_AFI_SAFI (afi, safi) {
- paf = peer_af_find(peer, afi, safi);
+ for (index = BGP_AF_START; index < BGP_AF_MAX; index++) {
+ paf = peer->peer_af_array[index];
if (!paf)
continue;
+
subgrp = paf->subgroup;
if (!subgrp)
continue;
@@ -364,6 +366,9 @@ static void bgp_write_proceed_actions(struct peer *peer)
return;
}
+ afi = paf->afi;
+ safi = paf->safi;
+
/* No packets to send, see if EOR is pending */
if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) {
if (!subgrp->t_coalesce && peer->afc_nego[afi][safi]
@@ -415,11 +420,16 @@ int bgp_generate_updgrp_packets(struct thread *thread)
return 0;
do {
+ enum bgp_af_index index;
+
s = NULL;
- FOREACH_AFI_SAFI (afi, safi) {
- paf = peer_af_find(peer, afi, safi);
+ for (index = BGP_AF_START; index < BGP_AF_MAX; index++) {
+ paf = peer->peer_af_array[index];
if (!paf || !PAF_SUBGRP(paf))
continue;
+
+ afi = paf->afi;
+ safi = paf->safi;
next_pkt = paf->next_pkt_to_send;
/*
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 8a3e74e8a..14f4fb731 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -912,13 +912,19 @@ static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi,
if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) {
afi_t tmp_afi;
safi_t tmp_safi;
+ enum bgp_af_index index;
+
+ for (index = BGP_AF_START; index < BGP_AF_MAX; index++) {
+ paf = peer->peer_af_array[index];
+ if (!paf)
+ continue;
- FOREACH_AFI_SAFI (tmp_afi, tmp_safi) {
- paf = peer_af_find(peer, tmp_afi, tmp_safi);
if (paf && paf->subgroup)
SET_FLAG(paf->subgroup->sflags,
SUBGRP_STATUS_FORCE_UPDATES);
+ tmp_afi = paf->afi;
+ tmp_safi = paf->safi;
if (!peer->afc[tmp_afi][tmp_safi])
continue;