]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Convert zapi->interface_delete to ifp callback
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 19 Sep 2019 13:40:57 +0000 (09:40 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 19 Sep 2019 17:34:06 +0000 (13:34 -0400)
Convert the callback of the interface_delete to the new
ifp callback.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
31 files changed:
babeld/babel_interface.c
babeld/babel_zebra.c
bfdd/ptm_adapter.c
bgpd/bgp_zebra.c
eigrpd/eigrp_interface.c
eigrpd/eigrp_zebra.c
isisd/isis_circuit.c
isisd/isis_zebra.c
ldpd/ldp_zebra.c
lib/if.c
lib/if.h
lib/zclient.c
lib/zclient.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
ospf6d/ospf6_interface.c
ospf6d/ospf6_zebra.c
ospfd/ospf_interface.c
ospfd/ospf_interface.h
ospfd/ospf_zebra.c
ospfd/ospf_zebra.h
pbrd/pbr_zebra.c
pimd/pim_iface.c
pimd/pim_zebra.c
ripd/rip_interface.c
ripd/rip_zebra.c
ripngd/ripng_interface.c
ripngd/ripng_zebra.c
sharpd/sharp_zebra.c
staticd/static_zebra.c
vrrpd/vrrp_zebra.c

index 59d0651168f465721f99e8785f171cbe23dd243c..6e60300983afce073163d4850cb5061081ae33d0 100644 (file)
@@ -103,31 +103,18 @@ int babel_ifp_create (struct interface *ifp)
     debugf(BABEL_DEBUG_IF, "receive a 'interface add'");
 
     interface_recalculate(ifp);
-    
+
      return 0;
  }
 
 int
-babel_interface_delete (ZAPI_CALLBACK_ARGS)
+babel_ifp_destroy(struct interface *ifp)
 {
-    struct interface *ifp;
-    struct stream *s;
-
     debugf(BABEL_DEBUG_IF, "receive a 'interface delete'");
 
-    s = zclient->ibuf;
-    ifp = zebra_interface_state_read(s, vrf_id); /* it updates iflist */
-
-    if (ifp == NULL)
-        return 0;
-
     if (IS_ENABLE(ifp))
         interface_reset(ifp);
 
-    /* To support pseudo interface do not free interface structure.  */
-    /* if_delete(ifp); */
-    if_set_index(ifp, IFINDEX_INTERNAL);
-
     return 0;
 }
 
@@ -1250,11 +1237,6 @@ int babel_ifp_up(struct interface *ifp)
        return 0;
 }
 
-int babel_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void
 babel_if_init(void)
 {
index fd4e497b9a15b528e9f7632382fabb83f576318e..5a336df7b51295e34ca36fec5b784cec1f1e87f8 100644 (file)
@@ -240,7 +240,6 @@ void babelz_zebra_init(void)
     zclient_init(zclient, ZEBRA_ROUTE_BABEL, 0, &babeld_privs);
 
     zclient->zebra_connected = babel_zebra_connected;
-    zclient->interface_delete = babel_interface_delete;
     zclient->interface_address_add = babel_interface_address_add;
     zclient->interface_address_delete = babel_interface_address_delete;
     zclient->redistribute_route_add = babel_zebra_read_route;
index dc90b4d6e17060a1c708db8d70b4077554806704..1b3219c2351cd9306fb8293341207f9a03480213 100644 (file)
@@ -673,19 +673,10 @@ void bfdd_sessions_disable_vrf(struct vrf *vrf)
        }
 }
 
-static int bfdd_interface_update(ZAPI_CALLBACK_ARGS)
+static int bfd_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       /* Update interface information. */
-       ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-       if (ifp == NULL)
-               return 0;
-
        bfdd_sessions_disable_interface(ifp);
 
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -749,11 +740,6 @@ static int bfd_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int bfd_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv)
 {
        if_zapi_callbacks(bfd_ifp_create, NULL, NULL, bfd_ifp_destroy);
@@ -771,9 +757,6 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv)
        /* Send replay request on zebra connect. */
        zclient->zebra_connected = bfdd_zebra_connected;
 
-       /* Learn interfaces from zebra instead of the OS. */
-       zclient->interface_delete = bfdd_interface_update;
-
        /* Learn about interface VRF. */
        zclient->interface_vrf_update = bfdd_interface_vrf_update;
 
index 5efe1087e5e6e2773fecc9084a3f1c494d427464..de39e295ff05ac520168233b2627ae1a0de881b2 100644 (file)
@@ -202,28 +202,20 @@ static void bgp_nbr_connected_delete(struct bgp *bgp, struct nbr_connected *ifc,
        }
 }
 
-static int bgp_interface_delete(ZAPI_CALLBACK_ARGS)
+static int bgp_ifp_destroy(struct interface *ifp)
 {
-       struct stream *s;
-       struct interface *ifp;
        struct bgp *bgp;
 
-       bgp = bgp_lookup_by_vrf_id(vrf_id);
-
-       s = zclient->ibuf;
-       ifp = zebra_interface_state_read(s, vrf_id);
-       if (!ifp) /* This may happen if we've just unregistered for a VRF. */
-               return 0;
+       bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
 
        if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name);
+               zlog_debug("Rx Intf del VRF %u IF %s", bgp->vrf_id, ifp->name);
 
        if (bgp)
                bgp_update_interface_nbrs(bgp, ifp, NULL);
 
        bgp_mac_del_mac_entry(ifp);
 
-       if_set_index(ifp, IFINDEX_INTERNAL);
        return 0;
 }
 
@@ -2700,11 +2692,6 @@ static int bgp_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int bgp_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void bgp_zebra_init(struct thread_master *master, unsigned short instance)
 {
        zclient_num_connects = 0;
@@ -2717,7 +2704,6 @@ void bgp_zebra_init(struct thread_master *master, unsigned short instance)
        zclient_init(zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
        zclient->zebra_connected = bgp_zebra_connected;
        zclient->router_id_update = bgp_router_id_update;
-       zclient->interface_delete = bgp_interface_delete;
        zclient->interface_address_add = bgp_interface_address_add;
        zclient->interface_address_delete = bgp_interface_address_delete;
        zclient->interface_nbr_address_add = bgp_interface_nbr_address_add;
index 9c2ced9ea89d39a33e201649035fbc60589cdb1f..6294c0dd0fb0c59af252fccfdaa1ef095bc82dbf 100644 (file)
@@ -196,6 +196,19 @@ static int eigrp_ifp_down(struct interface *ifp)
 
 static int eigrp_ifp_destroy(struct interface *ifp)
 {
+       if (if_is_up(ifp))
+               zlog_warn("Zebra: got delete of %s, but interface is still up",
+                         ifp->name);
+
+       if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
+               zlog_debug(
+                       "Zebra: interface delete %s index %d flags %llx metric %d mtu %d",
+                       ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
+                       ifp->metric, ifp->mtu);
+
+       if (ifp->info)
+               eigrp_if_free(ifp->info, INTERFACE_DOWN_BY_ZEBRA);
+
        return 0;
 }
 
index 256906824251802effe0b0fc7e3a8751fc5b302a..9a0fdda0f927cc203051d0642db64f0914007f10 100644 (file)
@@ -53,7 +53,6 @@
 #include "eigrpd/eigrp_topology.h"
 #include "eigrpd/eigrp_fsm.h"
 
-static int eigrp_interface_delete(ZAPI_CALLBACK_ARGS);
 static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS);
 static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS);
 
@@ -109,7 +108,6 @@ void eigrp_zebra_init(void)
        zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs);
        zclient->zebra_connected = eigrp_zebra_connected;
        zclient->router_id_update = eigrp_router_id_update_zebra;
-       zclient->interface_delete = eigrp_interface_delete;
        zclient->interface_address_add = eigrp_interface_address_add;
        zclient->interface_address_delete = eigrp_interface_address_delete;
        zclient->redistribute_route_add = eigrp_zebra_read_route;
@@ -143,36 +141,6 @@ static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int eigrp_interface_delete(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read () updates interface structure in iflist
-        */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
-       if (if_is_up(ifp))
-               zlog_warn("Zebra: got delete of %s, but interface is still up",
-                         ifp->name);
-
-       if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
-               zlog_debug(
-                       "Zebra: interface delete %s index %d flags %llx metric %d mtu %d",
-                       ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
-                       ifp->metric, ifp->mtu);
-
-       if (ifp->info)
-               eigrp_if_free(ifp->info, INTERFACE_DOWN_BY_ZEBRA);
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-       return 0;
-}
-
 static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS)
 {
        struct connected *c;
index 153e7ec26200fe37147cf9987728c0000490a028..29fb725b047a8885a9788db346e1fa45646383ff 100644 (file)
@@ -1423,6 +1423,16 @@ static int isis_ifp_down(struct interface *ifp)
 
 static int isis_ifp_destroy(struct interface *ifp)
 {
+       if (if_is_operative(ifp))
+               zlog_warn("Zebra: got delete of %s, but interface is still up",
+                         ifp->name);
+
+       isis_csm_state_change(IF_DOWN_FROM_Z, circuit_scan_by_ifp(ifp), ifp);
+
+       /* Cannot call if_delete because we should retain the pseudo interface
+          in case there is configuration info attached to it. */
+       if_delete_retain(ifp);
+
        return 0;
 }
 
index 2299354b1eb90a737c08ba75836671cef551f08b..bdf6869f5cc5ccdb51bce334d689e50519c48446 100644 (file)
@@ -72,32 +72,6 @@ static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int isis_zebra_if_del(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (!ifp)
-               return 0;
-
-       if (if_is_operative(ifp))
-               zlog_warn("Zebra: got delete of %s, but interface is still up",
-                         ifp->name);
-
-       isis_csm_state_change(IF_DOWN_FROM_Z, circuit_scan_by_ifp(ifp), ifp);
-
-       /* Cannot call if_delete because we should retain the pseudo interface
-          in case there is configuration info attached to it. */
-       if_delete_retain(ifp);
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
-       return 0;
-}
-
 static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
 {
        struct connected *c;
@@ -339,7 +313,6 @@ void isis_zebra_init(struct thread_master *master)
        zclient_init(zclient, PROTO_TYPE, 0, &isisd_privs);
        zclient->zebra_connected = isis_zebra_connected;
        zclient->router_id_update = isis_router_id_update_zebra;
-       zclient->interface_delete = isis_zebra_if_del;
        zclient->interface_address_add = isis_zebra_if_address_add;
        zclient->interface_address_delete = isis_zebra_if_address_del;
        zclient->interface_link_params = isis_zebra_link_params;
index 37ecc0673c2a5129f1e5afbd5fc2a1f98c381e54..4df1fc0304b922dfe45dcc95f4b9a931f72037a5 100644 (file)
@@ -39,7 +39,6 @@ static void    ifc2kaddr(struct interface *, struct connected *,
                    struct kaddr *);
 static int      ldp_zebra_send_mpls_labels(int, struct kroute *);
 static int      ldp_router_id_update(ZAPI_CALLBACK_ARGS);
-static int      ldp_interface_delete(ZAPI_CALLBACK_ARGS);
 static int      ldp_interface_address_add(ZAPI_CALLBACK_ARGS);
 static int      ldp_interface_address_delete(ZAPI_CALLBACK_ARGS);
 static int      ldp_zebra_read_route(ZAPI_CALLBACK_ARGS);
@@ -276,23 +275,13 @@ ldp_ifp_create(struct interface *ifp)
 }
 
 static int
-ldp_interface_delete(ZAPI_CALLBACK_ARGS)
+ldp_ifp_destroy(struct interface *ifp)
 {
-       struct interface        *ifp;
        struct kif               kif;
 
-       /* zebra_interface_state_read() updates interface structure in iflist */
-       ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-       if (ifp == NULL)
-               return (0);
-
        debug_zebra_in("interface delete %s index %d mtu %d", ifp->name,
            ifp->ifindex, ifp->mtu);
 
-       /* To support pseudo interface do not free interface structure.  */
-       /* if_delete(ifp); */
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        ifp2kif(ifp, &kif);
        main_imsg_compose_both(IMSG_IFSTATUS, &kif, sizeof(kif));
 
@@ -529,11 +518,6 @@ ldp_zebra_connected(struct zclient *zclient)
 
 extern struct zebra_privs_t ldpd_privs;
 
-static int ldp_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void
 ldp_zebra_init(struct thread_master *master)
 {
@@ -547,7 +531,6 @@ ldp_zebra_init(struct thread_master *master)
        /* set callbacks */
        zclient->zebra_connected = ldp_zebra_connected;
        zclient->router_id_update = ldp_router_id_update;
-       zclient->interface_delete = ldp_interface_delete;
        zclient->interface_address_add = ldp_interface_address_add;
        zclient->interface_address_delete = ldp_interface_address_delete;
        zclient->redistribute_route_add = ldp_zebra_read_route;
index de9ec46fff03557d1b6c8f95bbd9f5402a1a332e..5a46a8026d03f5d2afd43246c115881591ba4ffa 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -181,6 +181,14 @@ void if_new_via_zapi(struct interface *ifp)
                (*ifp_master.create_hook)(ifp);
 }
 
+void if_destroy_via_zapi(struct interface *ifp)
+{
+       if (ifp_master.destroy_hook)
+               (*ifp_master.destroy_hook)(ifp);
+
+       if_set_index(ifp, IFINDEX_INTERNAL);
+}
+
 void if_up_via_zapi(struct interface *ifp)
 {
        if (ifp_master.up_hook)
index bd8eb0b661184c004a2918dcc26cee17a6a131e2..a3c6e9ff5bda7416ca4371e1e357071985037712 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -566,6 +566,7 @@ extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
 extern void if_new_via_zapi(struct interface *ifp);
 extern void if_up_via_zapi(struct interface *ifp);
 extern void if_down_via_zapi(struct interface *ifp);
+extern void if_destroy_via_zapi(struct interface *ifp);
 
 extern const struct frr_yang_module_info frr_interface_info;
 
index 0540b129b5a360bd230dd9ce1c8c32b4d5156b2e..6ba71eba49cea2e1431ffdc3429bf49f70091b29 100644 (file)
@@ -1592,6 +1592,20 @@ struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
        return ifp;
 }
 
+static void zclient_interface_delete(struct zclient *zclient, vrf_id_t vrf_id)
+{
+       struct interface *ifp;
+       struct stream *s = zclient->ibuf;
+
+       ifp = zebra_interface_state_read(s, vrf_id);
+
+       if (ifp == NULL)
+               return;
+
+       if_destroy_via_zapi(ifp);
+       return;
+}
+
 static void zclient_interface_up(struct zclient *zclient, vrf_id_t vrf_id)
 {
        struct interface *ifp;
@@ -2818,9 +2832,7 @@ static int zclient_read(struct thread *thread)
                zclient_interface_add(zclient, vrf_id);
                break;
        case ZEBRA_INTERFACE_DELETE:
-               if (zclient->interface_delete)
-                       (*zclient->interface_delete)(command, zclient, length,
-                                                    vrf_id);
+               zclient_interface_delete(zclient, vrf_id);
                break;
        case ZEBRA_INTERFACE_ADDRESS_ADD:
                if (zclient->interface_address_add)
index 890fa4aae20ddc9b1b6c5605b353f8ddf7b794e5..37f20a6bf0b050a26f1c473f0deffddacfcb49d8 100644 (file)
@@ -240,7 +240,6 @@ struct zclient {
        void (*zebra_connected)(struct zclient *);
        void (*zebra_capabilities)(struct zclient_capabilities *cap);
        int (*router_id_update)(ZAPI_CALLBACK_ARGS);
-       int (*interface_delete)(ZAPI_CALLBACK_ARGS);
        int (*interface_address_add)(ZAPI_CALLBACK_ARGS);
        int (*interface_address_delete)(ZAPI_CALLBACK_ARGS);
        int (*interface_link_params)(ZAPI_CALLBACK_ARGS);
index ecf4bd75042521cb58ba5147f6bb627a78867f03..e4f614c7c4f2690bba29b71a62e7e7b913c71b66 100644 (file)
@@ -307,22 +307,12 @@ int nhrp_ifp_create(struct interface *ifp)
        return 0;
 }
 
-int nhrp_interface_delete(ZAPI_CALLBACK_ARGS)
+int nhrp_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       ifp = zebra_interface_state_read(s, vrf_id);
-       if (ifp == NULL)
-               return 0;
-
        debugf(NHRP_DEBUG_IF, "if-delete: %s", ifp->name);
 
        nhrp_interface_update(ifp);
 
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -418,8 +408,3 @@ void nhrp_interface_set_source(struct interface *ifp, const char *ifname)
 
        nhrp_interface_update_nbma(ifp);
 }
-
-int nhrp_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
index 84bee5761dfc3df51b3415ec29696b43d4687db6..cfca86a9bf7897f60e527be99304c931f77deb20 100644 (file)
@@ -345,7 +345,6 @@ void nhrp_zebra_init(void)
 
        zclient = zclient_new(master, &zclient_options_default);
        zclient->zebra_connected = nhrp_zebra_connected;
-       zclient->interface_delete = nhrp_interface_delete;
        zclient->interface_address_add = nhrp_interface_address_add;
        zclient->interface_address_delete = nhrp_interface_address_delete;
        zclient->redistribute_route_add = nhrp_route_read;
index d4f3f25ac0459b4610074b48aa9bf6497ef24fc6..e62efc5a0d352098e5d3fff4e1cce772655a43d8 100644 (file)
@@ -1976,6 +1976,14 @@ static int ospf6_ifp_down(struct interface *ifp)
 
 static int ospf6_ifp_destroy(struct interface *ifp)
 {
+       if (if_is_up(ifp))
+               zlog_warn("Zebra: got delete of %s, but interface is still up",
+                         ifp->name);
+
+       if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+               zlog_debug("Zebra Interface delete: %s index %d mtu %d",
+                          ifp->name, ifp->ifindex, ifp->mtu6);
+
        return 0;
 }
 
index f2b86e136b81eef10fee8983d9e814b5dc7857ae..d8a6a39e1e9fd7de3faabc175580ed32c8cee0e0 100644 (file)
@@ -97,25 +97,6 @@ void ospf6_zebra_no_redistribute(int type)
                                        AFI_IP6, type, 0, VRF_DEFAULT);
 }
 
-static int ospf6_zebra_if_del(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-
-       if (!(ifp = zebra_interface_state_read(zclient->ibuf, vrf_id)))
-               return 0;
-
-       if (if_is_up(ifp))
-               zlog_warn("Zebra: got delete of %s, but interface is still up",
-                         ifp->name);
-
-       if (IS_OSPF6_DEBUG_ZEBRA(RECV))
-               zlog_debug("Zebra Interface delete: %s index %d mtu %d",
-                          ifp->name, ifp->ifindex, ifp->mtu6);
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-       return 0;
-}
-
 static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
 {
        struct connected *c;
@@ -551,7 +532,6 @@ void ospf6_zebra_init(struct thread_master *master)
        zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
        zclient->zebra_connected = ospf6_zebra_connected;
        zclient->router_id_update = ospf6_router_id_update_zebra;
-       zclient->interface_delete = ospf6_zebra_if_del;
        zclient->interface_address_add = ospf6_zebra_if_address_update_add;
        zclient->interface_address_delete =
                ospf6_zebra_if_address_update_delete;
index 75d6211f8da29ecb2ba14ef1a60fde38513e1469..3407d1bad145f97744e91f8d759ee65147ee8e8f 100644 (file)
@@ -51,6 +51,7 @@ DEFINE_QOBJ_TYPE(ospf_interface)
 DEFINE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd))
 DEFINE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd))
 DEFINE_HOOK(ospf_if_update, (struct interface * ifp), (ifp))
+DEFINE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
 
 int ospf_interface_neighbor_count(struct ospf_interface *oi)
 {
@@ -1323,6 +1324,21 @@ static int ospf_ifp_down(struct interface *ifp)
 
 static int ospf_ifp_destroy(struct interface *ifp)
 {
+       struct route_node *rn;
+
+       if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+               zlog_debug(
+                       "Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d",
+                       ifp->name, ospf_vrf_id_to_name(ifp->vrf_id),
+                       ifp->vrf_id, ifp->ifindex,
+                       (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
+
+       hook_call(ospf_if_delete, ifp);
+
+       for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn))
+               if (rn->info)
+                       ospf_if_free((struct ospf_interface *)rn->info);
+
        return 0;
 }
 
index f8350c48dd7f7a7d07009ec1c88234a2dade919e..cde52dbb9e3c21904692f09b45459a9e8c53f0ce 100644 (file)
@@ -327,4 +327,6 @@ DECLARE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd))
 DECLARE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd))
 
 DECLARE_HOOK(ospf_if_update, (struct interface * ifp), (ifp))
+DECLARE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
+
 #endif /* _ZEBRA_OSPF_INTERFACE_H */
index dc0501ec6ad8a1b06da49347dfc001784ae8eae5..5678d545ba354bc2056cc8cd26b9fcf674a292b3 100644 (file)
@@ -55,8 +55,6 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_EXTERNAL, "OSPF External route table")
 DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute")
 DEFINE_MTYPE_STATIC(OSPFD, OSPF_DIST_ARGS, "OSPF Distribute arguments")
 
-DEFINE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
-
 /* Zebra structure to hold current status. */
 struct zclient *zclient = NULL;
 
@@ -96,36 +94,6 @@ static int ospf_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int ospf_interface_delete(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct stream *s;
-       struct route_node *rn;
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read() updates interface structure in iflist */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
-       if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
-               zlog_debug(
-                       "Zebra: interface delete %s vrf %s[%u] index %d flags %llx metric %d mtu %d",
-                       ifp->name, ospf_vrf_id_to_name(ifp->vrf_id),
-                       ifp->vrf_id, ifp->ifindex,
-                       (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
-
-       hook_call(ospf_if_delete, ifp);
-
-       for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn))
-               if (rn->info)
-                       ospf_if_free((struct ospf_interface *)rn->info);
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-       return 0;
-}
-
 static int ospf_interface_address_add(ZAPI_CALLBACK_ARGS)
 {
        struct connected *c;
@@ -1392,7 +1360,6 @@ void ospf_zebra_init(struct thread_master *master, unsigned short instance)
        zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs);
        zclient->zebra_connected = ospf_zebra_connected;
        zclient->router_id_update = ospf_router_id_update_zebra;
-       zclient->interface_delete = ospf_interface_delete;
        zclient->interface_address_add = ospf_interface_address_add;
        zclient->interface_address_delete = ospf_interface_address_delete;
        zclient->interface_link_params = ospf_interface_link_params;
index 3622d91e0784492aec7f87b51e4398ada1d530dc..d3f8a0380bfbd2242a23f9e624a8e86f93deb65a 100644 (file)
@@ -87,6 +87,4 @@ extern void ospf_zebra_init(struct thread_master *, unsigned short);
 extern void ospf_zebra_vrf_register(struct ospf *ospf);
 extern void ospf_zebra_vrf_deregister(struct ospf *ospf);
 
-DECLARE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
-
 #endif /* _ZEBRA_OSPF_ZEBRA_H */
index eadc39264cb46ccd2c45a1fd6a5b5648f32d8c14..2bba837389f23aa71d1ceed87e468d5516c8f501 100644 (file)
@@ -72,24 +72,11 @@ int pbr_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int interface_delete(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read () updates interface structure in iflist
-        */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        DEBUGD(&pbr_dbg_zebra,
               "%s: %s", __PRETTY_FUNCTION__, ifp->name);
 
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -432,7 +419,6 @@ void pbr_zebra_init(void)
 
        zclient_init(zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs);
        zclient->zebra_connected = zebra_connected;
-       zclient->interface_delete = interface_delete;
        zclient->interface_address_add = interface_address_add;
        zclient->interface_address_delete = interface_address_delete;
        zclient->route_notify_owner = route_notify_owner;
@@ -561,8 +547,3 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,
 
        zclient_send_message(zclient);
 }
-
-int pbr_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
index 5ed5abf0325597c22208cfdbbd2e3aee70019df6..bc8dedc4f6f01bf5cf8722672ea5535133f6aac8 100644 (file)
@@ -1673,5 +1673,22 @@ int pim_ifp_down(struct interface *ifp)
 
 int pim_ifp_destroy(struct interface *ifp)
 {
+       struct pim_instance *pim;
+
+       if (PIM_DEBUG_ZEBRA) {
+               zlog_debug(
+                       "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d",
+                       __PRETTY_FUNCTION__, ifp->name, ifp->ifindex,
+                       ifp->vrf_id, (long)ifp->flags, ifp->metric, ifp->mtu,
+                       if_is_operative(ifp));
+       }
+
+       if (!if_is_operative(ifp))
+               pim_if_addr_del_all(ifp);
+
+       pim = pim_get_pim_instance(ifp->vrf_id);
+       if (pim && pim->vxlan.term_if == ifp)
+               pim_vxlan_del_term_dev(pim);
+
        return 0;
 }
index 1287465588719da95f6a140dd6ca892a0e6511b9..db0aedad6aa155f6cd38e1d9bb73020e65d813fc 100644 (file)
@@ -63,35 +63,6 @@ static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int pim_zebra_if_del(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct pim_instance *pim;
-
-       ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-       if (!ifp)
-               return 0;
-
-       if (PIM_DEBUG_ZEBRA) {
-               zlog_debug(
-                       "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d",
-                       __PRETTY_FUNCTION__, ifp->name, ifp->ifindex, vrf_id,
-                       (long)ifp->flags, ifp->metric, ifp->mtu,
-                       if_is_operative(ifp));
-       }
-
-       if (!if_is_operative(ifp))
-               pim_if_addr_del_all(ifp);
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
-       pim = pim_get_pim_instance(vrf_id);
-       if (pim && pim->vxlan.term_if == ifp)
-               pim_vxlan_del_term_dev(pim);
-
-       return 0;
-}
-
 static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
@@ -610,7 +581,6 @@ void pim_zebra_init(void)
        zclient->zebra_capabilities = pim_zebra_capabilities;
        zclient->zebra_connected = pim_zebra_connected;
        zclient->router_id_update = pim_router_id_update_zebra;
-       zclient->interface_delete = pim_zebra_if_del;
        zclient->interface_address_add = pim_zebra_if_address_add;
        zclient->interface_address_delete = pim_zebra_if_address_del;
        zclient->interface_vrf_update = pim_zebra_interface_vrf_update;
index 13b9b874e3808f17da6d5f0939ad961436936b4c..3173277ba7553fd449a90b91ea24fa6db090a781 100644 (file)
@@ -411,19 +411,8 @@ static int rip_ifp_create(struct interface *ifp)
        return 0;
 }
 
-int rip_interface_delete(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read() updates interface structure in iflist */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        rip_interface_sync(ifp);
        if (if_is_up(ifp)) {
                rip_if_down(ifp);
@@ -434,10 +423,6 @@ int rip_interface_delete(ZAPI_CALLBACK_ARGS)
                ifp->name, ifp->vrf_id, ifp->ifindex,
                (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
 
-       /* To support pseudo interface do not free interface structure.  */
-       /* if_delete(ifp); */
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -1229,11 +1214,6 @@ static int rip_interface_delete_hook(struct interface *ifp)
        return 0;
 }
 
-static int rip_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 /* Allocate and initialize interface vector. */
 void rip_if_init(void)
 {
index 7b57fc79f8a8053c040c6324fb64cd74e65d4a88..90ee667f05a104d0a624ed6c1f7d8d20bb192285 100644 (file)
@@ -238,7 +238,6 @@ void rip_zclient_init(struct thread_master *master)
        zclient = zclient_new(master, &zclient_options_default);
        zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs);
        zclient->zebra_connected = rip_zebra_connected;
-       zclient->interface_delete = rip_interface_delete;
        zclient->interface_address_add = rip_interface_address_add;
        zclient->interface_address_delete = rip_interface_address_delete;
        zclient->interface_vrf_update = rip_interface_vrf_update;
index 4f238f179ce9f5ba4df2078a7f4fe076e81a4582..a132f723edb3c2bbf835cb585582efffb69bfea1 100644 (file)
@@ -256,19 +256,8 @@ static int ripng_ifp_create(struct interface *ifp)
        return 0;
 }
 
-int ripng_interface_delete(ZAPI_CALLBACK_ARGS)
+static int ripng_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       /*  zebra_interface_state_read() updates interface structure in iflist
-        */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        ripng_interface_sync(ifp);
        if (if_is_up(ifp)) {
                ripng_if_down(ifp);
@@ -279,10 +268,6 @@ int ripng_interface_delete(ZAPI_CALLBACK_ARGS)
                ifp->name, ifp->vrf_id, ifp->ifindex,
                (unsigned long long)ifp->flags, ifp->metric, ifp->mtu6);
 
-       /* To support pseudo interface do not free interface structure.  */
-       /* if_delete(ifp); */
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -964,11 +949,6 @@ static struct cmd_node interface_node = {
        INTERFACE_NODE, "%s(config-if)# ", 1 /* VTYSH */
 };
 
-static int ripng_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 /* Initialization of interface. */
 void ripng_if_init(void)
 {
index 227777681ceb0549f23cfb596fe858822c112b45..fa61d69caae5863a16c63961928982dfdc843cc2 100644 (file)
@@ -242,7 +242,6 @@ void zebra_init(struct thread_master *master)
        zclient_init(zclient, ZEBRA_ROUTE_RIPNG, 0, &ripngd_privs);
 
        zclient->zebra_connected = ripng_zebra_connected;
-       zclient->interface_delete = ripng_interface_delete;
        zclient->interface_address_add = ripng_interface_address_add;
        zclient->interface_address_delete = ripng_interface_address_delete;
        zclient->interface_vrf_update = ripng_interface_vrf_update;
index 5991b84c6f70d8b5058c579affe877ca47a3785a..14220830c2394be0c4b14b6f579fa185246419f9 100644 (file)
@@ -52,27 +52,13 @@ static int sharp_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int interface_delete(ZAPI_CALLBACK_ARGS)
+static int sharp_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read () updates interface structure in iflist
-        */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
 static int interface_address_add(ZAPI_CALLBACK_ARGS)
 {
-
        zebra_interface_address_read(cmd, zclient->ibuf, vrf_id);
 
        return 0;
@@ -368,11 +354,6 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int sharp_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 extern struct zebra_privs_t sharp_privs;
 
 void sharp_zebra_init(void)
@@ -386,7 +367,6 @@ void sharp_zebra_init(void)
 
        zclient_init(zclient, ZEBRA_ROUTE_SHARP, 0, &sharp_privs);
        zclient->zebra_connected = zebra_connected;
-       zclient->interface_delete = interface_delete;
        zclient->interface_address_add = interface_address_add;
        zclient->interface_address_delete = interface_address_delete;
        zclient->route_notify_owner = route_notify_owner;
index c494cf6cce8adf20d0ed91376bbd679442cab1e4..b364dd62900f0a6d95d232eeff21bd3c4ff9c1c3 100644 (file)
@@ -57,21 +57,8 @@ static int static_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int interface_delete(ZAPI_CALLBACK_ARGS)
+static int static_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read () updates interface structure in iflist
-        */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        static_ifindex_update(ifp, false);
        return 0;
 }
@@ -476,11 +463,6 @@ extern void static_zebra_route_add(struct route_node *rn,
                           zclient, &api);
 }
 
-static int static_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void static_zebra_init(void)
 {
        struct zclient_options opt = { .receive_notify = true };
@@ -493,7 +475,6 @@ void static_zebra_init(void)
        zclient_init(zclient, ZEBRA_ROUTE_STATIC, 0, &static_privs);
        zclient->zebra_capabilities = static_zebra_capabilities;
        zclient->zebra_connected = zebra_connected;
-       zclient->interface_delete = interface_delete;
        zclient->interface_address_add = interface_address_add;
        zclient->interface_address_delete = interface_address_delete;
        zclient->route_notify_owner = route_notify_owner;
index 4678a233312ca88e7b1244b8eebfe4a731d5edfc..a6c575f8da4426102dc1195af3fad85661f35c4f 100644 (file)
@@ -89,22 +89,12 @@ int vrrp_ifp_create(struct interface *ifp)
        return 0;
 }
 
-static int vrrp_zebra_if_del(int command, struct zclient *zclient,
-                            zebra_size_t length, vrf_id_t vrf_id)
+int vrrp_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-
-       if (!ifp)
-               return 0;
-
-       vrrp_zebra_debug_if_state(ifp, vrf_id, __func__);
+       vrrp_zebra_debug_if_state(ifp, ifp->vrf_id, __func__);
 
        vrrp_if_del(ifp);
 
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -199,11 +189,6 @@ int vrrp_zclient_send_interface_protodown(struct interface *ifp, bool down)
                                                down);
 }
 
-int vrrp_ifp_destroy(struct interface *ifp)
-{
-       return 0;
-}
-
 void vrrp_zebra_init(void)
 {
        if_zapi_callbacks(vrrp_ifp_create, vrrp_ifp_up,
@@ -214,7 +199,6 @@ void vrrp_zebra_init(void)
 
        zclient->zebra_connected = vrrp_zebra_connected;
        zclient->router_id_update = vrrp_router_id_update_zebra;
-       zclient->interface_delete = vrrp_zebra_if_del;
        zclient->interface_address_add = vrrp_zebra_if_address_add;
        zclient->interface_address_delete = vrrp_zebra_if_address_del;