]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: remove unnecessary check for evpn 11162/head
authoranlan_cs <vic.lan@pica8.com>
Fri, 6 May 2022 09:52:12 +0000 (05:52 -0400)
committeranlan_cs <vic.lan@pica8.com>
Sun, 8 May 2022 13:25:12 +0000 (09:25 -0400)
When `bgp_evpn_new()` is called, the `bgp` parameter MUST be non-NULL,
remove this unnecessary check and remove the NULL check for returned
`struct bgpevpn *`, which should be non-NULL.

And modify `import_rt_new()` in the same way.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
bgpd/bgp_evpn.c
bgpd/bgp_evpn_vty.c

index bfe7452fadb58f87b9d302d8ffc5889b049d7231..9337ef7fe7895bba6d20ed6506b9676a5ed62aad 100644 (file)
@@ -260,9 +260,6 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
 {
        struct irt_node *irt;
 
-       if (!bgp)
-               return NULL;
-
        irt = XCALLOC(MTYPE_BGP_EVPN_IMPORT_RT, sizeof(struct irt_node));
 
        irt->rt = *rt;
@@ -436,10 +433,8 @@ static void map_vni_to_rt(struct bgp *bgp, struct bgpevpn *vpn,
                        /* Already mapped. */
                        return;
 
-       if (!irt) {
+       if (!irt)
                irt = import_rt_new(bgp, &eval_tmp);
-               assert(irt);
-       }
 
        /* Add VNI to the hash list for this RT. */
        listnode_add(irt->vnis, vpn);
@@ -5302,9 +5297,6 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
 {
        struct bgpevpn *vpn;
 
-       if (!bgp)
-               return NULL;
-
        vpn = XCALLOC(MTYPE_BGP_EVPN, sizeof(struct bgpevpn));
 
        /* Set values - RD and RT set to defaults. */
@@ -5882,19 +5874,10 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni,
                 */
                if (is_vni_live(vpn))
                        update_routes_for_vni(bgp, vpn);
-       }
-
-       /* Create or update as appropriate. */
-       if (!vpn) {
+       } else {
+               /* Create or update as appropriate. */
                vpn = bgp_evpn_new(bgp, vni, originator_ip, tenant_vrf_id,
-                               mcast_grp, svi_ifindex);
-               if (!vpn) {
-                       flog_err(
-                               EC_BGP_VNI,
-                               "%u: Failed to allocate VNI entry for VNI %u - at Add",
-                               bgp->vrf_id, vni);
-                       return -1;
-               }
+                                  mcast_grp, svi_ifindex);
        }
 
        /* if the VNI is live already, there is nothing more to do */
index 109de1efb29c3b07bf25ef318b4a6195b4103798..0c9cd3b7218de1e4e4e0025ca7868b82dd476a2d 100644 (file)
@@ -2279,13 +2279,6 @@ static struct bgpevpn *evpn_create_update_vni(struct bgp *bgp, vni_t vni)
                 * zebra
                 */
                vpn = bgp_evpn_new(bgp, vni, bgp->router_id, 0, mcast_grp, 0);
-               if (!vpn) {
-                       flog_err(
-                               EC_BGP_VNI,
-                               "%u: Failed to allocate VNI entry for VNI %u - at Config",
-                               bgp->vrf_id, vni);
-                       return NULL;
-               }
        }
 
        /* Mark as configured. */