summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2024-10-30 11:14:56 -0400
committerDonald Sharp <sharpd@nvidia.com>2024-10-31 10:35:00 -0400
commitd9fd4901f0295d65ffdebb189d92a7d24e7d5e6f (patch)
tree304d62c93f0e2cf392cf98a70b456c773ef07edf
parent852e6c327dcaea1b73a5f703646edb5685dac204 (diff)
bgpd: Only set bgp_labels in bgp_update if we have num_labels
In the interest of speeding up code, there is no point in attempting to see if a label is usable if the number of labels passed in is 0. Since that is a much much quicker test than the bgp_is_valid_label() call, let's test that first. Additionally, there is no point in walking the label[] array passed in unless we are in the if statement, so move it inside. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--bgpd/bgp_route.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 25ef025412..f58be40b72 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -4667,11 +4667,12 @@ void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp = peer->bgp;
dest = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
- if ((afi == AFI_L2VPN && safi == SAFI_EVPN) ||
- bgp_is_valid_label(&label[0]))
+ if (num_labels &&
+ ((afi == AFI_L2VPN && safi == SAFI_EVPN) || bgp_is_valid_label(&label[0]))) {
bgp_labels.num_labels = num_labels;
- for (i = 0; i < bgp_labels.num_labels; i++)
- bgp_labels.label[i] = label[i];
+ for (i = 0; i < bgp_labels.num_labels; i++)
+ bgp_labels.label[i] = label[i];
+ }
/* When peer's soft reconfiguration enabled. Record input packet in
Adj-RIBs-In. */