bgpd: rfapi code does not need to assert on memory allocations

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>
This commit is contained in:
Donald Sharp 2022-07-08 20:53:43 -04:00
parent 3f22218b48
commit 04fd828f3f
7 changed files with 2 additions and 21 deletions

View 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) {

View 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;

View 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;

View 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

View 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);

View 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) {

View 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);