mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-06 23:40:35 +00:00
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
This commit is contained in:
commit
d3b05897ed
@ -1414,12 +1414,7 @@ static babel_interface_nfo *
|
||||
babel_interface_allocate (void)
|
||||
{
|
||||
babel_interface_nfo *babel_ifp;
|
||||
babel_ifp = XMALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo));
|
||||
if(babel_ifp == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Here are set the default values for an interface. */
|
||||
memset(babel_ifp, 0, sizeof(babel_interface_nfo));
|
||||
babel_ifp = XCALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo));
|
||||
/* All flags are unset */
|
||||
babel_ifp->bucket_time = babel_now.tv_sec;
|
||||
babel_ifp->bucket = BUCKET_TOKENS_MAX;
|
||||
|
||||
@ -551,8 +551,6 @@ static struct bfd_session *bfd_session_new(void)
|
||||
struct bfd_session *bs;
|
||||
|
||||
bs = XCALLOC(MTYPE_BFDD_CONFIG, sizeof(*bs));
|
||||
if (bs == NULL)
|
||||
return NULL;
|
||||
|
||||
QOBJ_REG(bs, bfd_session);
|
||||
|
||||
|
||||
@ -544,7 +544,7 @@ int bfd_recv_cb(struct thread *t)
|
||||
}
|
||||
|
||||
/* Validate packet TTL. */
|
||||
if ((is_mhop == false) && (ttl != BFD_TTL_VAL)) {
|
||||
if ((!is_mhop) && (ttl != BFD_TTL_VAL)) {
|
||||
cp_debug(is_mhop, &peer, &local, ifindex, vrfid,
|
||||
"invalid TTL: %d expected %d", ttl, BFD_TTL_VAL);
|
||||
return 0;
|
||||
|
||||
@ -564,7 +564,7 @@ static void _display_all_peers(struct vty *vty, bool use_json)
|
||||
{
|
||||
struct json_object *jo;
|
||||
|
||||
if (use_json == false) {
|
||||
if (!use_json) {
|
||||
vty_out(vty, "BFD Peers:\n");
|
||||
bfd_id_iterate(_display_peer_iter, vty);
|
||||
return;
|
||||
@ -647,7 +647,7 @@ static void _display_peers_counter(struct vty *vty, bool use_json)
|
||||
{
|
||||
struct json_object *jo;
|
||||
|
||||
if (use_json == false) {
|
||||
if (!use_json) {
|
||||
vty_out(vty, "BFD Peers:\n");
|
||||
bfd_id_iterate(_display_peer_counter_iter, vty);
|
||||
return;
|
||||
|
||||
@ -574,8 +574,6 @@ struct peer_label *pl_new(const char *label, struct bfd_session *bs)
|
||||
struct peer_label *pl;
|
||||
|
||||
pl = XCALLOC(MTYPE_BFDD_LABEL, sizeof(*pl));
|
||||
if (pl == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strlcpy(pl->pl_label, label, sizeof(pl->pl_label))
|
||||
> sizeof(pl->pl_label))
|
||||
|
||||
@ -186,8 +186,6 @@ struct bfd_control_socket *control_new(int sd)
|
||||
struct bfd_control_socket *bcs;
|
||||
|
||||
bcs = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*bcs));
|
||||
if (bcs == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Disable notifications by default. */
|
||||
bcs->bcs_notify = 0;
|
||||
@ -247,10 +245,6 @@ struct bfd_notify_peer *control_notifypeer_new(struct bfd_control_socket *bcs,
|
||||
return bnp;
|
||||
|
||||
bnp = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*bnp));
|
||||
if (bnp == NULL) {
|
||||
log_warning("%s: calloc: %s", __func__, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_INSERT_TAIL(&bcs->bcs_bnplist, bnp, bnp_entry);
|
||||
bnp->bnp_bs = bs;
|
||||
@ -285,10 +279,6 @@ struct bfd_control_queue *control_queue_new(struct bfd_control_socket *bcs)
|
||||
struct bfd_control_queue *bcq;
|
||||
|
||||
bcq = XCALLOC(MTYPE_BFDD_NOTIFICATION, sizeof(*bcq));
|
||||
if (bcq == NULL) {
|
||||
log_warning("%s: calloc: %s", __func__, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
control_reset_buf(&bcq->bcq_bcb);
|
||||
TAILQ_INSERT_TAIL(&bcs->bcs_bcqueue, bcq, bcq_entry);
|
||||
@ -743,11 +733,6 @@ static void control_response(struct bfd_control_socket *bcs, uint16_t id,
|
||||
jsonstrlen = strlen(jsonstr);
|
||||
bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
|
||||
sizeof(struct bfd_control_msg) + jsonstrlen);
|
||||
if (bcm == NULL) {
|
||||
log_warning("%s: malloc: %s", __func__, strerror(errno));
|
||||
XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
|
||||
return;
|
||||
}
|
||||
|
||||
bcm->bcm_length = htonl(jsonstrlen);
|
||||
bcm->bcm_ver = BMV_VERSION_1;
|
||||
@ -778,11 +763,6 @@ static void _control_notify(struct bfd_control_socket *bcs,
|
||||
jsonstrlen = strlen(jsonstr);
|
||||
bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
|
||||
sizeof(struct bfd_control_msg) + jsonstrlen);
|
||||
if (bcm == NULL) {
|
||||
log_warning("%s: malloc: %s", __func__, strerror(errno));
|
||||
XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
|
||||
return;
|
||||
}
|
||||
|
||||
bcm->bcm_length = htonl(jsonstrlen);
|
||||
bcm->bcm_ver = BMV_VERSION_1;
|
||||
@ -846,11 +826,6 @@ static void _control_notify_config(struct bfd_control_socket *bcs,
|
||||
jsonstrlen = strlen(jsonstr);
|
||||
bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
|
||||
sizeof(struct bfd_control_msg) + jsonstrlen);
|
||||
if (bcm == NULL) {
|
||||
log_warning("%s: malloc: %s", __func__, strerror(errno));
|
||||
XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
|
||||
return;
|
||||
}
|
||||
|
||||
bcm->bcm_length = htonl(jsonstrlen);
|
||||
bcm->bcm_ver = BMV_VERSION_1;
|
||||
|
||||
@ -752,8 +752,6 @@ static struct ptm_client *pc_new(uint32_t pid)
|
||||
|
||||
/* Allocate the client data and save it. */
|
||||
pc = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*pc));
|
||||
if (pc == NULL)
|
||||
return NULL;
|
||||
|
||||
pc->pc_pid = pid;
|
||||
TAILQ_INSERT_HEAD(&pcqueue, pc, pc_entry);
|
||||
@ -799,8 +797,6 @@ static struct ptm_client_notification *pcn_new(struct ptm_client *pc,
|
||||
|
||||
/* Save the client notification data. */
|
||||
pcn = XCALLOC(MTYPE_BFDD_NOTIFICATION, sizeof(*pcn));
|
||||
if (pcn == NULL)
|
||||
return NULL;
|
||||
|
||||
TAILQ_INSERT_HEAD(&pc->pc_pcnqueue, pcn, pcn_entry);
|
||||
pcn->pcn_pc = pc;
|
||||
|
||||
@ -45,8 +45,8 @@
|
||||
peer. */
|
||||
struct bgp_advertise_attr *baa_new(void)
|
||||
{
|
||||
return (struct bgp_advertise_attr *)XCALLOC(
|
||||
MTYPE_BGP_ADVERTISE_ATTR, sizeof(struct bgp_advertise_attr));
|
||||
return XCALLOC(MTYPE_BGP_ADVERTISE_ATTR,
|
||||
sizeof(struct bgp_advertise_attr));
|
||||
}
|
||||
|
||||
static void baa_free(struct bgp_advertise_attr *baa)
|
||||
@ -84,8 +84,7 @@ bool baa_hash_cmp(const void *p1, const void *p2)
|
||||
information. */
|
||||
struct bgp_advertise *bgp_advertise_new(void)
|
||||
{
|
||||
return (struct bgp_advertise *)XCALLOC(MTYPE_BGP_ADVERTISE,
|
||||
sizeof(struct bgp_advertise));
|
||||
return XCALLOC(MTYPE_BGP_ADVERTISE, sizeof(struct bgp_advertise));
|
||||
}
|
||||
|
||||
void bgp_advertise_free(struct bgp_advertise *adv)
|
||||
@ -255,8 +254,7 @@ void bgp_sync_delete(struct peer *peer)
|
||||
safi_t safi;
|
||||
|
||||
FOREACH_AFI_SAFI (afi, safi) {
|
||||
if (peer->sync[afi][safi])
|
||||
XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
|
||||
XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
|
||||
peer->sync[afi][safi] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,8 +312,7 @@ void aspath_free(struct aspath *aspath)
|
||||
return;
|
||||
if (aspath->segments)
|
||||
assegment_free_all(aspath->segments);
|
||||
if (aspath->str)
|
||||
XFREE(MTYPE_AS_STR, aspath->str);
|
||||
XFREE(MTYPE_AS_STR, aspath->str);
|
||||
|
||||
if (aspath->json) {
|
||||
json_object_free(aspath->json);
|
||||
@ -623,8 +622,7 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)
|
||||
|
||||
void aspath_str_update(struct aspath *as, bool make_json)
|
||||
{
|
||||
if (as->str)
|
||||
XFREE(MTYPE_AS_STR, as->str);
|
||||
XFREE(MTYPE_AS_STR, as->str);
|
||||
|
||||
if (as->json) {
|
||||
json_object_free(as->json);
|
||||
|
||||
@ -159,8 +159,7 @@ static bool cluster_hash_cmp(const void *p1, const void *p2)
|
||||
|
||||
static void cluster_free(struct cluster_list *cluster)
|
||||
{
|
||||
if (cluster->list)
|
||||
XFREE(MTYPE_CLUSTER_VAL, cluster->list);
|
||||
XFREE(MTYPE_CLUSTER_VAL, cluster->list);
|
||||
XFREE(MTYPE_CLUSTER, cluster);
|
||||
}
|
||||
|
||||
@ -401,8 +400,7 @@ static struct hash *transit_hash;
|
||||
|
||||
static void transit_free(struct transit *transit)
|
||||
{
|
||||
if (transit->val)
|
||||
XFREE(MTYPE_TRANSIT_VAL, transit->val);
|
||||
XFREE(MTYPE_TRANSIT_VAL, transit->val);
|
||||
XFREE(MTYPE_TRANSIT, transit);
|
||||
}
|
||||
|
||||
|
||||
@ -84,8 +84,8 @@ char *esi2str(struct eth_segment_id *id)
|
||||
return NULL;
|
||||
|
||||
val = id->val;
|
||||
ptr = (char *)XMALLOC(MTYPE_TMP,
|
||||
(ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char));
|
||||
ptr = XMALLOC(MTYPE_TMP,
|
||||
(ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char));
|
||||
|
||||
snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1),
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", val[0],
|
||||
|
||||
@ -100,16 +100,14 @@ static void community_entry_free(struct community_entry *entry)
|
||||
case EXTCOMMUNITY_LIST_STANDARD:
|
||||
/* In case of standard extcommunity-list, configuration string
|
||||
is made by ecommunity_ecom2str(). */
|
||||
if (entry->config)
|
||||
XFREE(MTYPE_ECOMMUNITY_STR, entry->config);
|
||||
XFREE(MTYPE_ECOMMUNITY_STR, entry->config);
|
||||
if (entry->u.ecom)
|
||||
ecommunity_free(&entry->u.ecom);
|
||||
break;
|
||||
case COMMUNITY_LIST_EXPANDED:
|
||||
case EXTCOMMUNITY_LIST_EXPANDED:
|
||||
case LARGE_COMMUNITY_LIST_EXPANDED:
|
||||
if (entry->config)
|
||||
XFREE(MTYPE_COMMUNITY_LIST_CONFIG, entry->config);
|
||||
XFREE(MTYPE_COMMUNITY_LIST_CONFIG, entry->config);
|
||||
if (entry->reg)
|
||||
bgp_regex_free(entry->reg);
|
||||
default:
|
||||
@ -127,8 +125,7 @@ static struct community_list *community_list_new(void)
|
||||
/* Free community-list. */
|
||||
static void community_list_free(struct community_list *list)
|
||||
{
|
||||
if (list->name)
|
||||
XFREE(MTYPE_COMMUNITY_LIST_NAME, list->name);
|
||||
XFREE(MTYPE_COMMUNITY_LIST_NAME, list->name);
|
||||
XFREE(MTYPE_COMMUNITY_LIST, list);
|
||||
}
|
||||
|
||||
|
||||
@ -34,17 +34,14 @@ static struct hash *comhash;
|
||||
/* Allocate a new communities value. */
|
||||
static struct community *community_new(void)
|
||||
{
|
||||
return (struct community *)XCALLOC(MTYPE_COMMUNITY,
|
||||
sizeof(struct community));
|
||||
return XCALLOC(MTYPE_COMMUNITY, sizeof(struct community));
|
||||
}
|
||||
|
||||
/* Free communities value. */
|
||||
void community_free(struct community **com)
|
||||
{
|
||||
if ((*com)->val)
|
||||
XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
|
||||
if ((*com)->str)
|
||||
XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
|
||||
XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
|
||||
XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
|
||||
|
||||
if ((*com)->json) {
|
||||
json_object_free((*com)->json);
|
||||
|
||||
@ -48,8 +48,7 @@ static struct hash *ecomhash;
|
||||
/* Allocate a new ecommunities. */
|
||||
struct ecommunity *ecommunity_new(void)
|
||||
{
|
||||
return (struct ecommunity *)XCALLOC(MTYPE_ECOMMUNITY,
|
||||
sizeof(struct ecommunity));
|
||||
return XCALLOC(MTYPE_ECOMMUNITY, sizeof(struct ecommunity));
|
||||
}
|
||||
|
||||
void ecommunity_strfree(char **s)
|
||||
@ -60,10 +59,8 @@ void ecommunity_strfree(char **s)
|
||||
/* Allocate ecommunities. */
|
||||
void ecommunity_free(struct ecommunity **ecom)
|
||||
{
|
||||
if ((*ecom)->val)
|
||||
XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val);
|
||||
if ((*ecom)->str)
|
||||
XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str);
|
||||
XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val);
|
||||
XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str);
|
||||
XFREE(MTYPE_ECOMMUNITY, *ecom);
|
||||
}
|
||||
|
||||
|
||||
@ -401,8 +401,7 @@ void bgp_encap_type_vxlan_to_tlv(
|
||||
|
||||
if (bet == NULL || !bet->vnid)
|
||||
return;
|
||||
if (attr->encap_subtlvs)
|
||||
XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
|
||||
XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
|
||||
tlv = XCALLOC(MTYPE_ENCAP_TLV,
|
||||
sizeof(struct bgp_attr_encap_subtlv) + 12);
|
||||
tlv->type = 1; /* encapsulation type */
|
||||
|
||||
@ -184,8 +184,6 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt)
|
||||
|
||||
irt = XCALLOC(MTYPE_BGP_EVPN_VRF_IMPORT_RT,
|
||||
sizeof(struct vrf_irt_node));
|
||||
if (!irt)
|
||||
return NULL;
|
||||
|
||||
irt->rt = *rt;
|
||||
irt->vrfs = list_new();
|
||||
@ -296,8 +294,6 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
|
||||
return NULL;
|
||||
|
||||
irt = XCALLOC(MTYPE_BGP_EVPN_IMPORT_RT, sizeof(struct irt_node));
|
||||
if (!irt)
|
||||
return NULL;
|
||||
|
||||
irt->rt = *rt;
|
||||
irt->vnis = list_new();
|
||||
@ -968,8 +964,6 @@ static struct in_addr *es_vtep_new(struct in_addr vtep)
|
||||
struct in_addr *ip;
|
||||
|
||||
ip = XCALLOC(MTYPE_BGP_EVPN_ES_VTEP, sizeof(struct in_addr));
|
||||
if (!ip)
|
||||
return NULL;
|
||||
|
||||
ip->s_addr = vtep.s_addr;
|
||||
return ip;
|
||||
@ -5100,8 +5094,6 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
|
||||
return NULL;
|
||||
|
||||
vpn = XCALLOC(MTYPE_BGP_EVPN, sizeof(struct bgpevpn));
|
||||
if (!vpn)
|
||||
return NULL;
|
||||
|
||||
/* Set values - RD and RT set to defaults. */
|
||||
vpn->vni = vni;
|
||||
@ -5181,8 +5173,6 @@ struct evpnes *bgp_evpn_es_new(struct bgp *bgp,
|
||||
return NULL;
|
||||
|
||||
es = XCALLOC(MTYPE_BGP_EVPN_ES, sizeof(struct evpnes));
|
||||
if (!es)
|
||||
return NULL;
|
||||
|
||||
/* set the ESI and originator_ip */
|
||||
memcpy(&es->esi, esi, sizeof(esi_t));
|
||||
|
||||
@ -95,8 +95,7 @@ static void as_filter_free(struct as_filter *asfilter)
|
||||
{
|
||||
if (asfilter->reg)
|
||||
bgp_regex_free(asfilter->reg);
|
||||
if (asfilter->reg_str)
|
||||
XFREE(MTYPE_AS_FILTER_STR, asfilter->reg_str);
|
||||
XFREE(MTYPE_AS_FILTER_STR, asfilter->reg_str);
|
||||
XFREE(MTYPE_AS_FILTER, asfilter);
|
||||
}
|
||||
|
||||
@ -338,8 +337,7 @@ static void as_list_filter_delete(struct as_list *aslist,
|
||||
/* Run hook function. */
|
||||
if (as_list_master.delete_hook)
|
||||
(*as_list_master.delete_hook)(name);
|
||||
if (name)
|
||||
XFREE(MTYPE_AS_STR, name);
|
||||
XFREE(MTYPE_AS_STR, name);
|
||||
}
|
||||
|
||||
static int as_filter_match(struct as_filter *asfilter, struct aspath *aspath)
|
||||
|
||||
@ -180,14 +180,12 @@ static void lp_cbq_item_free(struct work_queue *wq, void *data)
|
||||
|
||||
static void lp_lcb_free(void *goner)
|
||||
{
|
||||
if (goner)
|
||||
XFREE(MTYPE_BGP_LABEL_CB, goner);
|
||||
XFREE(MTYPE_BGP_LABEL_CB, goner);
|
||||
}
|
||||
|
||||
static void lp_chunk_free(void *goner)
|
||||
{
|
||||
if (goner)
|
||||
XFREE(MTYPE_BGP_LABEL_CHUNK, goner);
|
||||
XFREE(MTYPE_BGP_LABEL_CHUNK, goner);
|
||||
}
|
||||
|
||||
void bgp_lp_init(struct thread_master *master, struct labelpool *pool)
|
||||
|
||||
@ -38,17 +38,14 @@ static struct hash *lcomhash;
|
||||
/* Allocate a new lcommunities. */
|
||||
static struct lcommunity *lcommunity_new(void)
|
||||
{
|
||||
return (struct lcommunity *)XCALLOC(MTYPE_LCOMMUNITY,
|
||||
sizeof(struct lcommunity));
|
||||
return XCALLOC(MTYPE_LCOMMUNITY, sizeof(struct lcommunity));
|
||||
}
|
||||
|
||||
/* Allocate lcommunities. */
|
||||
void lcommunity_free(struct lcommunity **lcom)
|
||||
{
|
||||
if ((*lcom)->val)
|
||||
XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val);
|
||||
if ((*lcom)->str)
|
||||
XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str);
|
||||
XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val);
|
||||
XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str);
|
||||
XFREE(MTYPE_LCOMMUNITY, *lcom);
|
||||
}
|
||||
|
||||
@ -180,7 +177,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
bool first = 1;
|
||||
bool first = true;
|
||||
char *str_buf;
|
||||
char *str_pnt;
|
||||
uint8_t *pnt;
|
||||
@ -218,7 +215,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
|
||||
|
||||
for (i = 0; i < lcom->size; i++) {
|
||||
if (first)
|
||||
first = 0;
|
||||
first = false;
|
||||
else
|
||||
*str_pnt++ = ' ';
|
||||
|
||||
@ -319,10 +316,10 @@ bool lcommunity_cmp(const void *arg1, const void *arg2)
|
||||
const struct lcommunity *lcom2 = arg2;
|
||||
|
||||
if (lcom1 == NULL && lcom2 == NULL)
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
if (lcom1 == NULL || lcom2 == NULL)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return (lcom1->size == lcom2->size
|
||||
&& memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) == 0);
|
||||
|
||||
@ -671,7 +671,7 @@ void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best)
|
||||
|
||||
bgp_path_info_mpath_count_set(dmed_best, 0);
|
||||
UNSET_FLAG(dmed_best->flags, BGP_PATH_MULTIPATH_CHG);
|
||||
assert(bgp_path_info_mpath_first(dmed_best) == 0);
|
||||
assert(bgp_path_info_mpath_first(dmed_best) == NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -333,7 +333,7 @@ static bool bgp_pbr_extract_enumerate_unary(struct bgp_pbr_match_val list[],
|
||||
unary_operator, and_valmask,
|
||||
or_valmask, list[i].value,
|
||||
type_entry);
|
||||
if (ret == false)
|
||||
if (!ret)
|
||||
return ret;
|
||||
continue;
|
||||
}
|
||||
@ -441,7 +441,7 @@ static bool bgp_pbr_extract(struct bgp_pbr_match_val list[],
|
||||
range->min_port = list[i].value;
|
||||
exact_match = true;
|
||||
}
|
||||
if (exact_match == true && i > 0)
|
||||
if (exact_match && i > 0)
|
||||
return false;
|
||||
if (list[i].compare_operator ==
|
||||
(OPERATOR_COMPARE_GREATER_THAN +
|
||||
@ -545,7 +545,7 @@ static int bgp_pbr_validate_policy_route(struct bgp_pbr_entry_main *api)
|
||||
"too complex. ignoring.");
|
||||
return 0;
|
||||
} else if (api->match_icmp_type_num > 1 &&
|
||||
enumerate_icmp == false) {
|
||||
!enumerate_icmp) {
|
||||
if (BGP_DEBUG(pbr, PBR))
|
||||
zlog_debug("BGP: match icmp code is enumerate"
|
||||
", and icmp type is not."
|
||||
|
||||
@ -155,8 +155,7 @@ int str2prefix_rd(const char *str, struct prefix_rd *prd)
|
||||
out:
|
||||
if (s)
|
||||
stream_free(s);
|
||||
if (half)
|
||||
XFREE(MTYPE_TMP, half);
|
||||
XFREE(MTYPE_TMP, half);
|
||||
return lret;
|
||||
}
|
||||
|
||||
|
||||
@ -4468,12 +4468,10 @@ static struct bgp_static *bgp_static_new(void)
|
||||
|
||||
static void bgp_static_free(struct bgp_static *bgp_static)
|
||||
{
|
||||
if (bgp_static->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
|
||||
route_map_counter_decrement(bgp_static->rmap.map);
|
||||
|
||||
if (bgp_static->eth_s_id)
|
||||
XFREE(MTYPE_ATTR, bgp_static->eth_s_id);
|
||||
XFREE(MTYPE_ATTR, bgp_static->eth_s_id);
|
||||
XFREE(MTYPE_BGP_STATIC, bgp_static);
|
||||
}
|
||||
|
||||
@ -5033,9 +5031,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
|
||||
bgp_static->backdoor = backdoor;
|
||||
|
||||
if (rmap) {
|
||||
if (bgp_static->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
route_map_counter_decrement(
|
||||
bgp_static->rmap.map);
|
||||
bgp_static->rmap.name =
|
||||
@ -5045,9 +5042,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
|
||||
route_map_counter_increment(
|
||||
bgp_static->rmap.map);
|
||||
} else {
|
||||
if (bgp_static->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
route_map_counter_decrement(
|
||||
bgp_static->rmap.map);
|
||||
bgp_static->rmap.name = NULL;
|
||||
@ -5065,9 +5061,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
|
||||
bgp_static->label_index = label_index;
|
||||
|
||||
if (rmap) {
|
||||
if (bgp_static->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
route_map_counter_decrement(
|
||||
bgp_static->rmap.map);
|
||||
bgp_static->rmap.name =
|
||||
@ -5351,9 +5346,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
|
||||
bgp_static->prd = prd;
|
||||
|
||||
if (rmap_str) {
|
||||
if (bgp_static->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME,
|
||||
bgp_static->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
|
||||
route_map_counter_decrement(bgp_static->rmap.map);
|
||||
bgp_static->rmap.name =
|
||||
XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str);
|
||||
@ -5460,15 +5453,13 @@ static int bgp_table_map_set(struct vty *vty, afi_t afi, safi_t safi,
|
||||
|
||||
rmap = &bgp->table_map[afi][safi];
|
||||
if (rmap_name) {
|
||||
if (rmap->name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
route_map_counter_decrement(rmap->map);
|
||||
rmap->name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
||||
rmap->map = route_map_lookup_by_name(rmap_name);
|
||||
route_map_counter_increment(rmap->map);
|
||||
} else {
|
||||
if (rmap->name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
route_map_counter_decrement(rmap->map);
|
||||
rmap->name = NULL;
|
||||
rmap->map = NULL;
|
||||
@ -5487,8 +5478,7 @@ static int bgp_table_map_unset(struct vty *vty, afi_t afi, safi_t safi,
|
||||
struct bgp_rmap *rmap;
|
||||
|
||||
rmap = &bgp->table_map[afi][safi];
|
||||
if (rmap->name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
route_map_counter_decrement(rmap->map);
|
||||
rmap->name = NULL;
|
||||
rmap->map = NULL;
|
||||
@ -11461,8 +11451,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
if (bdistance->access_list)
|
||||
XFREE(MTYPE_AS_LIST, bdistance->access_list);
|
||||
XFREE(MTYPE_AS_LIST, bdistance->access_list);
|
||||
bgp_distance_free(bdistance);
|
||||
|
||||
bgp_node_set_bgp_path_info(rn, NULL);
|
||||
@ -12049,10 +12038,8 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
decode_label(&bgp_static->label), esi, buf2,
|
||||
macrouter);
|
||||
|
||||
if (macrouter)
|
||||
XFREE(MTYPE_TMP, macrouter);
|
||||
if (esi)
|
||||
XFREE(MTYPE_TMP, esi);
|
||||
XFREE(MTYPE_TMP, macrouter);
|
||||
XFREE(MTYPE_TMP, esi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,8 +197,6 @@ static void *route_value_compile(const char *arg)
|
||||
}
|
||||
|
||||
rv = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_value));
|
||||
if (!rv)
|
||||
return NULL;
|
||||
|
||||
rv->action = action;
|
||||
rv->variable = var;
|
||||
@ -324,8 +322,7 @@ static void route_match_peer_free(void *rule)
|
||||
{
|
||||
struct bgp_match_peer_compiled *pc = rule;
|
||||
|
||||
if (pc->interface)
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, pc->interface);
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, pc->interface);
|
||||
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
||||
}
|
||||
@ -837,8 +834,6 @@ static void *route_match_vni_compile(const char *arg)
|
||||
char *end = NULL;
|
||||
|
||||
vni = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(vni_t));
|
||||
if (!vni)
|
||||
return NULL;
|
||||
|
||||
*vni = strtoul(arg, &end, 10);
|
||||
if (*end != '\0') {
|
||||
@ -998,9 +993,6 @@ static void *route_match_local_pref_compile(const char *arg)
|
||||
|
||||
local_pref = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
|
||||
|
||||
if (!local_pref)
|
||||
return local_pref;
|
||||
|
||||
*local_pref = tmpval;
|
||||
return local_pref;
|
||||
}
|
||||
@ -1555,8 +1547,7 @@ static void route_set_ip_nexthop_free(void *rule)
|
||||
{
|
||||
struct rmap_ip_nexthop_set *rins = rule;
|
||||
|
||||
if (rins->address)
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, rins->address);
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, rins->address);
|
||||
|
||||
XFREE(MTYPE_ROUTE_MAP_COMPILED, rins);
|
||||
}
|
||||
@ -3105,10 +3096,8 @@ static int bgp_route_match_delete(struct vty *vty, const char *command,
|
||||
break;
|
||||
}
|
||||
|
||||
if (dep_name)
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
||||
if (rmap_name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -900,11 +900,10 @@ static int bgpTrapEstablished(struct peer *peer)
|
||||
|
||||
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
||||
|
||||
smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
|
||||
bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
|
||||
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
|
||||
array_size(bgp_trap_oid), bgp_oid,
|
||||
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
||||
bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
|
||||
BGPESTABLISHED);
|
||||
bgpTrapList, array_size(bgpTrapList), BGPESTABLISHED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -920,11 +919,10 @@ static int bgpTrapBackwardTransition(struct peer *peer)
|
||||
|
||||
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
|
||||
|
||||
smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
|
||||
bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
|
||||
smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
|
||||
array_size(bgp_trap_oid), bgp_oid,
|
||||
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
|
||||
bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
|
||||
BGPBACKWARDTRANSITION);
|
||||
bgpTrapList, array_size(bgpTrapList), BGPBACKWARDTRANSITION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -110,8 +110,7 @@ static void sync_init(struct update_subgroup *subgrp)
|
||||
|
||||
static void sync_delete(struct update_subgroup *subgrp)
|
||||
{
|
||||
if (subgrp->sync)
|
||||
XFREE(MTYPE_BGP_SYNCHRONISE, subgrp->sync);
|
||||
XFREE(MTYPE_BGP_SYNCHRONISE, subgrp->sync);
|
||||
subgrp->sync = NULL;
|
||||
if (subgrp->hash)
|
||||
hash_free(subgrp->hash);
|
||||
@ -144,8 +143,7 @@ static void conf_copy(struct peer *dst, struct peer *src, afi_t afi,
|
||||
dst->v_routeadv = src->v_routeadv;
|
||||
dst->flags = src->flags;
|
||||
dst->af_flags[afi][safi] = src->af_flags[afi][safi];
|
||||
if (dst->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, dst->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, dst->host);
|
||||
|
||||
dst->host = XSTRDUP(MTYPE_BGP_PEER_HOST, src->host);
|
||||
dst->cap = src->cap;
|
||||
@ -208,27 +206,19 @@ static void conf_release(struct peer *src, afi_t afi, safi_t safi)
|
||||
|
||||
srcfilter = &src->filter[afi][safi];
|
||||
|
||||
if (src->default_rmap[afi][safi].name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, src->default_rmap[afi][safi].name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, src->default_rmap[afi][safi].name);
|
||||
|
||||
if (srcfilter->dlist[FILTER_OUT].name)
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->dlist[FILTER_OUT].name);
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->dlist[FILTER_OUT].name);
|
||||
|
||||
if (srcfilter->plist[FILTER_OUT].name)
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->plist[FILTER_OUT].name);
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->plist[FILTER_OUT].name);
|
||||
|
||||
if (srcfilter->aslist[FILTER_OUT].name)
|
||||
XFREE(MTYPE_BGP_FILTER_NAME,
|
||||
srcfilter->aslist[FILTER_OUT].name);
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->aslist[FILTER_OUT].name);
|
||||
|
||||
if (srcfilter->map[RMAP_OUT].name)
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->map[RMAP_OUT].name);
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->map[RMAP_OUT].name);
|
||||
|
||||
if (srcfilter->usmap.name)
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->usmap.name);
|
||||
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->usmap.name);
|
||||
|
||||
if (src->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, src->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, src->host);
|
||||
src->host = NULL;
|
||||
}
|
||||
|
||||
@ -440,7 +430,7 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2)
|
||||
return false;
|
||||
|
||||
if (pe1->addpath_type[afi][safi] != pe2->addpath_type[afi][safi])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if ((pe1->cap & PEER_UPDGRP_CAP_FLAGS)
|
||||
!= (pe2->cap & PEER_UPDGRP_CAP_FLAGS))
|
||||
@ -741,12 +731,10 @@ static void update_group_delete(struct update_group *updgrp)
|
||||
hash_release(updgrp->bgp->update_groups[updgrp->afid], updgrp);
|
||||
conf_release(updgrp->conf, updgrp->afi, updgrp->safi);
|
||||
|
||||
if (updgrp->conf->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, updgrp->conf->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, updgrp->conf->host);
|
||||
updgrp->conf->host = NULL;
|
||||
|
||||
if (updgrp->conf->ifname)
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, updgrp->conf->ifname);
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, updgrp->conf->ifname);
|
||||
|
||||
XFREE(MTYPE_BGP_PEER, updgrp->conf);
|
||||
XFREE(MTYPE_BGP_UPDGRP, updgrp);
|
||||
|
||||
@ -69,8 +69,7 @@ struct bpacket *bpacket_alloc(void)
|
||||
{
|
||||
struct bpacket *pkt;
|
||||
|
||||
pkt = (struct bpacket *)XCALLOC(MTYPE_BGP_PACKET,
|
||||
sizeof(struct bpacket));
|
||||
pkt = XCALLOC(MTYPE_BGP_PACKET, sizeof(struct bpacket));
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
@ -14456,8 +14456,7 @@ static int lcommunity_list_set_vty(struct vty *vty, int argc,
|
||||
|
||||
/* Free temporary community list string allocated by
|
||||
argv_concat(). */
|
||||
if (str)
|
||||
XFREE(MTYPE_TMP, str);
|
||||
XFREE(MTYPE_TMP, str);
|
||||
|
||||
if (ret < 0) {
|
||||
community_list_perror(vty, ret);
|
||||
@ -14508,8 +14507,7 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc,
|
||||
|
||||
/* Free temporary community list string allocated by
|
||||
argv_concat(). */
|
||||
if (str)
|
||||
XFREE(MTYPE_TMP, str);
|
||||
XFREE(MTYPE_TMP, str);
|
||||
|
||||
if (ret < 0) {
|
||||
community_list_perror(vty, ret);
|
||||
|
||||
@ -1586,8 +1586,7 @@ struct bgp_redist *bgp_redist_add(struct bgp *bgp, afi_t afi, uint8_t type,
|
||||
bgp->redist[afi][type] = list_new();
|
||||
|
||||
red_list = bgp->redist[afi][type];
|
||||
red = (struct bgp_redist *)XCALLOC(MTYPE_BGP_REDIST,
|
||||
sizeof(struct bgp_redist));
|
||||
red = XCALLOC(MTYPE_BGP_REDIST, sizeof(struct bgp_redist));
|
||||
red->instance = instance;
|
||||
|
||||
listnode_add(red_list, red);
|
||||
@ -1694,8 +1693,7 @@ int bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
|
||||
if (red->rmap.name && (strcmp(red->rmap.name, name) == 0))
|
||||
return 0;
|
||||
|
||||
if (red->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
|
||||
/* Decrement the count for existing routemap and
|
||||
* increment the count for new route map.
|
||||
*/
|
||||
@ -1808,8 +1806,7 @@ int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type,
|
||||
bgp_redistribute_unreg(bgp, afi, type, instance);
|
||||
|
||||
/* Unset route-map. */
|
||||
if (red->rmap.name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
|
||||
route_map_counter_decrement(red->rmap.map);
|
||||
red->rmap.name = NULL;
|
||||
red->rmap.map = NULL;
|
||||
|
||||
50
bgpd/bgpd.c
50
bgpd/bgpd.c
@ -116,7 +116,7 @@ static int bgp_check_main_socket(bool create, struct bgp *bgp)
|
||||
{
|
||||
static int bgp_server_main_created;
|
||||
|
||||
if (create == true) {
|
||||
if (create) {
|
||||
if (bgp_server_main_created)
|
||||
return 0;
|
||||
if (bgp_socket(bgp, bm->port, bm->address) < 0)
|
||||
@ -1099,8 +1099,7 @@ static void peer_free(struct peer *peer)
|
||||
peer->update_if = NULL;
|
||||
}
|
||||
|
||||
if (peer->notify.data)
|
||||
XFREE(MTYPE_TMP, peer->notify.data);
|
||||
XFREE(MTYPE_TMP, peer->notify.data);
|
||||
memset(&peer->notify, 0, sizeof(struct bgp_notify));
|
||||
|
||||
if (peer->clear_node_queue)
|
||||
@ -1322,8 +1321,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
|
||||
peer_dst->update_source =
|
||||
sockunion_dup(peer_src->update_source);
|
||||
} else if (peer_src->update_if) {
|
||||
if (peer_dst->update_if)
|
||||
XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
|
||||
XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
|
||||
if (peer_dst->update_source) {
|
||||
sockunion_free(peer_dst->update_source);
|
||||
peer_dst->update_source = NULL;
|
||||
@ -1333,8 +1331,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
|
||||
}
|
||||
|
||||
if (peer_src->ifname) {
|
||||
if (peer_dst->ifname)
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer_dst->ifname);
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer_dst->ifname);
|
||||
|
||||
peer_dst->ifname =
|
||||
XSTRDUP(MTYPE_BGP_PEER_IFNAME, peer_src->ifname);
|
||||
@ -1541,14 +1538,12 @@ struct peer *peer_create(union sockunion *su, const char *conf_if,
|
||||
peer->su = *su;
|
||||
else
|
||||
bgp_peer_conf_if_to_su_update(peer);
|
||||
if (peer->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, peer->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, peer->host);
|
||||
peer->host = XSTRDUP(MTYPE_BGP_PEER_HOST, conf_if);
|
||||
} else if (su) {
|
||||
peer->su = *su;
|
||||
sockunion2str(su, buf, SU_ADDRSTRLEN);
|
||||
if (peer->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, peer->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, peer->host);
|
||||
peer->host = XSTRDUP(MTYPE_BGP_PEER_HOST, buf);
|
||||
}
|
||||
peer->local_as = local_as;
|
||||
@ -2384,8 +2379,7 @@ static int peer_group_cmp(struct peer_group *g1, struct peer_group *g2)
|
||||
/* Peer group cofiguration. */
|
||||
static struct peer_group *peer_group_new(void)
|
||||
{
|
||||
return (struct peer_group *)XCALLOC(MTYPE_PEER_GROUP,
|
||||
sizeof(struct peer_group));
|
||||
return XCALLOC(MTYPE_PEER_GROUP, sizeof(struct peer_group));
|
||||
}
|
||||
|
||||
static void peer_group_free(struct peer_group *group)
|
||||
@ -2416,8 +2410,7 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name)
|
||||
|
||||
group = peer_group_new();
|
||||
group->bgp = bgp;
|
||||
if (group->name)
|
||||
XFREE(MTYPE_PEER_GROUP_HOST, group->name);
|
||||
XFREE(MTYPE_PEER_GROUP_HOST, group->name);
|
||||
group->name = XSTRDUP(MTYPE_PEER_GROUP_HOST, name);
|
||||
group->peer = list_new();
|
||||
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
||||
@ -2425,8 +2418,7 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name)
|
||||
group->conf = peer_new(bgp);
|
||||
if (!bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4))
|
||||
group->conf->afc[AFI_IP][SAFI_UNICAST] = 1;
|
||||
if (group->conf->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, group->conf->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, group->conf->host);
|
||||
group->conf->host = XSTRDUP(MTYPE_BGP_PEER_HOST, name);
|
||||
group->conf->group = group;
|
||||
group->conf->as = 0;
|
||||
@ -2886,8 +2878,7 @@ static struct bgp *bgp_create(as_t *as, const char *name,
|
||||
bgp->vrf_id = (inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? VRF_DEFAULT
|
||||
: VRF_UNKNOWN;
|
||||
bgp->peer_self = peer_new(bgp);
|
||||
if (bgp->peer_self->host)
|
||||
XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->host);
|
||||
XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->host);
|
||||
bgp->peer_self->host =
|
||||
XSTRDUP(MTYPE_BGP_PEER_HOST, "Static announcement");
|
||||
if (bgp->peer_self->hostname != NULL) {
|
||||
@ -3404,8 +3395,7 @@ void bgp_free(struct bgp *bgp)
|
||||
if (bgp->rib[afi][safi])
|
||||
bgp_table_finish(&bgp->rib[afi][safi]);
|
||||
rmap = &bgp->table_map[afi][safi];
|
||||
if (rmap->name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
|
||||
}
|
||||
|
||||
bgp_scan_finish(bgp);
|
||||
@ -3435,10 +3425,8 @@ void bgp_free(struct bgp *bgp)
|
||||
ecommunity_free(&bgp->vpn_policy[afi].rtlist[dir]);
|
||||
}
|
||||
|
||||
if (bgp->name)
|
||||
XFREE(MTYPE_BGP, bgp->name);
|
||||
if (bgp->name_pretty)
|
||||
XFREE(MTYPE_BGP, bgp->name_pretty);
|
||||
XFREE(MTYPE_BGP, bgp->name);
|
||||
XFREE(MTYPE_BGP, bgp->name_pretty);
|
||||
|
||||
XFREE(MTYPE_BGP, bgp);
|
||||
}
|
||||
@ -4368,8 +4356,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)
|
||||
/* Neighbor description. */
|
||||
int peer_description_set(struct peer *peer, const char *desc)
|
||||
{
|
||||
if (peer->desc)
|
||||
XFREE(MTYPE_PEER_DESC, peer->desc);
|
||||
XFREE(MTYPE_PEER_DESC, peer->desc);
|
||||
|
||||
peer->desc = XSTRDUP(MTYPE_PEER_DESC, desc);
|
||||
|
||||
@ -4378,8 +4365,7 @@ int peer_description_set(struct peer *peer, const char *desc)
|
||||
|
||||
int peer_description_unset(struct peer *peer)
|
||||
{
|
||||
if (peer->desc)
|
||||
XFREE(MTYPE_PEER_DESC, peer->desc);
|
||||
XFREE(MTYPE_PEER_DESC, peer->desc);
|
||||
|
||||
peer->desc = NULL;
|
||||
|
||||
@ -5125,15 +5111,13 @@ int peer_advertise_interval_unset(struct peer *peer)
|
||||
/* neighbor interface */
|
||||
void peer_interface_set(struct peer *peer, const char *str)
|
||||
{
|
||||
if (peer->ifname)
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
|
||||
peer->ifname = XSTRDUP(MTYPE_BGP_PEER_IFNAME, str);
|
||||
}
|
||||
|
||||
void peer_interface_unset(struct peer *peer)
|
||||
{
|
||||
if (peer->ifname)
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
|
||||
XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
|
||||
peer->ifname = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -3457,8 +3457,7 @@ static void bgp_rfapi_delete_l2_group(struct vty *vty, /* NULL = no output */
|
||||
ecommunity_free(&rfg->rt_export_list);
|
||||
if (rfg->labels)
|
||||
list_delete(&rfg->labels);
|
||||
if (rfg->rfp_cfg)
|
||||
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
|
||||
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
|
||||
listnode_delete(bgp->rfapi_cfg->l2_groups, rfg);
|
||||
|
||||
rfapi_l2_group_del(rfg);
|
||||
@ -3815,8 +3814,7 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
|
||||
struct rfapi_cfg *h;
|
||||
afi_t afi;
|
||||
|
||||
h = (struct rfapi_cfg *)XCALLOC(MTYPE_RFAPI_CFG,
|
||||
sizeof(struct rfapi_cfg));
|
||||
h = XCALLOC(MTYPE_RFAPI_CFG, sizeof(struct rfapi_cfg));
|
||||
assert(h);
|
||||
|
||||
h->nve_groups_sequential = list_new();
|
||||
@ -3878,8 +3876,7 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
|
||||
ecommunity_free(&h->default_rt_export_list);
|
||||
if (h->default_rt_import_list)
|
||||
ecommunity_free(&h->default_rt_import_list);
|
||||
if (h->default_rfp_cfg)
|
||||
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
|
||||
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
|
||||
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
||||
agg_table_finish(h->nve_groups_vn[afi]);
|
||||
agg_table_finish(h->nve_groups_un[afi]);
|
||||
|
||||
@ -4285,7 +4285,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
|
||||
|
||||
assert(bgp->rfapi_cfg == NULL);
|
||||
|
||||
h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
|
||||
h = XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
|
||||
|
||||
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
||||
h->un[afi] = agg_table_init();
|
||||
|
||||
@ -190,7 +190,7 @@ static int bgp_vnc_config_write_debug(struct vty *vty)
|
||||
int write = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) {
|
||||
for (i = 0; i < array_size(vncdebug); ++i) {
|
||||
if (conf_vnc_debug & vncdebug[i].bit) {
|
||||
vty_out(vty, "debug bgp vnc %s\n", vncdebug[i].name);
|
||||
write++;
|
||||
|
||||
@ -608,10 +608,8 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
|
||||
add);
|
||||
}
|
||||
|
||||
if (nhp_ary)
|
||||
XFREE(MTYPE_TMP, nhp_ary);
|
||||
if (nh_ary)
|
||||
XFREE(MTYPE_TMP, nh_ary);
|
||||
XFREE(MTYPE_TMP, nhp_ary);
|
||||
XFREE(MTYPE_TMP, nh_ary);
|
||||
}
|
||||
|
||||
void vnc_zebra_add_prefix(struct bgp *bgp,
|
||||
@ -789,10 +787,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nhp_ary)
|
||||
XFREE(MTYPE_TMP, nhp_ary);
|
||||
if (nh_ary)
|
||||
XFREE(MTYPE_TMP, nh_ary);
|
||||
XFREE(MTYPE_TMP, nhp_ary);
|
||||
XFREE(MTYPE_TMP, nh_ary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ static const char *fsm_state2str(enum eigrp_fsm_events event)
|
||||
return "Query from Successor while in active state";
|
||||
case EIGRP_FSM_EVENT_LR_FCN:
|
||||
return "Last Reply Event, Feasibility not satisfied";
|
||||
};
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@ -577,8 +577,6 @@ static uint16_t eigrp_next_sequence_encode(struct stream *s)
|
||||
static uint16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
|
||||
struct stream *s, uint8_t flags)
|
||||
{
|
||||
uint16_t length = EIGRP_TLV_PARAMETER_LEN;
|
||||
|
||||
// add in the parameters TLV
|
||||
stream_putw(s, EIGRP_TLV_PARAMETER);
|
||||
stream_putw(s, EIGRP_TLV_PARAMETER_LEN);
|
||||
@ -605,7 +603,7 @@ static uint16_t eigrp_hello_parameter_encode(struct eigrp_interface *ei,
|
||||
// and set hold time value..
|
||||
stream_putw(s, ei->params.v_wait);
|
||||
|
||||
return length;
|
||||
return EIGRP_TLV_PARAMETER_LEN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1499,8 +1499,6 @@ static int eigrp_config_write(struct vty *vty)
|
||||
{
|
||||
struct eigrp *eigrp;
|
||||
|
||||
int write = 0;
|
||||
|
||||
eigrp = eigrp_lookup();
|
||||
if (eigrp != NULL) {
|
||||
/* Writes 'router eigrp' section to config */
|
||||
@ -1525,7 +1523,7 @@ static int eigrp_config_write(struct vty *vty)
|
||||
// config_write_eigrp_distance (vty, eigrp)
|
||||
}
|
||||
|
||||
return write;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eigrp_vty_show_init(void)
|
||||
|
||||
@ -1095,10 +1095,10 @@ void dict_load_end(dict_load_t *load)
|
||||
baselevel = level = 1;
|
||||
complete = tree[0];
|
||||
|
||||
if (complete != 0) {
|
||||
if (complete != NULL) {
|
||||
tree[0] = 0;
|
||||
complete->right = dictnil;
|
||||
while (tree[level] != 0) {
|
||||
while (tree[level] != NULL) {
|
||||
tree[level]->right = complete;
|
||||
complete->parent = tree[level];
|
||||
complete = tree[level];
|
||||
@ -1114,7 +1114,7 @@ void dict_load_end(dict_load_t *load)
|
||||
complete = curr;
|
||||
|
||||
assert(level == baselevel);
|
||||
while (tree[level] != 0) {
|
||||
while (tree[level] != NULL) {
|
||||
tree[level]->right = complete;
|
||||
complete->parent = tree[level];
|
||||
complete = tree[level];
|
||||
@ -1134,7 +1134,7 @@ void dict_load_end(dict_load_t *load)
|
||||
complete = dictnil;
|
||||
|
||||
for (i = 0; i < DICT_DEPTH_MAX; i++) {
|
||||
if (tree[i] != 0) {
|
||||
if (tree[i] != NULL) {
|
||||
tree[i]->right = complete;
|
||||
complete->parent = tree[i];
|
||||
complete = tree[i];
|
||||
|
||||
@ -140,12 +140,9 @@ void isis_delete_adj(void *arg)
|
||||
/* remove from SPF trees */
|
||||
spftree_area_adj_del(adj->circuit->area, adj);
|
||||
|
||||
if (adj->area_addresses)
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->area_addresses);
|
||||
if (adj->ipv4_addresses)
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->ipv4_addresses);
|
||||
if (adj->ipv6_addresses)
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->ipv6_addresses);
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->area_addresses);
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->ipv4_addresses);
|
||||
XFREE(MTYPE_ISIS_ADJACENCY_INFO, adj->ipv6_addresses);
|
||||
|
||||
adj_mt_finish(adj);
|
||||
|
||||
|
||||
@ -444,7 +444,7 @@ static int open_dlpi_dev(struct isis_circuit *circuit)
|
||||
struct strioctl sioc;
|
||||
|
||||
pfil.Pf_Priority = 0;
|
||||
pfil.Pf_FilterLen = sizeof(pf_filter) / sizeof(unsigned short);
|
||||
pfil.Pf_FilterLen = array_size(pf_filter);
|
||||
memcpy(pfil.Pf_Filter, pf_filter, sizeof(pf_filter));
|
||||
/* pfmod does not support transparent ioctls */
|
||||
sioc.ic_cmd = PFIOCSETF;
|
||||
|
||||
@ -80,7 +80,7 @@ struct zebra_privs_t isisd_privs = {
|
||||
.vty_group = VTY_GROUP,
|
||||
#endif
|
||||
.caps_p = _caps_p,
|
||||
.cap_num_p = sizeof(_caps_p) / sizeof(*_caps_p),
|
||||
.cap_num_p = array_size(_caps_p),
|
||||
.cap_num_i = 0};
|
||||
|
||||
/* isisd options */
|
||||
|
||||
@ -2146,11 +2146,11 @@ int send_csnp(struct isis_circuit *circuit, int level)
|
||||
* stop lsp_id in this current CSNP.
|
||||
*/
|
||||
memcpy(start, stop, ISIS_SYS_ID_LEN + 2);
|
||||
loop = 0;
|
||||
loop = false;
|
||||
for (int i = ISIS_SYS_ID_LEN + 1; i >= 0; --i) {
|
||||
if (start[i] < (uint8_t)0xff) {
|
||||
start[i] += 1;
|
||||
loop = 1;
|
||||
loop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2164,7 +2164,6 @@ int send_csnp(struct isis_circuit *circuit, int level)
|
||||
int send_l1_csnp(struct thread *thread)
|
||||
{
|
||||
struct isis_circuit *circuit;
|
||||
int retval = ISIS_OK;
|
||||
|
||||
circuit = THREAD_ARG(thread);
|
||||
assert(circuit);
|
||||
@ -2181,13 +2180,12 @@ int send_l1_csnp(struct thread *thread)
|
||||
isis_jitter(circuit->csnp_interval[0], CSNP_JITTER),
|
||||
&circuit->t_send_csnp[0]);
|
||||
|
||||
return retval;
|
||||
return ISIS_OK;
|
||||
}
|
||||
|
||||
int send_l2_csnp(struct thread *thread)
|
||||
{
|
||||
struct isis_circuit *circuit;
|
||||
int retval = ISIS_OK;
|
||||
|
||||
circuit = THREAD_ARG(thread);
|
||||
assert(circuit);
|
||||
@ -2204,7 +2202,7 @@ int send_l2_csnp(struct thread *thread)
|
||||
isis_jitter(circuit->csnp_interval[1], CSNP_JITTER),
|
||||
&circuit->t_send_csnp[1]);
|
||||
|
||||
return retval;
|
||||
return ISIS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2329,7 +2327,6 @@ int send_l1_psnp(struct thread *thread)
|
||||
{
|
||||
|
||||
struct isis_circuit *circuit;
|
||||
int retval = ISIS_OK;
|
||||
|
||||
circuit = THREAD_ARG(thread);
|
||||
assert(circuit);
|
||||
@ -2342,7 +2339,7 @@ int send_l1_psnp(struct thread *thread)
|
||||
isis_jitter(circuit->psnp_interval[0], PSNP_JITTER),
|
||||
&circuit->t_send_psnp[0]);
|
||||
|
||||
return retval;
|
||||
return ISIS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2352,7 +2349,6 @@ int send_l1_psnp(struct thread *thread)
|
||||
int send_l2_psnp(struct thread *thread)
|
||||
{
|
||||
struct isis_circuit *circuit;
|
||||
int retval = ISIS_OK;
|
||||
|
||||
circuit = THREAD_ARG(thread);
|
||||
assert(circuit);
|
||||
@ -2366,7 +2362,7 @@ int send_l2_psnp(struct thread *thread)
|
||||
isis_jitter(circuit->psnp_interval[1], PSNP_JITTER),
|
||||
&circuit->t_send_psnp[1]);
|
||||
|
||||
return retval;
|
||||
return ISIS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -504,8 +504,7 @@ void isis_redist_area_finish(struct isis_area *area)
|
||||
redist = &area->redist_settings[protocol][type]
|
||||
[level];
|
||||
redist->redist = 0;
|
||||
if (redist->map_name)
|
||||
XFREE(MTYPE_ISIS, redist->map_name);
|
||||
XFREE(MTYPE_ISIS, redist->map_name);
|
||||
}
|
||||
route_table_finish(area->ext_reach[protocol][level]);
|
||||
}
|
||||
|
||||
@ -1913,7 +1913,7 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i,
|
||||
default:
|
||||
sbuf_push(buf, indent, " Unknown (%" PRIu8 ")\n", auth->type);
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static void free_item_auth(struct isis_item *i)
|
||||
@ -3202,8 +3202,7 @@ void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs,
|
||||
struct nlpids *nlpids)
|
||||
{
|
||||
tlvs->protocols_supported.count = nlpids->count;
|
||||
if (tlvs->protocols_supported.protocols)
|
||||
XFREE(MTYPE_ISIS_TLV, tlvs->protocols_supported.protocols);
|
||||
XFREE(MTYPE_ISIS_TLV, tlvs->protocols_supported.protocols);
|
||||
if (nlpids->count) {
|
||||
tlvs->protocols_supported.protocols =
|
||||
XCALLOC(MTYPE_ISIS_TLV, nlpids->count);
|
||||
|
||||
@ -1277,8 +1277,7 @@ int cmd_execute(struct vty *vty, const char *cmd,
|
||||
|
||||
hook_call(cmd_execute_done, vty, cmd_exec);
|
||||
|
||||
if (cmd_out)
|
||||
XFREE(MTYPE_TMP, cmd_out);
|
||||
XFREE(MTYPE_TMP, cmd_out);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2408,8 +2407,7 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel)
|
||||
|
||||
ret = zlog_set_file(fullpath, loglevel);
|
||||
|
||||
if (p)
|
||||
XFREE(MTYPE_TMP, p);
|
||||
XFREE(MTYPE_TMP, p);
|
||||
|
||||
if (!ret) {
|
||||
if (vty)
|
||||
@ -2417,8 +2415,7 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel)
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
}
|
||||
|
||||
if (host.logfile)
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
|
||||
host.logfile = XSTRDUP(MTYPE_HOST, fname);
|
||||
|
||||
@ -2487,8 +2484,7 @@ static void disable_log_file(void)
|
||||
{
|
||||
zlog_reset_file();
|
||||
|
||||
if (host.logfile)
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
|
||||
host.logfile = NULL;
|
||||
}
|
||||
@ -2637,8 +2633,7 @@ int cmd_banner_motd_file(const char *file)
|
||||
return CMD_ERR_NO_FILE;
|
||||
in = strstr(rpath, SYSCONFDIR);
|
||||
if (in == rpath) {
|
||||
if (host.motdfile)
|
||||
XFREE(MTYPE_HOST, host.motdfile);
|
||||
XFREE(MTYPE_HOST, host.motdfile);
|
||||
host.motdfile = XSTRDUP(MTYPE_HOST, file);
|
||||
} else
|
||||
success = CMD_WARNING_CONFIG_FAILED;
|
||||
@ -2723,8 +2718,7 @@ DEFUN(find,
|
||||
/* Set config filename. Called from vty.c */
|
||||
void host_config_set(const char *filename)
|
||||
{
|
||||
if (host.config)
|
||||
XFREE(MTYPE_HOST, host.config);
|
||||
XFREE(MTYPE_HOST, host.config);
|
||||
host.config = XSTRDUP(MTYPE_HOST, filename);
|
||||
}
|
||||
|
||||
@ -2904,24 +2898,15 @@ void cmd_terminate(void)
|
||||
cmdvec = NULL;
|
||||
}
|
||||
|
||||
if (host.name)
|
||||
XFREE(MTYPE_HOST, host.name);
|
||||
if (host.domainname)
|
||||
XFREE(MTYPE_HOST, host.domainname);
|
||||
if (host.password)
|
||||
XFREE(MTYPE_HOST, host.password);
|
||||
if (host.password_encrypt)
|
||||
XFREE(MTYPE_HOST, host.password_encrypt);
|
||||
if (host.enable)
|
||||
XFREE(MTYPE_HOST, host.enable);
|
||||
if (host.enable_encrypt)
|
||||
XFREE(MTYPE_HOST, host.enable_encrypt);
|
||||
if (host.logfile)
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
if (host.motdfile)
|
||||
XFREE(MTYPE_HOST, host.motdfile);
|
||||
if (host.config)
|
||||
XFREE(MTYPE_HOST, host.config);
|
||||
XFREE(MTYPE_HOST, host.name);
|
||||
XFREE(MTYPE_HOST, host.domainname);
|
||||
XFREE(MTYPE_HOST, host.password);
|
||||
XFREE(MTYPE_HOST, host.password_encrypt);
|
||||
XFREE(MTYPE_HOST, host.enable);
|
||||
XFREE(MTYPE_HOST, host.enable_encrypt);
|
||||
XFREE(MTYPE_HOST, host.logfile);
|
||||
XFREE(MTYPE_HOST, host.motdfile);
|
||||
XFREE(MTYPE_HOST, host.config);
|
||||
|
||||
list_delete(&varhandlers);
|
||||
qobj_finish();
|
||||
|
||||
@ -471,7 +471,7 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf)
|
||||
struct cmd_token *tok = gn->data;
|
||||
const char *color;
|
||||
|
||||
if (wasend == true) {
|
||||
if (wasend) {
|
||||
wasend = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -44,16 +44,15 @@ static void distribute_free(struct distribute *dist)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (dist->ifname)
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, dist->ifname);
|
||||
|
||||
for (i = 0; i < DISTRIBUTE_MAX; i++)
|
||||
if (dist->list[i])
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[i]);
|
||||
for (i = 0; i < DISTRIBUTE_MAX; i++) {
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < DISTRIBUTE_MAX; i++)
|
||||
if (dist->prefix[i])
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[i]);
|
||||
for (i = 0; i < DISTRIBUTE_MAX; i++) {
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[i]);
|
||||
}
|
||||
|
||||
XFREE(MTYPE_DISTRIBUTE, dist);
|
||||
}
|
||||
@ -83,8 +82,7 @@ struct distribute *distribute_lookup(struct distribute_ctx *ctx,
|
||||
|
||||
dist = hash_lookup(ctx->disthash, &key);
|
||||
|
||||
if (key.ifname)
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
||||
|
||||
return dist;
|
||||
}
|
||||
@ -128,8 +126,7 @@ static struct distribute *distribute_get(struct distribute_ctx *ctx,
|
||||
ret = hash_get(ctx->disthash, &key,
|
||||
(void *(*)(void *))distribute_hash_alloc);
|
||||
|
||||
if (key.ifname)
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
||||
XFREE(MTYPE_DISTRIBUTE_IFNAME, key.ifname);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -163,8 +160,7 @@ static void distribute_list_set(struct distribute_ctx *ctx,
|
||||
|
||||
dist = distribute_get(ctx, ifname);
|
||||
|
||||
if (dist->list[type])
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[type]);
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->list[type]);
|
||||
dist->list[type] = XSTRDUP(MTYPE_DISTRIBUTE_NAME, alist_name);
|
||||
|
||||
/* Apply this distribute-list to the interface. */
|
||||
@ -210,8 +206,7 @@ static void distribute_list_prefix_set(struct distribute_ctx *ctx,
|
||||
|
||||
dist = distribute_get(ctx, ifname);
|
||||
|
||||
if (dist->prefix[type])
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[type]);
|
||||
XFREE(MTYPE_DISTRIBUTE_NAME, dist->prefix[type]);
|
||||
dist->prefix[type] = XSTRDUP(MTYPE_DISTRIBUTE_NAME, plist_name);
|
||||
|
||||
/* Apply this distribute-list to the interface. */
|
||||
|
||||
12
lib/filter.c
12
lib/filter.c
@ -128,8 +128,7 @@ static struct access_master *access_master_get(afi_t afi)
|
||||
/* Allocate new filter structure. */
|
||||
static struct filter *filter_new(void)
|
||||
{
|
||||
return (struct filter *)XCALLOC(MTYPE_ACCESS_FILTER,
|
||||
sizeof(struct filter));
|
||||
return XCALLOC(MTYPE_ACCESS_FILTER, sizeof(struct filter));
|
||||
}
|
||||
|
||||
static void filter_free(struct filter *filter)
|
||||
@ -202,8 +201,7 @@ static int filter_match_zebra(struct filter *mfilter, const struct prefix *p)
|
||||
/* Allocate new access list structure. */
|
||||
static struct access_list *access_list_new(void)
|
||||
{
|
||||
return (struct access_list *)XCALLOC(MTYPE_ACCESS_LIST,
|
||||
sizeof(struct access_list));
|
||||
return XCALLOC(MTYPE_ACCESS_LIST, sizeof(struct access_list));
|
||||
}
|
||||
|
||||
/* Free allocated access_list. */
|
||||
@ -242,11 +240,9 @@ static void access_list_delete(struct access_list *access)
|
||||
else
|
||||
list->head = access->next;
|
||||
|
||||
if (access->name)
|
||||
XFREE(MTYPE_ACCESS_LIST_STR, access->name);
|
||||
XFREE(MTYPE_ACCESS_LIST_STR, access->name);
|
||||
|
||||
if (access->remark)
|
||||
XFREE(MTYPE_TMP, access->remark);
|
||||
XFREE(MTYPE_TMP, access->remark);
|
||||
|
||||
access_list_free(access);
|
||||
}
|
||||
|
||||
@ -110,8 +110,7 @@ void frr_pthread_destroy(struct frr_pthread *fpt)
|
||||
pthread_mutex_destroy(&fpt->mtx);
|
||||
pthread_mutex_destroy(fpt->running_cond_mtx);
|
||||
pthread_cond_destroy(fpt->running_cond);
|
||||
if (fpt->name)
|
||||
XFREE(MTYPE_FRR_PTHREAD, fpt->name);
|
||||
XFREE(MTYPE_FRR_PTHREAD, fpt->name);
|
||||
XFREE(MTYPE_PTHREAD_PRIM, fpt->running_cond_mtx);
|
||||
XFREE(MTYPE_PTHREAD_PRIM, fpt->running_cond);
|
||||
XFREE(MTYPE_FRR_PTHREAD, fpt);
|
||||
|
||||
@ -176,8 +176,6 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
|
||||
cb = *cbp;
|
||||
else {
|
||||
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
|
||||
if (!cb)
|
||||
return -1;
|
||||
|
||||
cb->write.cancelled = 1;
|
||||
*cbp = cb;
|
||||
@ -286,8 +284,6 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
|
||||
cb = *cbp;
|
||||
else {
|
||||
cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
|
||||
if (!cb)
|
||||
return -1;
|
||||
|
||||
cb->read.cancelled = 1;
|
||||
*cbp = cb;
|
||||
|
||||
@ -155,13 +155,13 @@ void frrstr_strvec_free(vector v)
|
||||
bool begins_with(const char *str, const char *prefix)
|
||||
{
|
||||
if (!str || !prefix)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
size_t lenstr = strlen(str);
|
||||
size_t lenprefix = strlen(prefix);
|
||||
|
||||
if (lenprefix > lenstr)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return strncmp(str, prefix, lenprefix) == 0;
|
||||
}
|
||||
|
||||
@ -95,8 +95,6 @@ static void hash_expand(struct hash *hash)
|
||||
|
||||
new_index = XCALLOC(MTYPE_HASH_INDEX,
|
||||
sizeof(struct hash_bucket *) * new_size);
|
||||
if (new_index == NULL)
|
||||
return;
|
||||
|
||||
hash->stats.empty = new_size;
|
||||
|
||||
@ -324,8 +322,7 @@ void hash_free(struct hash *hash)
|
||||
}
|
||||
pthread_mutex_unlock(&_hashes_mtx);
|
||||
|
||||
if (hash->name)
|
||||
XFREE(MTYPE_HASH, hash->name);
|
||||
XFREE(MTYPE_HASH, hash->name);
|
||||
|
||||
XFREE(MTYPE_HASH_INDEX, hash->index);
|
||||
XFREE(MTYPE_HASH, hash);
|
||||
|
||||
12
lib/if.c
12
lib/if.c
@ -234,8 +234,7 @@ void if_delete(struct interface *ifp)
|
||||
|
||||
if_link_params_free(ifp);
|
||||
|
||||
if (ifp->desc)
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
|
||||
XFREE(MTYPE_IF, ifp);
|
||||
}
|
||||
@ -708,8 +707,7 @@ void connected_free(struct connected *connected)
|
||||
if (connected->destination)
|
||||
prefix_free(connected->destination);
|
||||
|
||||
if (connected->label)
|
||||
XFREE(MTYPE_CONNECTED_LABEL, connected->label);
|
||||
XFREE(MTYPE_CONNECTED_LABEL, connected->label);
|
||||
|
||||
XFREE(MTYPE_CONNECTED, connected);
|
||||
}
|
||||
@ -1349,8 +1347,7 @@ static int lib_interface_description_modify(enum nb_event event,
|
||||
return NB_OK;
|
||||
|
||||
ifp = yang_dnode_get_entry(dnode, true);
|
||||
if (ifp->desc)
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
description = yang_dnode_get_string(dnode, NULL);
|
||||
ifp->desc = XSTRDUP(MTYPE_TMP, description);
|
||||
|
||||
@ -1366,8 +1363,7 @@ static int lib_interface_description_delete(enum nb_event event,
|
||||
return NB_OK;
|
||||
|
||||
ifp = yang_dnode_get_entry(dnode, true);
|
||||
if (ifp->desc)
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
XFREE(MTYPE_TMP, ifp->desc);
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
@ -44,13 +44,10 @@ static struct if_rmap *if_rmap_new(void)
|
||||
|
||||
static void if_rmap_free(struct if_rmap *if_rmap)
|
||||
{
|
||||
if (if_rmap->ifname)
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->ifname);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->ifname);
|
||||
|
||||
if (if_rmap->routemap[IF_RMAP_IN])
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_IN]);
|
||||
if (if_rmap->routemap[IF_RMAP_OUT])
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_OUT]);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_IN]);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_OUT]);
|
||||
|
||||
XFREE(MTYPE_IF_RMAP, if_rmap);
|
||||
}
|
||||
@ -65,8 +62,7 @@ struct if_rmap *if_rmap_lookup(struct if_rmap_ctx *ctx, const char *ifname)
|
||||
|
||||
if_rmap = hash_lookup(ctx->ifrmaphash, &key);
|
||||
|
||||
if (key.ifname)
|
||||
XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
|
||||
|
||||
return if_rmap;
|
||||
}
|
||||
@ -106,8 +102,7 @@ static struct if_rmap *if_rmap_get(struct if_rmap_ctx *ctx, const char *ifname)
|
||||
|
||||
ret = hash_get(ctx->ifrmaphash, &key, if_rmap_hash_alloc);
|
||||
|
||||
if (key.ifname)
|
||||
XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -136,16 +131,12 @@ static struct if_rmap *if_rmap_set(struct if_rmap_ctx *ctx,
|
||||
if_rmap = if_rmap_get(ctx, ifname);
|
||||
|
||||
if (type == IF_RMAP_IN) {
|
||||
if (if_rmap->routemap[IF_RMAP_IN])
|
||||
XFREE(MTYPE_IF_RMAP_NAME,
|
||||
if_rmap->routemap[IF_RMAP_IN]);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_IN]);
|
||||
if_rmap->routemap[IF_RMAP_IN] =
|
||||
XSTRDUP(MTYPE_IF_RMAP_NAME, routemap_name);
|
||||
}
|
||||
if (type == IF_RMAP_OUT) {
|
||||
if (if_rmap->routemap[IF_RMAP_OUT])
|
||||
XFREE(MTYPE_IF_RMAP_NAME,
|
||||
if_rmap->routemap[IF_RMAP_OUT]);
|
||||
XFREE(MTYPE_IF_RMAP_NAME, if_rmap->routemap[IF_RMAP_OUT]);
|
||||
if_rmap->routemap[IF_RMAP_OUT] =
|
||||
XSTRDUP(MTYPE_IF_RMAP_NAME, routemap_name);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include <zebra.h>
|
||||
|
||||
#include "memory.h"
|
||||
#include "queue.h"
|
||||
#include "imsg.h"
|
||||
|
||||
@ -35,7 +36,7 @@ static int available_fds(unsigned int n)
|
||||
unsigned int i;
|
||||
int ret, fds[256];
|
||||
|
||||
if (n > (sizeof(fds) / sizeof(fds[0])))
|
||||
if (n > (unsigned int)array_size(fds))
|
||||
return (1);
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -116,7 +116,7 @@ uint32_t jhash(const void *key, uint32_t length, uint32_t initval)
|
||||
/* fallthru */
|
||||
case 1:
|
||||
a += k[0];
|
||||
};
|
||||
}
|
||||
|
||||
__jhash_mix(a, b, c);
|
||||
|
||||
@ -151,7 +151,7 @@ uint32_t jhash2(const uint32_t *k, uint32_t length, uint32_t initval)
|
||||
/* fallthru */
|
||||
case 1:
|
||||
a += k[0];
|
||||
};
|
||||
}
|
||||
|
||||
__jhash_mix(a, b, c);
|
||||
|
||||
|
||||
@ -116,8 +116,7 @@ static struct keychain *keychain_get(const char *name)
|
||||
|
||||
static void keychain_delete(struct keychain *keychain)
|
||||
{
|
||||
if (keychain->name)
|
||||
XFREE(MTYPE_KEYCHAIN, keychain->name);
|
||||
XFREE(MTYPE_KEYCHAIN, keychain->name);
|
||||
|
||||
list_delete(&keychain->key);
|
||||
listnode_delete(keychain_list, keychain);
|
||||
@ -217,8 +216,7 @@ static void key_delete(struct keychain *keychain, struct key *key)
|
||||
{
|
||||
listnode_delete(keychain->key, key);
|
||||
|
||||
if (key->string)
|
||||
XFREE(MTYPE_KEY, key->string);
|
||||
XFREE(MTYPE_KEY, key->string);
|
||||
key_free(key);
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ static char dbfile_default[512];
|
||||
#endif
|
||||
static char vtypath_default[256];
|
||||
|
||||
bool debug_memstats_at_exit = 0;
|
||||
bool debug_memstats_at_exit = false;
|
||||
static bool nodetach_term, nodetach_daemon;
|
||||
|
||||
static char comb_optstr[256];
|
||||
|
||||
@ -851,8 +851,7 @@ void closezlog(void)
|
||||
if (zl->fp != NULL)
|
||||
fclose(zl->fp);
|
||||
|
||||
if (zl->filename != NULL)
|
||||
XFREE(MTYPE_ZLOG, zl->filename);
|
||||
XFREE(MTYPE_ZLOG, zl->filename);
|
||||
|
||||
XFREE(MTYPE_ZLOG, zl);
|
||||
zlog_default = NULL;
|
||||
@ -911,8 +910,7 @@ int zlog_reset_file(void)
|
||||
logfile_fd = -1;
|
||||
zl->maxlvl[ZLOG_DEST_FILE] = ZLOG_DISABLED;
|
||||
|
||||
if (zl->filename)
|
||||
XFREE(MTYPE_ZLOG, zl->filename);
|
||||
XFREE(MTYPE_ZLOG, zl->filename);
|
||||
zl->filename = NULL;
|
||||
|
||||
pthread_mutex_unlock(&loglock);
|
||||
|
||||
@ -141,8 +141,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err,
|
||||
return rtinfo;
|
||||
|
||||
out_fail:
|
||||
if (rtinfo->load_args)
|
||||
XFREE(MTYPE_MODULE_LOADARGS, rtinfo->load_args);
|
||||
XFREE(MTYPE_MODULE_LOADARGS, rtinfo->load_args);
|
||||
XFREE(MTYPE_MODULE_LOADNAME, rtinfo->load_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -344,8 +344,7 @@ void ns_delete(struct ns *ns)
|
||||
// if_terminate (&ns->iflist);
|
||||
|
||||
RB_REMOVE(ns_head, &ns_tree, ns);
|
||||
if (ns->name)
|
||||
XFREE(MTYPE_NS_NAME, ns->name);
|
||||
XFREE(MTYPE_NS_NAME, ns->name);
|
||||
|
||||
XFREE(MTYPE_NS, ns);
|
||||
}
|
||||
|
||||
@ -205,11 +205,9 @@ static int nhgl_cmp(struct nexthop_hold *nh1, struct nexthop_hold *nh2)
|
||||
|
||||
static void nhgl_delete(struct nexthop_hold *nh)
|
||||
{
|
||||
if (nh->intf)
|
||||
XFREE(MTYPE_TMP, nh->intf);
|
||||
XFREE(MTYPE_TMP, nh->intf);
|
||||
|
||||
if (nh->nhvrf_name)
|
||||
XFREE(MTYPE_TMP, nh->nhvrf_name);
|
||||
XFREE(MTYPE_TMP, nh->nhvrf_name);
|
||||
|
||||
XFREE(MTYPE_TMP, nh);
|
||||
}
|
||||
|
||||
@ -1383,7 +1383,7 @@ error:
|
||||
|
||||
static int frr_confd_finish(void)
|
||||
{
|
||||
if (confd_connected == false)
|
||||
if (!confd_connected)
|
||||
return 0;
|
||||
|
||||
frr_confd_finish_cdb();
|
||||
|
||||
@ -326,8 +326,7 @@ static void prefix_list_delete(struct prefix_list *plist)
|
||||
else
|
||||
list->head = plist->next;
|
||||
|
||||
if (plist->desc)
|
||||
XFREE(MTYPE_TMP, plist->desc);
|
||||
XFREE(MTYPE_TMP, plist->desc);
|
||||
|
||||
/* Make sure master's recent changed prefix-list information is
|
||||
cleared. */
|
||||
@ -338,8 +337,7 @@ static void prefix_list_delete(struct prefix_list *plist)
|
||||
if (master->delete_hook)
|
||||
(*master->delete_hook)(plist);
|
||||
|
||||
if (plist->name)
|
||||
XFREE(MTYPE_MPREFIX_LIST_STR, plist->name);
|
||||
XFREE(MTYPE_MPREFIX_LIST_STR, plist->name);
|
||||
|
||||
XFREE(MTYPE_PREFIX_LIST_TRIE, plist->trie);
|
||||
|
||||
|
||||
@ -133,8 +133,6 @@ static int pqueue_expand(struct pqueue *queue)
|
||||
|
||||
newarray =
|
||||
XCALLOC(MTYPE_PQUEUE_DATA, queue->array_size * DATA_SIZE * 2);
|
||||
if (newarray == NULL)
|
||||
return 0;
|
||||
|
||||
memcpy(newarray, queue->array, queue->array_size * DATA_SIZE);
|
||||
|
||||
|
||||
@ -944,8 +944,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)
|
||||
ret = 1;
|
||||
|
||||
done:
|
||||
if (cp)
|
||||
XFREE(MTYPE_TMP, cp);
|
||||
XFREE(MTYPE_TMP, cp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1503,8 +1502,7 @@ char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size)
|
||||
if (!mac)
|
||||
return NULL;
|
||||
if (!buf)
|
||||
ptr = (char *)XMALLOC(MTYPE_TMP,
|
||||
ETHER_ADDR_STRLEN * sizeof(char));
|
||||
ptr = XMALLOC(MTYPE_TMP, ETHER_ADDR_STRLEN * sizeof(char));
|
||||
else {
|
||||
assert(size >= ETHER_ADDR_STRLEN);
|
||||
ptr = buf;
|
||||
@ -1585,8 +1583,7 @@ char *esi_to_str(const esi_t *esi, char *buf, int size)
|
||||
if (!esi)
|
||||
return NULL;
|
||||
if (!buf)
|
||||
ptr = (char *)XMALLOC(MTYPE_TMP,
|
||||
ESI_STR_LEN * sizeof(char));
|
||||
ptr = XMALLOC(MTYPE_TMP, ESI_STR_LEN * sizeof(char));
|
||||
else {
|
||||
assert(size >= ESI_STR_LEN);
|
||||
ptr = buf;
|
||||
|
||||
@ -538,10 +538,8 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
|
||||
break;
|
||||
}
|
||||
|
||||
if (dep_name)
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
||||
if (rmap_name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -1075,8 +1073,7 @@ static void route_map_index_delete(struct route_map_index *index, int notify)
|
||||
index->map->head = index->next;
|
||||
|
||||
/* Free 'char *nextrm' if not NULL */
|
||||
if (index->nextrm)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, index->nextrm);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, index->nextrm);
|
||||
|
||||
/* Execute event hook. */
|
||||
if (route_map_master.event_hook && notify) {
|
||||
@ -1231,8 +1228,7 @@ static void route_map_rule_delete(struct route_map_rule_list *list,
|
||||
if (rule->cmd->func_free)
|
||||
(*rule->cmd->func_free)(rule->value);
|
||||
|
||||
if (rule->rule_str)
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE_STR, rule->rule_str);
|
||||
XFREE(MTYPE_ROUTE_MAP_RULE_STR, rule->rule_str);
|
||||
|
||||
if (rule->next)
|
||||
rule->next->prev = rule->prev;
|
||||
@ -1779,8 +1775,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
|
||||
}
|
||||
|
||||
ret_map_name = (char *)hash_release(dep->dep_rmap_hash, rname);
|
||||
if (ret_map_name)
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, ret_map_name);
|
||||
XFREE(MTYPE_ROUTE_MAP_NAME, ret_map_name);
|
||||
|
||||
if (!dep->dep_rmap_hash->count) {
|
||||
dep = hash_release(dephash, dname);
|
||||
|
||||
@ -414,8 +414,6 @@ struct thread_master *thread_master_create(const char *name)
|
||||
pthread_once(&init_once, &initializer);
|
||||
|
||||
rv = XCALLOC(MTYPE_THREAD_MASTER, sizeof(struct thread_master));
|
||||
if (rv == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Initialize master mutex */
|
||||
pthread_mutex_init(&rv->mtx, NULL);
|
||||
@ -484,8 +482,7 @@ void thread_master_set_name(struct thread_master *master, const char *name)
|
||||
{
|
||||
pthread_mutex_lock(&master->mtx);
|
||||
{
|
||||
if (master->name)
|
||||
XFREE(MTYPE_THREAD_MASTER, master->name);
|
||||
XFREE(MTYPE_THREAD_MASTER, master->name);
|
||||
master->name = XSTRDUP(MTYPE_THREAD_MASTER, name);
|
||||
}
|
||||
pthread_mutex_unlock(&master->mtx);
|
||||
@ -649,8 +646,7 @@ void thread_master_free(struct thread_master *m)
|
||||
hash_free(m->cpu_record);
|
||||
m->cpu_record = NULL;
|
||||
|
||||
if (m->name)
|
||||
XFREE(MTYPE_THREAD_MASTER, m->name);
|
||||
XFREE(MTYPE_THREAD_MASTER, m->name);
|
||||
XFREE(MTYPE_THREAD_MASTER, m->handler.pfds);
|
||||
XFREE(MTYPE_THREAD_MASTER, m->handler.copy);
|
||||
XFREE(MTYPE_THREAD_MASTER, m);
|
||||
|
||||
21
lib/vty.c
21
lib/vty.c
@ -974,8 +974,7 @@ static void vty_complete_command(struct vty *vty)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (matched)
|
||||
XFREE(MTYPE_TMP, matched);
|
||||
XFREE(MTYPE_TMP, matched);
|
||||
}
|
||||
|
||||
static void vty_describe_fold(struct vty *vty, int cmd_width,
|
||||
@ -1169,8 +1168,7 @@ static void vty_hist_add(struct vty *vty)
|
||||
}
|
||||
|
||||
/* Insert history entry. */
|
||||
if (vty->hist[vty->hindex])
|
||||
XFREE(MTYPE_VTY_HIST, vty->hist[vty->hindex]);
|
||||
XFREE(MTYPE_VTY_HIST, vty->hist[vty->hindex]);
|
||||
vty->hist[vty->hindex] = XSTRDUP(MTYPE_VTY_HIST, vty->buf);
|
||||
|
||||
/* History index rotation. */
|
||||
@ -2232,9 +2230,9 @@ void vty_close(struct vty *vty)
|
||||
buffer_free(vty->lbuf);
|
||||
|
||||
/* Free command history. */
|
||||
for (i = 0; i < VTY_MAXHIST; i++)
|
||||
if (vty->hist[i])
|
||||
XFREE(MTYPE_VTY_HIST, vty->hist[i]);
|
||||
for (i = 0; i < VTY_MAXHIST; i++) {
|
||||
XFREE(MTYPE_VTY_HIST, vty->hist[i]);
|
||||
}
|
||||
|
||||
/* Unset vector. */
|
||||
if (vty->fd != -1)
|
||||
@ -2255,8 +2253,7 @@ void vty_close(struct vty *vty)
|
||||
if (vty->fd == STDIN_FILENO)
|
||||
was_stdio = true;
|
||||
|
||||
if (vty->buf)
|
||||
XFREE(MTYPE_VTY, vty->buf);
|
||||
XFREE(MTYPE_VTY, vty->buf);
|
||||
|
||||
if (vty->error) {
|
||||
vty->error->del = vty_error_delete;
|
||||
@ -2546,8 +2543,7 @@ bool vty_read_config(struct nb_config *config, const char *config_file,
|
||||
host_config_set(fullpath);
|
||||
|
||||
tmp_free_and_out:
|
||||
if (tmp)
|
||||
XFREE(MTYPE_TMP, tmp);
|
||||
XFREE(MTYPE_TMP, tmp);
|
||||
|
||||
return read_success;
|
||||
}
|
||||
@ -3163,8 +3159,7 @@ void vty_init(struct thread_master *master_thread)
|
||||
|
||||
void vty_terminate(void)
|
||||
{
|
||||
if (vty_cwd)
|
||||
XFREE(MTYPE_TMP, vty_cwd);
|
||||
XFREE(MTYPE_TMP, vty_cwd);
|
||||
|
||||
if (vtyvec && Vvty_serv_thread) {
|
||||
vty_reset();
|
||||
|
||||
@ -274,7 +274,7 @@ int work_queue_run(struct thread *thread)
|
||||
wq->cycles.granularity = WORK_QUEUE_MIN_GRANULARITY;
|
||||
|
||||
STAILQ_FOREACH_SAFE (item, &wq->items, wq, titem) {
|
||||
assert(item && item->data);
|
||||
assert(item->data);
|
||||
|
||||
/* dont run items which are past their allowed retries */
|
||||
if (item->ran > wq->spec.max_retries) {
|
||||
|
||||
@ -62,7 +62,7 @@ bool yang_str2bool(const char *value)
|
||||
|
||||
struct yang_data *yang_data_new_bool(const char *xpath, bool value)
|
||||
{
|
||||
return yang_data_new(xpath, (value == true) ? "true" : "false");
|
||||
return yang_data_new(xpath, (value) ? "true" : "false");
|
||||
}
|
||||
|
||||
bool yang_dnode_get_bool(const struct lyd_node *dnode, const char *xpath_fmt,
|
||||
|
||||
@ -122,7 +122,7 @@ static int netlink_route_recv(struct thread *t)
|
||||
|
||||
zbuf_init(&zb, buf, sizeof(buf), 0);
|
||||
while (zbuf_recv(&zb, fd) > 0) {
|
||||
while ((n = znl_nlmsg_pull(&zb, &payload)) != 0) {
|
||||
while ((n = znl_nlmsg_pull(&zb, &payload)) != NULL) {
|
||||
debugf(NHRP_DEBUG_KERNEL,
|
||||
"Netlink: Received msg_type %u, msg_flags %u",
|
||||
n->nlmsg_type, n->nlmsg_flags);
|
||||
@ -217,7 +217,7 @@ static int netlink_log_recv(struct thread *t)
|
||||
|
||||
zbuf_init(&zb, buf, sizeof(buf), 0);
|
||||
while (zbuf_recv(&zb, fd) > 0) {
|
||||
while ((n = znl_nlmsg_pull(&zb, &payload)) != 0) {
|
||||
while ((n = znl_nlmsg_pull(&zb, &payload)) != NULL) {
|
||||
debugf(NHRP_DEBUG_KERNEL,
|
||||
"Netlink-log: Received msg_type %u, msg_flags %u",
|
||||
n->nlmsg_type, n->nlmsg_flags);
|
||||
|
||||
@ -177,8 +177,7 @@ struct ospf6_interface *ospf6_interface_create(struct interface *ifp)
|
||||
struct ospf6_interface *oi;
|
||||
unsigned int iobuflen;
|
||||
|
||||
oi = (struct ospf6_interface *)XCALLOC(MTYPE_OSPF6_IF,
|
||||
sizeof(struct ospf6_interface));
|
||||
oi = XCALLOC(MTYPE_OSPF6_IF, sizeof(struct ospf6_interface));
|
||||
|
||||
oi->area = (struct ospf6_area *)NULL;
|
||||
oi->neighbor_list = list_new();
|
||||
|
||||
@ -518,16 +518,14 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header)
|
||||
lsa_size = ntohs(header->length); /* XXX vulnerable */
|
||||
|
||||
/* allocate memory for this LSA */
|
||||
new_header = (struct ospf6_lsa_header *)XMALLOC(MTYPE_OSPF6_LSA_HEADER,
|
||||
lsa_size);
|
||||
new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, lsa_size);
|
||||
|
||||
/* copy LSA from original header */
|
||||
memcpy(new_header, header, lsa_size);
|
||||
|
||||
/* LSA information structure */
|
||||
/* allocate memory */
|
||||
lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
|
||||
sizeof(struct ospf6_lsa));
|
||||
lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));
|
||||
|
||||
lsa->header = (struct ospf6_lsa_header *)new_header;
|
||||
|
||||
@ -546,16 +544,15 @@ struct ospf6_lsa *ospf6_lsa_create_headeronly(struct ospf6_lsa_header *header)
|
||||
struct ospf6_lsa_header *new_header = NULL;
|
||||
|
||||
/* allocate memory for this LSA */
|
||||
new_header = (struct ospf6_lsa_header *)XMALLOC(
|
||||
MTYPE_OSPF6_LSA_HEADER, sizeof(struct ospf6_lsa_header));
|
||||
new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER,
|
||||
sizeof(struct ospf6_lsa_header));
|
||||
|
||||
/* copy LSA from original header */
|
||||
memcpy(new_header, header, sizeof(struct ospf6_lsa_header));
|
||||
|
||||
/* LSA information structure */
|
||||
/* allocate memory */
|
||||
lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
|
||||
sizeof(struct ospf6_lsa));
|
||||
lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));
|
||||
|
||||
lsa->header = (struct ospf6_lsa_header *)new_header;
|
||||
SET_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY);
|
||||
|
||||
@ -39,10 +39,6 @@ struct ospf6_lsdb *ospf6_lsdb_create(void *data)
|
||||
struct ospf6_lsdb *lsdb;
|
||||
|
||||
lsdb = XCALLOC(MTYPE_OSPF6_LSDB, sizeof(struct ospf6_lsdb));
|
||||
if (lsdb == NULL) {
|
||||
zlog_warn("Can't malloc lsdb");
|
||||
return NULL;
|
||||
}
|
||||
memset(lsdb, 0, sizeof(struct ospf6_lsdb));
|
||||
|
||||
lsdb->data = data;
|
||||
|
||||
@ -1505,10 +1505,8 @@ int ospf6_iobuf_size(unsigned int size)
|
||||
recvnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
|
||||
sendnew = XMALLOC(MTYPE_OSPF6_MESSAGE, size);
|
||||
|
||||
if (recvbuf)
|
||||
XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
|
||||
if (sendbuf)
|
||||
XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
|
||||
XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
|
||||
XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
|
||||
recvbuf = recvnew;
|
||||
sendbuf = sendnew;
|
||||
iobuflen = size;
|
||||
|
||||
@ -86,10 +86,7 @@ struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
|
||||
struct ospf6_neighbor *on;
|
||||
char buf[16];
|
||||
|
||||
on = (struct ospf6_neighbor *)XMALLOC(MTYPE_OSPF6_NEIGHBOR,
|
||||
sizeof(struct ospf6_neighbor));
|
||||
|
||||
memset(on, 0, sizeof(struct ospf6_neighbor));
|
||||
on = XCALLOC(MTYPE_OSPF6_NEIGHBOR, sizeof(struct ospf6_neighbor));
|
||||
inet_ntop(AF_INET, &router_id, buf, sizeof(buf));
|
||||
snprintf(on->name, sizeof(on->name), "%s%%%s", buf,
|
||||
oi->interface->name);
|
||||
|
||||
@ -174,8 +174,7 @@ struct ospf6_nexthop *ospf6_nexthop_create(void)
|
||||
|
||||
void ospf6_nexthop_delete(struct ospf6_nexthop *nh)
|
||||
{
|
||||
if (nh)
|
||||
XFREE(MTYPE_OSPF6_NEXTHOP, nh);
|
||||
XFREE(MTYPE_OSPF6_NEXTHOP, nh);
|
||||
}
|
||||
|
||||
void ospf6_clear_nexthops(struct list *nh_list)
|
||||
|
||||
@ -1358,13 +1358,10 @@ static int ospf6TrapNbrStateChange(struct ospf6_neighbor *on, int next_state,
|
||||
index[1] = on->ospf6_if->instance_id;
|
||||
index[2] = ntohl(on->router_id);
|
||||
|
||||
smux_trap(ospfv3_variables,
|
||||
sizeof ospfv3_variables / sizeof(struct variable),
|
||||
ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
|
||||
ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 3,
|
||||
ospf6NbrTrapList,
|
||||
sizeof ospf6NbrTrapList / sizeof(struct trap_object),
|
||||
NBRSTATECHANGE);
|
||||
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
|
||||
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
|
||||
sizeof ospfv3_oid / sizeof(oid), index, 3, ospf6NbrTrapList,
|
||||
array_size(ospf6NbrTrapList), NBRSTATECHANGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1383,13 +1380,10 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state,
|
||||
index[0] = oi->interface->ifindex;
|
||||
index[1] = oi->instance_id;
|
||||
|
||||
smux_trap(ospfv3_variables,
|
||||
sizeof ospfv3_variables / sizeof(struct variable),
|
||||
ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
|
||||
ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 2,
|
||||
ospf6IfTrapList,
|
||||
sizeof ospf6IfTrapList / sizeof(struct trap_object),
|
||||
IFSTATECHANGE);
|
||||
smux_trap(ospfv3_variables, array_size(ospfv3_variables),
|
||||
ospfv3_trap_oid, array_size(ospfv3_trap_oid), ospfv3_oid,
|
||||
sizeof ospfv3_oid / sizeof(oid), index, 2, ospf6IfTrapList,
|
||||
array_size(ospf6IfTrapList), IFSTATECHANGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -107,8 +107,7 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa)
|
||||
{
|
||||
struct ospf6_vertex *v;
|
||||
|
||||
v = (struct ospf6_vertex *)XMALLOC(MTYPE_OSPF6_VERTEX,
|
||||
sizeof(struct ospf6_vertex));
|
||||
v = XMALLOC(MTYPE_OSPF6_VERTEX, sizeof(struct ospf6_vertex));
|
||||
|
||||
/* type */
|
||||
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_ROUTER) {
|
||||
@ -1016,8 +1015,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
|
||||
new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, total_lsa_length);
|
||||
|
||||
/* LSA information structure */
|
||||
lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
|
||||
sizeof(struct ospf6_lsa));
|
||||
lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));
|
||||
|
||||
lsa->header = (struct ospf6_lsa_header *)new_header;
|
||||
|
||||
|
||||
@ -79,8 +79,7 @@ struct external_info *ospf_external_info_new(uint8_t type,
|
||||
{
|
||||
struct external_info *new;
|
||||
|
||||
new = (struct external_info *)XCALLOC(MTYPE_OSPF_EXTERNAL_INFO,
|
||||
sizeof(struct external_info));
|
||||
new = XCALLOC(MTYPE_OSPF_EXTERNAL_INFO, sizeof(struct external_info));
|
||||
new->type = type;
|
||||
new->instance = instance;
|
||||
|
||||
|
||||
@ -380,12 +380,10 @@ static int ism_interface_up(struct ospf_interface *oi)
|
||||
|
||||
static int ism_loop_ind(struct ospf_interface *oi)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* call ism_interface_down. */
|
||||
/* ret = ism_interface_down (oi); */
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Interface down event handler. */
|
||||
|
||||
@ -2590,13 +2590,10 @@ static void ospfTrapNbrStateChange(struct ospf_neighbor *on)
|
||||
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
||||
index[IN_ADDR_SIZE] = 0;
|
||||
|
||||
smux_trap(ospf_variables,
|
||||
sizeof ospf_variables / sizeof(struct variable),
|
||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
||||
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||
array_size(ospf_trap_oid), ospf_oid,
|
||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||
ospfNbrTrapList,
|
||||
sizeof ospfNbrTrapList / sizeof(struct trap_object),
|
||||
NBRSTATECHANGE);
|
||||
ospfNbrTrapList, array_size(ospfNbrTrapList), NBRSTATECHANGE);
|
||||
}
|
||||
|
||||
static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
||||
@ -2608,12 +2605,10 @@ static void ospfTrapVirtNbrStateChange(struct ospf_neighbor *on)
|
||||
oid_copy_addr(index, &(on->address.u.prefix4), IN_ADDR_SIZE);
|
||||
index[IN_ADDR_SIZE] = 0;
|
||||
|
||||
smux_trap(ospf_variables,
|
||||
sizeof ospf_variables / sizeof(struct variable),
|
||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
||||
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||
array_size(ospf_trap_oid), ospf_oid,
|
||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||
ospfVirtNbrTrapList,
|
||||
sizeof ospfVirtNbrTrapList / sizeof(struct trap_object),
|
||||
ospfVirtNbrTrapList, array_size(ospfVirtNbrTrapList),
|
||||
VIRTNBRSTATECHANGE);
|
||||
}
|
||||
|
||||
@ -2649,13 +2644,10 @@ static void ospfTrapIfStateChange(struct ospf_interface *oi)
|
||||
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
||||
index[IN_ADDR_SIZE] = 0;
|
||||
|
||||
smux_trap(ospf_variables,
|
||||
sizeof ospf_variables / sizeof(struct variable),
|
||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
||||
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||
array_size(ospf_trap_oid), ospf_oid,
|
||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||
ospfIfTrapList,
|
||||
sizeof ospfIfTrapList / sizeof(struct trap_object),
|
||||
IFSTATECHANGE);
|
||||
ospfIfTrapList, array_size(ospfIfTrapList), IFSTATECHANGE);
|
||||
}
|
||||
|
||||
static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
||||
@ -2667,12 +2659,10 @@ static void ospfTrapVirtIfStateChange(struct ospf_interface *oi)
|
||||
oid_copy_addr(index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
|
||||
index[IN_ADDR_SIZE] = 0;
|
||||
|
||||
smux_trap(ospf_variables,
|
||||
sizeof ospf_variables / sizeof(struct variable),
|
||||
ospf_trap_oid, sizeof ospf_trap_oid / sizeof(oid), ospf_oid,
|
||||
smux_trap(ospf_variables, array_size(ospf_variables), ospf_trap_oid,
|
||||
array_size(ospf_trap_oid), ospf_oid,
|
||||
sizeof ospf_oid / sizeof(oid), index, IN_ADDR_SIZE + 1,
|
||||
ospfVirtIfTrapList,
|
||||
sizeof ospfVirtIfTrapList / sizeof(struct trap_object),
|
||||
ospfVirtIfTrapList, array_size(ospfVirtIfTrapList),
|
||||
VIRTIFSTATECHANGE);
|
||||
}
|
||||
|
||||
|
||||
@ -560,8 +560,7 @@ struct ospf_external *ospf_external_add(struct ospf *ospf, uint8_t type,
|
||||
ospf->external[type] = list_new();
|
||||
|
||||
ext_list = ospf->external[type];
|
||||
ext = (struct ospf_external *)XCALLOC(MTYPE_OSPF_EXTERNAL,
|
||||
sizeof(struct ospf_external));
|
||||
ext = XCALLOC(MTYPE_OSPF_EXTERNAL, sizeof(struct ospf_external));
|
||||
ext->instance = instance;
|
||||
EXTERNAL_INFO(ext) = route_table_init();
|
||||
|
||||
@ -621,8 +620,7 @@ struct ospf_redist *ospf_redist_add(struct ospf *ospf, uint8_t type,
|
||||
ospf->redist[type] = list_new();
|
||||
|
||||
red_list = ospf->redist[type];
|
||||
red = (struct ospf_redist *)XCALLOC(MTYPE_OSPF_REDISTRIBUTE,
|
||||
sizeof(struct ospf_redist));
|
||||
red = XCALLOC(MTYPE_OSPF_REDISTRIBUTE, sizeof(struct ospf_redist));
|
||||
red->instance = instance;
|
||||
red->dmetric.type = -1;
|
||||
red->dmetric.value = -1;
|
||||
|
||||
@ -71,8 +71,7 @@ static int pbr_map_sequence_compare(const struct pbr_map_sequence *pbrms1,
|
||||
|
||||
static void pbr_map_sequence_delete(struct pbr_map_sequence *pbrms)
|
||||
{
|
||||
if (pbrms->internal_nhg_name)
|
||||
XFREE(MTYPE_TMP, pbrms->internal_nhg_name);
|
||||
XFREE(MTYPE_TMP, pbrms->internal_nhg_name);
|
||||
|
||||
XFREE(MTYPE_PBR_MAP_SEQNO, pbrms);
|
||||
}
|
||||
|
||||
@ -740,7 +740,7 @@ uint32_t pbr_nht_get_next_tableid(bool peek)
|
||||
bool found = false;
|
||||
|
||||
for (i = pbr_nhg_low_table; i <= pbr_nhg_high_table; i++) {
|
||||
if (nhg_tableid[i] == false) {
|
||||
if (!nhg_tableid[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5159,16 +5159,14 @@ static int pim_cmd_spt_switchover(struct pim_instance *pim,
|
||||
|
||||
switch (pim->spt.switchover) {
|
||||
case PIM_SPT_IMMEDIATE:
|
||||
if (pim->spt.plist)
|
||||
XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
|
||||
XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
|
||||
|
||||
pim_upstream_add_lhr_star_pimreg(pim);
|
||||
break;
|
||||
case PIM_SPT_INFINITY:
|
||||
pim_upstream_remove_lhr_star_pimreg(pim, plist);
|
||||
|
||||
if (pim->spt.plist)
|
||||
XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
|
||||
XFREE(MTYPE_PIM_SPT_PLIST_NAME, pim->spt.plist);
|
||||
|
||||
if (plist)
|
||||
pim->spt.plist =
|
||||
|
||||
@ -208,8 +208,7 @@ void pim_if_delete(struct interface *ifp)
|
||||
list_delete(&pim_ifp->upstream_switch_list);
|
||||
list_delete(&pim_ifp->sec_addr_list);
|
||||
|
||||
if (pim_ifp->boundary_oil_plist)
|
||||
XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist);
|
||||
XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist);
|
||||
|
||||
while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) {
|
||||
ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb);
|
||||
|
||||
@ -68,7 +68,7 @@ struct zebra_privs_t pimd_privs = {
|
||||
.vty_group = VTY_GROUP,
|
||||
#endif
|
||||
.caps_p = _caps_p,
|
||||
.cap_num_p = sizeof(_caps_p) / sizeof(_caps_p[0]),
|
||||
.cap_num_p = array_size(_caps_p),
|
||||
.cap_num_i = 0};
|
||||
|
||||
static const struct frr_yang_module_info *pimd_yang_modules[] = {
|
||||
|
||||
@ -1256,8 +1256,7 @@ static void pim_msdp_mg_free(struct pim_instance *pim)
|
||||
if (PIM_DEBUG_MSDP_EVENTS) {
|
||||
zlog_debug("MSDP mesh-group %s deleted", mg->mesh_group_name);
|
||||
}
|
||||
if (mg->mesh_group_name)
|
||||
XFREE(MTYPE_PIM_MSDP_MG_NAME, mg->mesh_group_name);
|
||||
XFREE(MTYPE_PIM_MSDP_MG_NAME, mg->mesh_group_name);
|
||||
|
||||
if (mg->mbr_list)
|
||||
list_delete(&mg->mbr_list);
|
||||
|
||||
@ -65,8 +65,7 @@ void pim_rp_list_hash_clean(void *data)
|
||||
|
||||
static void pim_rp_info_free(struct rp_info *rp_info)
|
||||
{
|
||||
if (rp_info->plist)
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, rp_info->plist);
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, rp_info->plist);
|
||||
|
||||
XFREE(MTYPE_PIM_RP, rp_info);
|
||||
}
|
||||
|
||||
@ -151,8 +151,7 @@ void pim_ssm_terminate(struct pim_ssm *ssm)
|
||||
if (!ssm)
|
||||
return;
|
||||
|
||||
if (ssm->plist_name)
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
|
||||
XFREE(MTYPE_PIM_FILTER_NAME, ssm->plist_name);
|
||||
|
||||
XFREE(MTYPE_PIM_SSM_INFO, ssm);
|
||||
}
|
||||
|
||||
@ -510,11 +510,9 @@ static void rip_interface_reset(struct rip_interface *ri)
|
||||
ri->ri_receive = yang_get_default_enum("%s/version-receive", RIP_IFACE);
|
||||
ri->v2_broadcast = yang_get_default_bool("%s/v2-broadcast", RIP_IFACE);
|
||||
|
||||
if (ri->auth_str)
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
|
||||
|
||||
if (ri->key_chain)
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
|
||||
|
||||
ri->list[RIP_FILTER_IN] = NULL;
|
||||
ri->list[RIP_FILTER_OUT] = NULL;
|
||||
|
||||
@ -937,8 +937,7 @@ lib_interface_rip_authentication_password_modify(enum nb_event event,
|
||||
|
||||
ifp = yang_dnode_get_entry(dnode, true);
|
||||
ri = ifp->info;
|
||||
if (ri->auth_str)
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
|
||||
ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
|
||||
yang_dnode_get_string(dnode, NULL));
|
||||
|
||||
@ -978,8 +977,7 @@ lib_interface_rip_authentication_key_chain_modify(enum nb_event event,
|
||||
|
||||
ifp = yang_dnode_get_entry(dnode, true);
|
||||
ri = ifp->info;
|
||||
if (ri->key_chain)
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
|
||||
XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
|
||||
ri->key_chain = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
|
||||
yang_dnode_get_string(dnode, NULL));
|
||||
|
||||
|
||||
@ -104,30 +104,18 @@ static int static_list_compare_helper(const char *s1, const char *s2)
|
||||
|
||||
static void static_list_delete(struct static_hold_route *shr)
|
||||
{
|
||||
if (shr->vrf_name)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->vrf_name);
|
||||
if (shr->nhvrf_name)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->nhvrf_name);
|
||||
if (shr->dest_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->dest_str);
|
||||
if (shr->mask_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->mask_str);
|
||||
if (shr->src_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->src_str);
|
||||
if (shr->gate_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->gate_str);
|
||||
if (shr->ifname)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->ifname);
|
||||
if (shr->flag_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->flag_str);
|
||||
if (shr->tag_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->tag_str);
|
||||
if (shr->distance_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->distance_str);
|
||||
if (shr->label_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->label_str);
|
||||
if (shr->table_str)
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->table_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->vrf_name);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->nhvrf_name);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->dest_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->mask_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->src_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->gate_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->ifname);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->flag_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->tag_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->distance_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->label_str);
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr->table_str);
|
||||
|
||||
XFREE(MTYPE_STATIC_ROUTE, shr);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ static void test_range_lookup(void)
|
||||
"1.16.160.0/19", "1.16.32.0/20",
|
||||
"1.16.32.0/21", "16.0.0.0/16"};
|
||||
|
||||
int num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
|
||||
int num_prefixes = array_size(prefixes);
|
||||
|
||||
for (int i = 0; i < num_prefixes; i++)
|
||||
add_node(table, prefixes[i]);
|
||||
|
||||
@ -205,7 +205,7 @@ struct peer test_mp_list_peer[] = {
|
||||
{.local_as = 1, .as = 2}, {.local_as = 1, .as = 2},
|
||||
{.local_as = 1, .as = 2},
|
||||
};
|
||||
int test_mp_list_peer_count = sizeof(test_mp_list_peer) / sizeof(struct peer);
|
||||
int test_mp_list_peer_count = array_size(test_mp_list_peer);
|
||||
struct attr test_mp_list_attr[4];
|
||||
struct bgp_path_info test_mp_list_info[] = {
|
||||
{.peer = &test_mp_list_peer[0], .attr = &test_mp_list_attr[0]},
|
||||
@ -214,8 +214,7 @@ struct bgp_path_info test_mp_list_info[] = {
|
||||
{.peer = &test_mp_list_peer[3], .attr = &test_mp_list_attr[2]},
|
||||
{.peer = &test_mp_list_peer[4], .attr = &test_mp_list_attr[3]},
|
||||
};
|
||||
int test_mp_list_info_count =
|
||||
sizeof(test_mp_list_info) / sizeof(struct bgp_path_info);
|
||||
int test_mp_list_info_count = array_size(test_mp_list_info);
|
||||
|
||||
static int setup_bgp_mp_list(testcase_t *t)
|
||||
{
|
||||
@ -370,7 +369,7 @@ testcase_t *all_tests[] = {
|
||||
&test_bgp_path_info_mpath_update,
|
||||
};
|
||||
|
||||
int all_tests_count = (sizeof(all_tests) / sizeof(testcase_t *));
|
||||
int all_tests_count = array_size(all_tests);
|
||||
|
||||
/*=========================================================
|
||||
* Test Driver Functions
|
||||
|
||||
@ -37,7 +37,7 @@ struct zebra_privs_t test_privs = {
|
||||
.vty_group = VTY_GROUP,
|
||||
#endif
|
||||
.caps_p = _caps_p,
|
||||
.cap_num_p = sizeof(_caps_p) / sizeof(_caps_p[0]),
|
||||
.cap_num_p = array_size(_caps_p),
|
||||
.cap_num_i = 0};
|
||||
|
||||
struct option longopts[] = {{"help", no_argument, NULL, 'h'},
|
||||
|
||||
@ -105,7 +105,7 @@ static unsigned int log_key(void *data)
|
||||
static bool log_cmp(const void *a, const void *b)
|
||||
{
|
||||
if (a == NULL || b == NULL)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return !memcmp(a, b, 2 * sizeof(struct prefix));
|
||||
}
|
||||
|
||||
@ -478,7 +478,7 @@ static void test_iter_pause(void)
|
||||
const char *prefixes[] = {"1.0.1.0/24", "1.0.1.0/25", "1.0.1.128/25",
|
||||
"1.0.2.0/24", "2.0.0.0/8"};
|
||||
|
||||
num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
|
||||
num_prefixes = array_size(prefixes);
|
||||
|
||||
printf("\n\nTesting that route_table_iter_pause() works as expected\n");
|
||||
table = route_table_init();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user