]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: clear misleading mismatched check 11096/head
authoranlan_cs <vic.lan@pica8.com>
Tue, 26 Apr 2022 04:14:34 +0000 (00:14 -0400)
committeranlan_cs <vic.lan@pica8.com>
Sun, 8 May 2022 02:20:15 +0000 (22:20 -0400)
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 <vic.lan@pica8.com>
bgpd/bgp_evpn.c

index bfe7452fadb58f87b9d302d8ffc5889b049d7231..aef7cecc7bd38d0fdbea11304a62a37eae7a5f47 100644 (file)
@@ -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);