*: Convert connected_free to a double pointer

Set the connected pointer to set the pointer to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-10-29 20:16:28 -04:00
parent 63265b5c1f
commit 721c08573a
17 changed files with 39 additions and 29 deletions

View file

@ -357,7 +357,7 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
bgp_connected_delete(bgp, ifc); bgp_connected_delete(bgp, ifc);
} }
connected_free(ifc); connected_free(&ifc);
return 0; return 0;
} }

View file

@ -189,7 +189,7 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (prefix_cmp(&ei->address, c->address) == 0) if (prefix_cmp(&ei->address, c->address) == 0)
eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA); eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA);
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -128,7 +128,7 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
if (if_is_operative(ifp)) if (if_is_operative(ifp))
isis_circuit_del_addr(circuit_scan_by_ifp(ifp), c); isis_circuit_del_addr(circuit_scan_by_ifp(ifp), c);
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -368,7 +368,7 @@ ldp_interface_address_delete(ZAPI_CALLBACK_ARGS)
ifp = ifc->ifp; ifp = ifc->ifp;
ifc2kaddr(ifp, ifc, &ka); ifc2kaddr(ifp, ifc, &ka);
connected_free(ifc); connected_free(&ifc);
/* Filter invalid addresses. */ /* Filter invalid addresses. */
if (bad_addr(ka.af, &ka.addr)) if (bad_addr(ka.af, &ka.addr))

View file

@ -140,6 +140,13 @@ static int if_cmp_index_func(const struct interface *ifp1,
return ifp1->ifindex - ifp2->ifindex; return ifp1->ifindex - ifp2->ifindex;
} }
static void ifp_connected_free(void *arg)
{
struct connected *c = arg;
connected_free(&c);
}
/* Create new interface structure. */ /* Create new interface structure. */
static struct interface *if_new(vrf_id_t vrf_id) static struct interface *if_new(vrf_id_t vrf_id)
{ {
@ -153,7 +160,7 @@ static struct interface *if_new(vrf_id_t vrf_id)
ifp->vrf_id = vrf_id; ifp->vrf_id = vrf_id;
ifp->connected = list_new(); ifp->connected = list_new();
ifp->connected->del = (void (*)(void *))connected_free; ifp->connected->del = ifp_connected_free;
ifp->nbr_connected = list_new(); ifp->nbr_connected = list_new();
ifp->nbr_connected->del = (void (*)(void *))nbr_connected_free; ifp->nbr_connected->del = (void (*)(void *))nbr_connected_free;
@ -866,17 +873,20 @@ struct nbr_connected *nbr_connected_new(void)
} }
/* Free connected structure. */ /* Free connected structure. */
void connected_free(struct connected *connected) void connected_free(struct connected **connected)
{ {
if (connected->address) struct connected *ptr = *connected;
prefix_free(&connected->address);
if (connected->destination) if (ptr->address)
prefix_free(&connected->destination); prefix_free(&ptr->address);
XFREE(MTYPE_CONNECTED_LABEL, connected->label); if (ptr->destination)
prefix_free(&ptr->destination);
XFREE(MTYPE_CONNECTED, connected); XFREE(MTYPE_CONNECTED_LABEL, ptr->label);
XFREE(MTYPE_CONNECTED, ptr);
*connected = NULL;
} }
/* Free nbr connected structure. */ /* Free nbr connected structure. */

View file

@ -543,7 +543,7 @@ extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id);
/* Connected address functions. */ /* Connected address functions. */
extern struct connected *connected_new(void); extern struct connected *connected_new(void);
extern void connected_free(struct connected *); extern void connected_free(struct connected **connected);
extern void connected_add(struct interface *, struct connected *); extern void connected_add(struct interface *, struct connected *);
extern struct connected * extern struct connected *
connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *); connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *);

View file

@ -364,7 +364,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
nhrp_interface_update_address( nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0); ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
connected_free(ifc); connected_free(&ifc);
return 0; return 0;
} }

View file

@ -143,7 +143,7 @@ static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
ospf6_interface_state_update(c->ifp); ospf6_interface_state_update(c->ifp);
} }
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -150,7 +150,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
rn = route_node_lookup(IF_OIFS(ifp), &p); rn = route_node_lookup(IF_OIFS(ifp), &p);
if (!rn) { if (!rn) {
connected_free(c); connected_free(&c);
return 0; return 0;
} }
@ -163,7 +163,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
ospf_if_interface(c->ifp); ospf_if_interface(c->ifp);
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -109,7 +109,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
"%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name, "%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name,
prefix2str(c->address, buf, sizeof(buf))); prefix2str(c->address, buf, sizeof(buf)));
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -233,7 +233,7 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
pim_i_am_rp_re_evaluate(pim); pim_i_am_rp_re_evaluate(pim);
} }
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -648,7 +648,7 @@ int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
rip_apply_address_del(ifc); rip_apply_address_del(ifc);
} }
connected_free(ifc); connected_free(&ifc);
} }
return 0; return 0;

View file

@ -430,7 +430,7 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
/* Check wether this prefix needs to be removed. */ /* Check wether this prefix needs to be removed. */
ripng_apply_address_del(ifc); ripng_apply_address_del(ifc);
} }
connected_free(ifc); connected_free(&ifc);
} }
return 0; return 0;

View file

@ -73,7 +73,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c) if (!c)
return 0; return 0;
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -79,7 +79,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c) if (!c)
return 0; return 0;
connected_free(c); connected_free(&c);
return 0; return 0;
} }

View file

@ -65,7 +65,7 @@ static void connected_withdraw(struct connected *ifc)
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) { if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) {
listnode_delete(ifc->ifp->connected, ifc); listnode_delete(ifc->ifp->connected, ifc);
connected_free(ifc); connected_free(&ifc);
} }
} }
@ -177,7 +177,7 @@ static void connected_update(struct interface *ifp, struct connected *ifc)
*/ */
if (connected_same(current, ifc)) { if (connected_same(current, ifc)) {
/* nothing to do */ /* nothing to do */
connected_free(ifc); connected_free(&ifc);
return; return;
} }

View file

@ -738,7 +738,7 @@ static void if_delete_connected(struct interface *ifp)
ZEBRA_IFC_CONFIGURED)) { ZEBRA_IFC_CONFIGURED)) {
listnode_delete(ifp->connected, listnode_delete(ifp->connected,
ifc); ifc);
connected_free(ifc); connected_free(&ifc);
} else } else
last = node; last = node;
} }
@ -759,7 +759,7 @@ static void if_delete_connected(struct interface *ifp)
last = node; last = node;
else { else {
listnode_delete(ifp->connected, ifc); listnode_delete(ifp->connected, ifc);
connected_free(ifc); connected_free(&ifc);
} }
} else { } else {
last = node; last = node;
@ -2878,7 +2878,7 @@ static int ip_address_uninstall(struct vty *vty, struct interface *ifp,
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED) if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) { || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc); listnode_delete(ifp->connected, ifc);
connected_free(ifc); connected_free(&ifc);
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
@ -3103,7 +3103,7 @@ static int ipv6_address_uninstall(struct vty *vty, struct interface *ifp,
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED) if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) { || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc); listnode_delete(ifp->connected, ifc);
connected_free(ifc); connected_free(&ifc);
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }