]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: bgp_update and bgp_withdraw never return failures
authorDonald Sharp <sharpd@nvidia.com>
Mon, 30 Jan 2023 21:02:23 +0000 (16:02 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 30 Jan 2023 21:02:23 +0000 (16:02 -0500)
These two functions always return 0.  As such any and all
tests against this make no sense.  Remove the return 0
to a void and follow the chain, logically, to remove all
the dead code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_mh.c
bgpd/bgp_flowspec.c
bgpd/bgp_mac.c
bgpd/bgp_route.c
bgpd/bgp_route.h

index 155e33da91984760c8a6322c95e90b1b097fb6dd..c993707206847cdb687830006d21c157e925f8c4 100644 (file)
@@ -4429,7 +4429,7 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
        mpls_label_t label[BGP_MAX_LABELS] = {};
        uint32_t num_labels = 0;
        uint32_t eth_tag;
-       int ret;
+       int ret = 0;
 
        /* Type-2 route should be either 33, 37 or 49 bytes or an
         * additional 3 bytes if there is a second label (VNI):
@@ -4522,13 +4522,13 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
 
        /* Process the route. */
        if (attr)
-               ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
-                                afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                &prd, &label[0], num_labels, 0, &evpn);
+               bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                          safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                          &label[0], num_labels, 0, &evpn);
        else
-               ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
-                                  afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                  &prd, &label[0], num_labels, &evpn);
+               bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                            safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                            &label[0], num_labels, &evpn);
        goto done;
 
 fail:
@@ -4553,7 +4553,6 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
        struct prefix_evpn p;
        uint8_t ipaddr_len;
        uint32_t eth_tag;
-       int ret;
 
        /* Type-3 route should be either 17 or 29 bytes: RD (8), Eth Tag (4),
         * IP len (1) and IP (4 or 16).
@@ -4614,14 +4613,14 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
 
        /* Process the route. */
        if (attr)
-               ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
-                                afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                &prd, NULL, 0, 0, NULL);
+               bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                          safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
+                          0, 0, NULL);
        else
-               ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
-                                  afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                  &prd, NULL, 0, NULL);
-       return ret;
+               bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                            safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                            NULL, 0, NULL);
+       return 0;
 }
 
 /*
@@ -4637,7 +4636,6 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
        uint8_t ippfx_len;
        uint32_t eth_tag;
        mpls_label_t label; /* holds the VNI as in the packet */
-       int ret;
        bool is_valid_update = true;
 
        /* Type-5 route should be 34 or 58 bytes:
@@ -4749,9 +4747,9 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
 
        /* Process the route. */
        if (attr && is_valid_update)
-               ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
-                                afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                &prd, &label, 1, 0, &evpn);
+               bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                          safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                          &label, 1, 0, &evpn);
        else {
                if (!is_valid_update) {
                        char attr_str[BUFSIZ] = {0};
@@ -4762,12 +4760,12 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
                                peer->hostname, peer->bgp->vrf_id, &p,
                                attr_str);
                }
-               ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
-                                  afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                  &prd, &label, 1, &evpn);
+               bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                            safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                            &label, 1, &evpn);
        }
 
-       return ret;
+       return 0;
 }
 
 static void evpn_mpattr_encode_type5(struct stream *s, const struct prefix *p,
index 7b1c7cf471ad9f47f732fea26957fb66cffd55db..7ad08166311aeb69df7ffde625dee0c619261be7 100644 (file)
@@ -706,7 +706,6 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
                struct attr *attr, uint8_t *pfx, int psize,
                uint32_t addpath_id)
 {
-       int ret;
        esi_t esi;
        uint8_t ipaddr_len;
        struct in_addr vtep_ip;
@@ -750,15 +749,15 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
        build_evpn_type4_prefix(&p, &esi, vtep_ip);
        /* Process the route. */
        if (attr) {
-               ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
-                               afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                               &prd, NULL, 0, 0, NULL);
+               bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                          safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
+                          0, 0, NULL);
        } else {
-               ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
-                               afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                               &prd, NULL, 0, NULL);
+               bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                            safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                            NULL, 0, NULL);
        }
-       return ret;
+       return 0;
 }
 
 /* Check if a prefix belongs to the local ES */
@@ -1180,7 +1179,6 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
                struct attr *attr, uint8_t *pfx, int psize,
                uint32_t addpath_id)
 {
-       int ret;
        struct prefix_rd prd;
        esi_t esi;
        uint32_t eth_tag;
@@ -1219,15 +1217,15 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
        build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip);
        /* Process the route. */
        if (attr) {
-               ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
-                               afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                               &prd, NULL, 0, 0, NULL);
+               bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                          safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
+                          0, 0, NULL);
        } else {
-               ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
-                               afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                               &prd, NULL, 0, NULL);
+               bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
+                            safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
+                            NULL, 0, NULL);
        }
-       return ret;
+       return 0;
 }
 
 void bgp_evpn_mh_config_ead_export_rt(struct bgp *bgp,
index 39c0cfe5147ba528e40c4f9c78f092fc0a0a89ba..b07625c49e2395e17ceb32f34554eede598406ca 100644 (file)
@@ -103,7 +103,6 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
        safi_t safi;
        int psize = 0;
        struct prefix p;
-       int ret;
        void *temp;
 
        /* Start processing the NLRI - there may be multiple in the MP_REACH */
@@ -190,21 +189,13 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                }
                /* Process the route. */
                if (!withdraw)
-                       ret = bgp_update(peer, &p, 0, attr,
-                                        afi, safi,
-                                        ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                        NULL, NULL, 0, 0, NULL);
+                       bgp_update(peer, &p, 0, attr, afi, safi,
+                                  ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
+                                  NULL, 0, 0, NULL);
                else
-                       ret = bgp_withdraw(peer, &p, 0, attr,
-                                          afi, safi,
-                                          ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                          NULL, NULL, 0, NULL);
-               if (ret) {
-                       flog_err(EC_BGP_FLOWSPEC_INSTALLATION,
-                                "Flowspec NLRI failed to be %s.",
-                                attr ? "added" : "withdrawn");
-                       return BGP_NLRI_PARSE_ERROR;
-               }
+                       bgp_withdraw(peer, &p, 0, attr, afi, safi,
+                                    ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
+                                    NULL, 0, NULL);
        }
        return BGP_NLRI_PARSE_OK;
 }
index b9649ac4da0e643b05b39289286a7aac7ca07362..52ffb103341ded9c6cd7c6354383e4a61c607574 100644 (file)
@@ -211,16 +211,10 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
 
                        memcpy(&evpn, bgp_attr_get_evpn_overlay(pi->attr),
                               sizeof(evpn));
-                       int32_t ret = bgp_update(peer, p,
-                                                pi->addpath_rx_id,
-                                                pi->attr, AFI_L2VPN, SAFI_EVPN,
-                                                ZEBRA_ROUTE_BGP,
-                                                BGP_ROUTE_NORMAL, &prd,
-                                                label_pnt, num_labels,
-                                                1, evpn);
-
-                       if (ret < 0)
-                               bgp_dest_unlock_node(dest);
+                       bgp_update(peer, p, pi->addpath_rx_id, pi->attr,
+                                  AFI_L2VPN, SAFI_EVPN, ZEBRA_ROUTE_BGP,
+                                  BGP_ROUTE_NORMAL, &prd, label_pnt,
+                                  num_labels, 1, evpn);
                }
        }
 }
index 3f07e53bb68684b928e873c0e1d6d8c3a60cd119..3efc92aaac696cc2c170ac32967dcca419c7961e 100644 (file)
@@ -3957,11 +3957,11 @@ static bool bgp_accept_own(struct peer *peer, afi_t afi, safi_t safi,
        return false;
 }
 
-int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
-              struct attr *attr, afi_t afi, safi_t safi, int type,
-              int sub_type, struct prefix_rd *prd, mpls_label_t *label,
-              uint32_t num_labels, int soft_reconfig,
-              struct bgp_route_evpn *evpn)
+void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
+               struct attr *attr, afi_t afi, safi_t safi, int type,
+               int sub_type, struct prefix_rd *prd, mpls_label_t *label,
+               uint32_t num_labels, int soft_reconfig,
+               struct bgp_route_evpn *evpn)
 {
        int ret;
        int aspath_loop_count = 0;
@@ -4337,7 +4337,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                        bgp_dest_unlock_node(dest);
                        bgp_attr_unintern(&attr_new);
 
-                       return 0;
+                       return;
                }
 
                /* Withdraw/Announce before we fully processed the withdraw */
@@ -4551,7 +4551,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                        ret = bgp_damp_update(pi, dest, afi, safi);
                        if (ret == BGP_DAMP_SUPPRESSED) {
                                bgp_dest_unlock_node(dest);
-                               return 0;
+                               return;
                        }
                }
 
@@ -4671,7 +4671,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                        bgp_unlink_nexthop(pi);
                        bgp_path_info_delete(dest, pi);
                }
-               return 0;
+               return;
        } // End of implicit withdraw
 
        /* Received Logging. */
@@ -4834,7 +4834,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                bgp_path_info_delete(dest, new);
        }
 
-       return 0;
+       return;
 
 /* This BGP update is filtered.  Log the reason then update BGP
    entry.  */
@@ -4897,13 +4897,14 @@ filtered:
        }
 #endif
 
-       return 0;
+       return;
 }
 
-int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
-                struct attr *attr, afi_t afi, safi_t safi, int type,
-                int sub_type, struct prefix_rd *prd, mpls_label_t *label,
-                uint32_t num_labels, struct bgp_route_evpn *evpn)
+void bgp_withdraw(struct peer *peer, const struct prefix *p,
+                 uint32_t addpath_id, struct attr *attr, afi_t afi,
+                 safi_t safi, int type, int sub_type, struct prefix_rd *prd,
+                 mpls_label_t *label, uint32_t num_labels,
+                 struct bgp_route_evpn *evpn)
 {
        struct bgp *bgp;
        char pfx_buf[BGP_PRD_PATH_STRLEN];
@@ -4948,7 +4949,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
                                        peer->host, pfx_buf);
                        }
                        bgp_dest_unlock_node(dest);
-                       return 0;
+                       return;
                }
 
        /* Lookup withdrawn route. */
@@ -4990,7 +4991,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
        /* Unlock bgp_node_get() lock. */
        bgp_dest_unlock_node(dest);
 
-       return 0;
+       return;
 }
 
 void bgp_default_originate(struct peer *peer, afi_t afi, safi_t safi,
@@ -5122,10 +5123,10 @@ static void bgp_soft_reconfig_table_flag(struct bgp_table *table, bool flag)
        }
 }
 
-static int bgp_soft_reconfig_table_update(struct peer *peer,
-                                         struct bgp_dest *dest,
-                                         struct bgp_adj_in *ain, afi_t afi,
-                                         safi_t safi, struct prefix_rd *prd)
+static void bgp_soft_reconfig_table_update(struct peer *peer,
+                                          struct bgp_dest *dest,
+                                          struct bgp_adj_in *ain, afi_t afi,
+                                          safi_t safi, struct prefix_rd *prd)
 {
        struct bgp_path_info *pi;
        uint32_t num_labels = 0;
@@ -5146,17 +5147,15 @@ static int bgp_soft_reconfig_table_update(struct peer *peer,
        else
                memset(&evpn, 0, sizeof(evpn));
 
-       return bgp_update(peer, bgp_dest_get_prefix(dest), ain->addpath_rx_id,
-                         ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
-                         BGP_ROUTE_NORMAL, prd, label_pnt, num_labels, 1,
-                         &evpn);
+       bgp_update(peer, bgp_dest_get_prefix(dest), ain->addpath_rx_id,
+                  ain->attr, afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd,
+                  label_pnt, num_labels, 1, &evpn);
 }
 
 static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
                                    struct bgp_table *table,
                                    struct prefix_rd *prd)
 {
-       int ret;
        struct bgp_dest *dest;
        struct bgp_adj_in *ain;
 
@@ -5168,13 +5167,8 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
                        if (ain->peer != peer)
                                continue;
 
-                       ret = bgp_soft_reconfig_table_update(peer, dest, ain,
-                                                            afi, safi, prd);
-
-                       if (ret < 0) {
-                               bgp_dest_unlock_node(dest);
-                               return;
-                       }
+                       bgp_soft_reconfig_table_update(peer, dest, ain, afi,
+                                                      safi, prd);
                }
 }
 
@@ -5189,7 +5183,6 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
 static void bgp_soft_reconfig_table_task(struct thread *thread)
 {
        uint32_t iter, max_iter;
-       int ret;
        struct bgp_dest *dest;
        struct bgp_adj_in *ain;
        struct peer *peer;
@@ -5222,27 +5215,10 @@ static void bgp_soft_reconfig_table_task(struct thread *thread)
                                if (ain->peer != peer)
                                        continue;
 
-                               ret = bgp_soft_reconfig_table_update(
+                               bgp_soft_reconfig_table_update(
                                        peer, dest, ain, table->afi,
                                        table->safi, prd);
                                iter++;
-
-                               if (ret < 0) {
-                                       bgp_dest_unlock_node(dest);
-                                       listnode_delete(
-                                               table->soft_reconfig_peers,
-                                               peer);
-                                       bgp_announce_route(peer, table->afi,
-                                                          table->safi, false);
-                                       if (list_isempty(
-                                                   table->soft_reconfig_peers)) {
-                                               list_delete(
-                                                       &table->soft_reconfig_peers);
-                                               bgp_soft_reconfig_table_flag(
-                                                       table, false);
-                                               return;
-                                       }
-                               }
                        }
                }
        }
@@ -5959,7 +5935,6 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
        uint8_t *lim;
        struct prefix p;
        int psize;
-       int ret;
        afi_t afi;
        safi_t safi;
        bool addpath_capable;
@@ -6072,23 +6047,18 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
 
                /* Normal process. */
                if (attr)
-                       ret = bgp_update(peer, &p, addpath_id, attr, afi, safi,
-                                        ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                                        NULL, NULL, 0, 0, NULL);
+                       bgp_update(peer, &p, addpath_id, attr, afi, safi,
+                                  ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
+                                  NULL, 0, 0, NULL);
                else
-                       ret = bgp_withdraw(peer, &p, addpath_id, attr, afi,
-                                          safi, ZEBRA_ROUTE_BGP,
-                                          BGP_ROUTE_NORMAL, NULL, NULL, 0,
-                                          NULL);
+                       bgp_withdraw(peer, &p, addpath_id, attr, afi, safi,
+                                    ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
+                                    NULL, 0, NULL);
 
                /* Do not send BGP notification twice when maximum-prefix count
                 * overflow. */
                if (CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
                        return BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW;
-
-               /* Address family configuration mismatch. */
-               if (ret < 0)
-                       return BGP_NLRI_PARSE_ERROR_ADDRESS_FAMILY;
        }
 
        /* Packet length consistency check. */
index e16e077029563796fe8cf65b37138840a62e425a..452282926fc9fe3ef3a4242068ce3fc63dcb2f0c 100644 (file)
@@ -750,17 +750,17 @@ extern int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *,
                                 const char *, const char *, const char *);
 
 /* this is primarily for MPLS-VPN */
-extern int bgp_update(struct peer *peer, const struct prefix *p,
-                     uint32_t addpath_id, struct attr *attr,
-                     afi_t afi, safi_t safi, int type, int sub_type,
-                     struct prefix_rd *prd, mpls_label_t *label,
-                     uint32_t num_labels, int soft_reconfig,
-                     struct bgp_route_evpn *evpn);
-extern int bgp_withdraw(struct peer *peer, const struct prefix *p,
-                       uint32_t addpath_id, struct attr *attr, afi_t afi,
-                       safi_t safi, int type, int sub_type,
-                       struct prefix_rd *prd, mpls_label_t *label,
-                       uint32_t num_labels, struct bgp_route_evpn *evpn);
+extern void bgp_update(struct peer *peer, const struct prefix *p,
+                      uint32_t addpath_id, struct attr *attr, afi_t afi,
+                      safi_t safi, int type, int sub_type,
+                      struct prefix_rd *prd, mpls_label_t *label,
+                      uint32_t num_labels, int soft_reconfig,
+                      struct bgp_route_evpn *evpn);
+extern void bgp_withdraw(struct peer *peer, const struct prefix *p,
+                        uint32_t addpath_id, struct attr *attr, afi_t afi,
+                        safi_t safi, int type, int sub_type,
+                        struct prefix_rd *prd, mpls_label_t *label,
+                        uint32_t num_labels, struct bgp_route_evpn *evpn);
 
 /* for bgp_nexthop and bgp_damp */
 extern void bgp_process(struct bgp *, struct bgp_dest *, afi_t, safi_t);