]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib, ospfd, zebra: Convert interface_delete to take double pointer
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 30 Oct 2019 00:24:10 +0000 (20:24 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 2 Nov 2019 20:13:44 +0000 (16:13 -0400)
When free'ing the interface pointer, set it to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/if.c
lib/if.h
ospfd/ospf_interface.c
zebra/interface.c

index e61bf00283b59871a76b943239defec331e97e1e..9d0f13ecbda47ed7f62719db79b15aed4d48b21b 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -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;
        }
 
index 6d966a25564afe61bb3f1427ed8340d134170ce7..4ca2e795724a31bac78cc5edbe275bf459d86914 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -513,7 +513,7 @@ extern void if_delete_retain(struct interface *);
 
 /* Delete and free the interface structure: calls if_delete_retain and then
    deletes it from the interface list and frees the structure. */
-extern void if_delete(struct interface *);
+extern void if_delete(struct interface **ifp);
 
 extern int if_is_up(const struct interface *ifp);
 extern int if_is_running(const struct interface *ifp);
index 1f5e0da9440f84494913e9799b8a17506cb5887b..5459e3b87c5d4ed87b298eed2cd2398b5fae42a6 100644 (file)
@@ -902,11 +902,10 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
 
 static void ospf_vl_if_delete(struct ospf_vl_data *vl_data)
 {
-       struct interface *ifp = vl_data->vl_oi->ifp;
        vl_data->vl_oi->address->u.prefix4.s_addr = 0;
        vl_data->vl_oi->address->prefixlen = 0;
        ospf_if_free(vl_data->vl_oi);
-       if_delete(ifp);
+       if_delete(&vl_data->vl_oi->ifp);
        vlink_count--;
 }
 
index 5871b8746f1eef6eca6a1038cac07b3b11908de5..eea80652e57957e6e2d2a7b2067b0a722721e1f7 100644 (file)
@@ -829,7 +829,7 @@ void if_delete_update(struct interface *ifp)
                if (IS_ZEBRA_DEBUG_KERNEL)
                        zlog_debug("interface %s is being deleted from the system",
                                   ifp->name);
-               if_delete(ifp);
+               if_delete(&ifp);
        }
 }