From 17151ae94bd9ddc2eab6a9b1c5fcfea3e53defe3 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Tue, 26 Apr 2022 00:14:34 -0400 Subject: [PATCH] bgpd: clear misleading mismatched check Two changes for `delete_global_type2_routes()`: 1) Remove check of `bgp_dest_has_bgp_path_info_data(rddest)`. It is unnecessary(`dest->info` should not be NULL) and misleading. `if (rddest && bgp_dest_has_bgp_path_info_data(rddest))` Use (locked) node with this check, but unlock with `if (rddest)`, The mismatched condition is misleading, there seems to be a mistake to extra unlock. Just make it clear, immediately exit with `(!rddest)`. 2) Remove checking returned value for it, and use `void` as return type. It is unnecessary and wrong. Even the check failed, it should continue to delete other types of routes. Just remove the check and go through. Signed-off-by: anlan_cs --- bgpd/bgp_evpn.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index bfe7452fad..aef7cecc7b 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -2147,7 +2147,7 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) * Delete all type-2 (MACIP) local routes for this VNI - only from the * global routing table. These are also scheduled for withdraw from peers. */ -static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) +static void delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) { afi_t afi; safi_t safi; @@ -2160,7 +2160,7 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) rddest = bgp_node_lookup(bgp->rib[afi][safi], (struct prefix *)&vpn->prd); - if (rddest && bgp_dest_has_bgp_path_info_data(rddest)) { + if (rddest) { table = bgp_dest_get_bgp_table_info(rddest); for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) { @@ -2175,13 +2175,10 @@ static int delete_global_type2_routes(struct bgp *bgp, struct bgpevpn *vpn) if (pi) bgp_process(bgp, dest, afi, safi); } - } - /* Unlock RD node. */ - if (rddest) + /* Unlock RD node. */ bgp_dest_unlock_node(rddest); - - return 0; + } } /* @@ -3704,7 +3701,6 @@ static int update_advertise_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) */ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) { - int ret; struct prefix_evpn p; struct bgp_dest *global_dest; struct bgp_path_info *pi; @@ -3714,9 +3710,7 @@ static int delete_withdraw_vni_routes(struct bgp *bgp, struct bgpevpn *vpn) /* Delete and withdraw locally learnt type-2 routes (MACIP) * for this VNI - from the global table. */ - ret = delete_global_type2_routes(bgp, vpn); - if (ret) - return ret; + delete_global_type2_routes(bgp, vpn); /* Remove type-3 route for this VNI from global table. */ build_evpn_type3_prefix(&p, vpn->originator_ip); -- 2.39.5