diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-10-29 20:24:10 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-11-02 16:13:44 -0400 |
| commit | f609709a58c8255188de8d6ddfa44c3f8b3abad4 (patch) | |
| tree | 81c7f47f1f4ce4cce832d8a195c59d173e77a671 /lib/if.c | |
| parent | 721c08573ab0427622e3073b7462196bc36a2894 (diff) | |
lib, ospfd, zebra: Convert interface_delete to take double pointer
When free'ing the interface pointer, set it to NULL.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -185,7 +185,7 @@ void if_destroy_via_zapi(struct interface *ifp) if_set_index(ifp, IFINDEX_INTERNAL); if (!ifp->configured) - if_delete(ifp); + if_delete(&ifp); } void if_up_via_zapi(struct interface *ifp) @@ -283,27 +283,29 @@ void if_delete_retain(struct interface *ifp) } /* Delete and free interface structure. */ -void if_delete(struct interface *ifp) +void if_delete(struct interface **ifp) { + struct interface *ptr = *ifp; struct vrf *vrf; - vrf = vrf_lookup_by_id(ifp->vrf_id); + vrf = vrf_lookup_by_id(ptr->vrf_id); assert(vrf); - IFNAME_RB_REMOVE(vrf, ifp); - if (ifp->ifindex != IFINDEX_INTERNAL) - IFINDEX_RB_REMOVE(vrf, ifp); + IFNAME_RB_REMOVE(vrf, ptr); + if (ptr->ifindex != IFINDEX_INTERNAL) + IFINDEX_RB_REMOVE(vrf, ptr); - if_delete_retain(ifp); + if_delete_retain(ptr); - list_delete(&ifp->connected); - list_delete(&ifp->nbr_connected); + list_delete(&ptr->connected); + list_delete(&ptr->nbr_connected); - if_link_params_free(ifp); + if_link_params_free(ptr); - XFREE(MTYPE_TMP, ifp->desc); + XFREE(MTYPE_TMP, ptr->desc); - XFREE(MTYPE_IF, ifp); + XFREE(MTYPE_IF, ptr); + *ifp = NULL; } /* Used only internally to check within VRF only */ @@ -1169,7 +1171,7 @@ void if_terminate(struct vrf *vrf) ifp->node->info = NULL; route_unlock_node(ifp->node); } - if_delete(ifp); + if_delete(&ifp); } } @@ -1551,7 +1553,7 @@ static int lib_interface_destroy(enum nb_event event, ifp = nb_running_unset_entry(dnode); ifp->configured = false; - if_delete(ifp); + if_delete(&ifp); break; } |
