]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: In bgp_withdraw attempt to avoid a if statement on every pass
authorDonald Sharp <sharpd@nvidia.com>
Thu, 7 Nov 2024 16:31:59 +0000 (11:31 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 7 Nov 2024 16:57:34 +0000 (11:57 -0500)
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 <sharpd@nvidia.com>
bgpd/bgp_route.c

index 5b9b9e3db627caa0aea155a2ef38bbdbdd2d0e96..6dc2e449ab7e5160a7972485c1ef34d25e5902f5 100644 (file)
@@ -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,