From ea4823964c46f9537c89287439aec24816b27592 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 7 Nov 2024 11:31:59 -0500 Subject: [PATCH] bgpd: In bgp_withdraw attempt to avoid a if statement on every pass We have this: if ( (safi == SAFI_UNICAST) && ...) do stuff if ( (safi == SAFI_MPLS_VPN) && ... ) do stuff this leads to having to test safi multiple times if safi is SAFI_UNICAST. Let's make it a else if as that we know that the safi is going to not change. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5b9b9e3db6..6dc2e449ab 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -5570,12 +5570,8 @@ void bgp_withdraw(struct peer *peer, const struct prefix *p, && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF || bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { vpn_leak_from_vrf_withdraw(bgp_get_default(), bgp, pi); - } - if ((SAFI_MPLS_VPN == safi) - && (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) { - + } else if ((SAFI_MPLS_VPN == safi) && (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)) vpn_leak_to_vrf_withdraw(pi); - } } else if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, NULL, -- 2.39.5