summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-10-29 20:16:28 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-11-02 16:13:44 -0400
commit721c08573ab0427622e3073b7462196bc36a2894 (patch)
tree6e9fc167929ee822d31d5e9359aa5dd5fe8e2605
parent63265b5c1f9fb28946376b535a814bec1dbd19ed (diff)
*: 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>
-rw-r--r--bgpd/bgp_zebra.c2
-rw-r--r--eigrpd/eigrp_zebra.c2
-rw-r--r--isisd/isis_zebra.c2
-rw-r--r--ldpd/ldp_zebra.c2
-rw-r--r--lib/if.c26
-rw-r--r--lib/if.h2
-rw-r--r--nhrpd/nhrp_interface.c2
-rw-r--r--ospf6d/ospf6_zebra.c2
-rw-r--r--ospfd/ospf_zebra.c4
-rw-r--r--pbrd/pbr_zebra.c2
-rw-r--r--pimd/pim_zebra.c2
-rw-r--r--ripd/rip_interface.c2
-rw-r--r--ripngd/ripng_interface.c2
-rw-r--r--sharpd/sharp_zebra.c2
-rw-r--r--staticd/static_zebra.c2
-rw-r--r--zebra/connected.c4
-rw-r--r--zebra/interface.c8
17 files changed, 39 insertions, 29 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 7923f076c1..d0a732b153 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -357,7 +357,7 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
bgp_connected_delete(bgp, ifc);
}
- connected_free(ifc);
+ connected_free(&ifc);
return 0;
}
diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c
index 9a0fdda0f9..3205f13922 100644
--- a/eigrpd/eigrp_zebra.c
+++ b/eigrpd/eigrp_zebra.c
@@ -189,7 +189,7 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (prefix_cmp(&ei->address, c->address) == 0)
eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA);
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index bdf6869f5c..b4c699ccbb 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -128,7 +128,7 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
if (if_is_operative(ifp))
isis_circuit_del_addr(circuit_scan_by_ifp(ifp), c);
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c
index 4df1fc0304..946b51e4ee 100644
--- a/ldpd/ldp_zebra.c
+++ b/ldpd/ldp_zebra.c
@@ -368,7 +368,7 @@ ldp_interface_address_delete(ZAPI_CALLBACK_ARGS)
ifp = ifc->ifp;
ifc2kaddr(ifp, ifc, &ka);
- connected_free(ifc);
+ connected_free(&ifc);
/* Filter invalid addresses. */
if (bad_addr(ka.af, &ka.addr))
diff --git a/lib/if.c b/lib/if.c
index a185d53ef7..e61bf00283 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -140,6 +140,13 @@ static int if_cmp_index_func(const struct interface *ifp1,
return ifp1->ifindex - ifp2->ifindex;
}
+static void ifp_connected_free(void *arg)
+{
+ struct connected *c = arg;
+
+ connected_free(&c);
+}
+
/* Create new interface structure. */
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->connected = list_new();
- ifp->connected->del = (void (*)(void *))connected_free;
+ ifp->connected->del = ifp_connected_free;
ifp->nbr_connected = list_new();
ifp->nbr_connected->del = (void (*)(void *))nbr_connected_free;
@@ -866,17 +873,20 @@ struct nbr_connected *nbr_connected_new(void)
}
/* Free connected structure. */
-void connected_free(struct connected *connected)
+void connected_free(struct connected **connected)
{
- if (connected->address)
- prefix_free(&connected->address);
+ struct connected *ptr = *connected;
+
+ if (ptr->address)
+ prefix_free(&ptr->address);
- if (connected->destination)
- prefix_free(&connected->destination);
+ if (ptr->destination)
+ prefix_free(&ptr->destination);
- XFREE(MTYPE_CONNECTED_LABEL, connected->label);
+ XFREE(MTYPE_CONNECTED_LABEL, ptr->label);
- XFREE(MTYPE_CONNECTED, connected);
+ XFREE(MTYPE_CONNECTED, ptr);
+ *connected = NULL;
}
/* Free nbr connected structure. */
diff --git a/lib/if.h b/lib/if.h
index 6322290937..6d966a2556 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -543,7 +543,7 @@ extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id);
/* Connected address functions. */
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 struct connected *
connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *);
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index e4f614c7c4..9f828a1c7d 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -364,7 +364,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
- connected_free(ifc);
+ connected_free(&ifc);
return 0;
}
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index d8a6a39e1e..6832737ada 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -143,7 +143,7 @@ static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
ospf6_interface_state_update(c->ifp);
}
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 5678d545ba..68d9d3bf83 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -150,7 +150,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
rn = route_node_lookup(IF_OIFS(ifp), &p);
if (!rn) {
- connected_free(c);
+ connected_free(&c);
return 0;
}
@@ -163,7 +163,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
ospf_if_interface(c->ifp);
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index 39e92467ab..719374e3b9 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -109,7 +109,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
"%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name,
prefix2str(c->address, buf, sizeof(buf)));
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index dadcbbe65d..dfddee99d0 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -233,7 +233,7 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
pim_i_am_rp_re_evaluate(pim);
}
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 3173277ba7..4d48740606 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -648,7 +648,7 @@ int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
rip_apply_address_del(ifc);
}
- connected_free(ifc);
+ connected_free(&ifc);
}
return 0;
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 9209a76460..97113a180f 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -430,7 +430,7 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
/* Check wether this prefix needs to be removed. */
ripng_apply_address_del(ifc);
}
- connected_free(ifc);
+ connected_free(&ifc);
}
return 0;
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index da2aa2f539..cd577e9051 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -73,7 +73,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c)
return 0;
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c
index 049cb4b4fa..a474613b4d 100644
--- a/staticd/static_zebra.c
+++ b/staticd/static_zebra.c
@@ -79,7 +79,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c)
return 0;
- connected_free(c);
+ connected_free(&c);
return 0;
}
diff --git a/zebra/connected.c b/zebra/connected.c
index 75f4f53bc6..0ff474d787 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -65,7 +65,7 @@ static void connected_withdraw(struct connected *ifc)
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) {
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)) {
/* nothing to do */
- connected_free(ifc);
+ connected_free(&ifc);
return;
}
diff --git a/zebra/interface.c b/zebra/interface.c
index daa93e36d1..5871b8746f 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -738,7 +738,7 @@ static void if_delete_connected(struct interface *ifp)
ZEBRA_IFC_CONFIGURED)) {
listnode_delete(ifp->connected,
ifc);
- connected_free(ifc);
+ connected_free(&ifc);
} else
last = node;
}
@@ -759,7 +759,7 @@ static void if_delete_connected(struct interface *ifp)
last = node;
else {
listnode_delete(ifp->connected, ifc);
- connected_free(ifc);
+ connected_free(&ifc);
}
} else {
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)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc);
- connected_free(ifc);
+ connected_free(&ifc);
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)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc);
- connected_free(ifc);
+ connected_free(&ifc);
return CMD_WARNING_CONFIG_FAILED;
}