]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: rfapi code does not need to assert on memory allocations
authorDonald Sharp <sharpd@nvidia.com>
Sat, 9 Jul 2022 00:53:43 +0000 (20:53 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 19 Jul 2022 17:54:10 +0000 (13:54 -0400)
cleanup memory allocations asserting that it didn't fail
as well as clean up some thread shenanigans.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/rfapi/rfapi.c
bgpd/rfapi/rfapi_ap.c
bgpd/rfapi/rfapi_encap_tlv.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_rib.c
bgpd/rfapi/vnc_export_bgp.c
bgpd/rfapi/vnc_export_table.c

index 35a76e7836e27255077bda1a98098ee0000a2506..f0e68d7f3f83aef3210f197bf1eed039c489a3d1 100644 (file)
@@ -721,7 +721,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
 
                encaptlv = XCALLOC(MTYPE_ENCAP_TLV,
                                   sizeof(struct bgp_attr_encap_subtlv) + 4);
-               assert(encaptlv);
                encaptlv->type =
                        BGP_VNC_SUBTLV_TYPE_LIFETIME; /* prefix lifetime */
                encaptlv->length = 4;
@@ -766,7 +765,6 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
                                        MTYPE_ENCAP_TLV,
                                        sizeof(struct bgp_attr_encap_subtlv) + 2
                                                + hop->length);
-                               assert(encaptlv);
                                encaptlv->type =
                                        BGP_VNC_SUBTLV_TYPE_RFPOPTION; /* RFP
                                                                          option
@@ -1041,7 +1039,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
        SET_FLAG(new->flags, BGP_PATH_VALID);
 
        /* save backref to rfapi handle */
-       assert(bgp_path_info_extra_get(new));
+       bgp_path_info_extra_get(new);
        new->extra->vnc.export.rfapi_handle = (void *)rfd;
        encode_label(label_val, &new->extra->label[0]);
 
@@ -1963,7 +1961,6 @@ int rfapi_open(void *rfp_start_val, struct rfapi_ip_addr *vn,
                rfd = XCALLOC(MTYPE_RFAPI_DESC,
                              sizeof(struct rfapi_descriptor));
        }
-       assert(rfd);
 
        rfd->bgp = bgp;
        if (default_options) {
index abb18aeb2c8ff259338f4fced8c828db076c35d4..fcc6168cfaf9834a0f1162349274eb56ee170bb5 100644 (file)
@@ -459,7 +459,6 @@ int rfapiApAdd(struct bgp *bgp, struct rfapi_descriptor *rfd,
        if (rc) {
                /* Not found */
                adb = XCALLOC(MTYPE_RFAPI_ADB, sizeof(struct rfapi_adb));
-               assert(adb);
                adb->lifetime = lifetime;
                adb->u.key = rk;
 
index a7bc909c589161dd576560dfdd9d4a9bed530073..d4e875df2ad601b6b1ee4b7407add38a0454201e 100644 (file)
@@ -170,7 +170,6 @@ struct rfapi_un_option *rfapi_encap_tlv_to_un_option(struct attr *attr)
        stlv = attr->encap_subtlvs;
 
        uo = XCALLOC(MTYPE_RFAPI_UN_OPTION, sizeof(struct rfapi_un_option));
-       assert(uo);
        uo->type = RFAPI_UN_OPTION_TYPE_TUNNELTYPE;
        uo->v.tunnel.type = attr->encap_tunneltype;
        tto = &uo->v.tunnel;
index 1d58c0331335752906fde37fb7d047367a1e061f..91b68b13d813d7d1eb8d6a393b49c9b0d6d25a92 100644 (file)
@@ -1273,7 +1273,6 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
 #endif
 
        new = XCALLOC(MTYPE_RFAPI_NEXTHOP, sizeof(struct rfapi_next_hop_entry));
-       assert(new);
 
        new->prefix = *rprefix;
 
@@ -1286,7 +1285,6 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
 
                vo = XCALLOC(MTYPE_RFAPI_VN_OPTION,
                             sizeof(struct rfapi_vn_option));
-               assert(vo);
 
                vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR;
 
@@ -2308,7 +2306,6 @@ rfapiMonitorEncapAdd(struct rfapi_import_table *import_table,
 
        m = XCALLOC(MTYPE_RFAPI_MONITOR_ENCAP,
                    sizeof(struct rfapi_monitor_encap));
-       assert(m);
 
        m->node = vpn_rn;
        m->bpi = vpn_bpi;
@@ -2791,7 +2788,6 @@ rfapiBiStartWithdrawTimer(struct rfapi_import_table *import_table,
         * service routine, which is supposed to free the wcb.
         */
        wcb = XCALLOC(MTYPE_RFAPI_WITHDRAW, sizeof(struct rfapi_withdraw));
-       assert(wcb);
        wcb->node = rn;
        wcb->info = bpi;
        wcb->import_table = import_table;
@@ -3224,7 +3220,6 @@ static void rfapiBgpInfoFilteredImportEncap(
                struct agg_table *referenced_vpn_table;
 
                referenced_vpn_table = agg_table_init();
-               assert(referenced_vpn_table);
 
 /*
  * iterate over the set of monitors at this ENCAP node.
@@ -3282,7 +3277,6 @@ static void rfapiBgpInfoFilteredImportEncap(
                                mnext = XCALLOC(
                                        MTYPE_RFAPI_MONITOR_ENCAP,
                                        sizeof(struct rfapi_monitor_encap));
-                               assert(mnext);
                                mnext->node = m->node;
                                mnext->next = referenced_vpn_prefix->info;
                                referenced_vpn_prefix->info = mnext;
@@ -4332,7 +4326,6 @@ rfapiImportTableRefAdd(struct bgp *bgp, struct ecommunity *rt_import_list,
        if (!it) {
                it = XCALLOC(MTYPE_RFAPI_IMPORTTABLE,
                             sizeof(struct rfapi_import_table));
-               assert(it);
                it->next = h->imports;
                h->imports = it;
 
@@ -4551,7 +4544,6 @@ static void rfapiDeleteRemotePrefixesIt(
                                                        MTYPE_RFAPI_NVE_ADDR,
                                                        sizeof(struct
                                                               rfapi_nve_addr));
-                                               assert(nap);
                                                *nap = na;
                                                nap->info = is_active
                                                                    ? pAHcount
index 44eebe961cb5835067050de6069d36b484981cf5..c4fc96f5ae210ce8fd0e909132cdf920828d1952 100644 (file)
@@ -357,10 +357,9 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
 
        vnc_zlog_debug_verbose("%s: rfd %p pfx %pRN life %u", __func__, rfd, rn,
                               ri->lifetime);
-       ri->timer = NULL;
+
        thread_add_timer(bm->master, rfapiRibExpireTimer, tcb, ri->lifetime,
                         &ri->timer);
-       assert(ri->timer);
 }
 
 extern void rfapi_rib_key_init(struct prefix *prefix, /* may be NULL */
@@ -1179,7 +1178,6 @@ callback:
 
                        new = XCALLOC(MTYPE_RFAPI_NEXTHOP,
                                      sizeof(struct rfapi_next_hop_entry));
-                       assert(new);
 
                        if (ri->rk.aux_prefix.family) {
                                rfapiQprefix2Rprefix(&ri->rk.aux_prefix,
@@ -1269,7 +1267,6 @@ callback:
                                new = XCALLOC(
                                        MTYPE_RFAPI_NEXTHOP,
                                        sizeof(struct rfapi_next_hop_entry));
-                               assert(new);
 
                                if (ri->rk.aux_prefix.family) {
                                        rfapiQprefix2Rprefix(&ri->rk.aux_prefix,
@@ -1718,7 +1715,6 @@ void rfapiRibUpdatePendingNode(
 
                urq = XCALLOC(MTYPE_RFAPI_UPDATED_RESPONSE_QUEUE,
                              sizeof(struct rfapi_updated_responses_queue));
-               assert(urq);
                if (!rfd->updated_responses_queue)
                        updated_responses_queue_init(rfd);
 
index 7cfa2ed67dec1282e33ed550440cec647507ff91..2152a55ca3aa7e5b8c334b88607fa516c3782d25 100644 (file)
@@ -564,7 +564,6 @@ static struct ecommunity *vnc_route_origin_ecom_single(struct in_addr *origin)
        roec.val[7] = 0;
 
        new = ecommunity_new();
-       assert(new);
        ecommunity_add_val(new, &roec, false, false);
 
        if (!new->size) {
index 255f868bdf6c12d49891988fb304bce4e7b31062..743576d2654ec8c466873c24ef5e99483cd1d7b0 100644 (file)
@@ -119,7 +119,6 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
                agg_unlock_node(etn);
        } else {
                eti = XCALLOC(MTYPE_RFAPI_ETI, sizeof(struct vnc_export_info));
-               assert(eti);
                eti->node = etn;
                eti->peer = peer;
                peer_lock(peer);