From 879e43a550d01d7e2726031a66907e2e5a8762b6 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Fri, 6 May 2022 05:52:12 -0400 Subject: [PATCH] bgpd: remove unnecessary check for evpn 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 --- bgpd/bgp_evpn.c | 25 ++++--------------------- bgpd/bgp_evpn_vty.c | 7 ------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index bfe7452fad..9337ef7fe7 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -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 */ diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 109de1efb2..0c9cd3b721 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -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. */ -- 2.39.5