]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: Switch all zclient->interface_add to interface create callback
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 19 Sep 2019 02:26:55 +0000 (22:26 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 19 Sep 2019 17:34:06 +0000 (13:34 -0400)
Switch the zclient->interface_add functionality to have everyone
use the interface create callback in lib/if.c

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
34 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_circuit.h
isisd/isis_zebra.c
isisd/isis_zebra.h
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
ospfd/ospfd.c
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 898848f84e00b5c956372a34e5e5ed9da4548e91..a0df6d9e1f22b927d6c84a99aab144087c4d56a3 100644 (file)
@@ -104,23 +104,14 @@ babel_interface_down (ZAPI_CALLBACK_ARGS)
     return 0;
 }
 
-int
-babel_interface_add (ZAPI_CALLBACK_ARGS)
+int babel_ifp_create (struct interface *ifp)
 {
-    struct interface *ifp = NULL;
-
     debugf(BABEL_DEBUG_IF, "receive a 'interface add'");
 
-    /* read and add the interface in the iflist. */
-    ifp = zebra_interface_add_read (zclient->ibuf, vrf_id);
-
-    if (ifp == NULL) {
-        return 0;
-    }
-
     interface_recalculate(ifp);
-    return 0;
-}
+    
+     return 0;
+ }
 
 int
 babel_interface_delete (ZAPI_CALLBACK_ARGS)
@@ -1260,11 +1251,6 @@ DEFUN (show_babel_parameters,
     return CMD_SUCCESS;
 }
 
-int babel_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 int babel_ifp_up(struct interface *ifp)
 {
        return 0;
index d70823544af27b9565da1c00ea3062614f21df19..3b58db7f27fb279f11065c88f17c7d15a9496600 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_add = babel_interface_add;
     zclient->interface_delete = babel_interface_delete;
     zclient->interface_up = babel_interface_up;
     zclient->interface_down = babel_interface_down;
index 2d1b17ce4a62d17abeb7888d0deb01b6cb40504d..dc90b4d6e17060a1c708db8d70b4077554806704 100644 (file)
@@ -677,20 +677,6 @@ static int bfdd_interface_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
 
-       /*
-        * `zebra_interface_add_read` will handle the interface creation
-        * on `lib/if.c`. We'll use that data structure instead of
-        * rolling our own.
-        */
-       if (cmd == ZEBRA_INTERFACE_ADD) {
-               ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-               if (ifp == NULL)
-                       return 0;
-
-               bfdd_sessions_enable_interface(ifp);
-               return 0;
-       }
-
        /* Update interface information. */
        ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
        if (ifp == NULL)
@@ -758,6 +744,8 @@ static int bfdd_interface_address_update(ZAPI_CALLBACK_ARGS)
 
 static int bfd_ifp_create(struct interface *ifp)
 {
+       bfdd_sessions_enable_interface(ifp);
+
        return 0;
 }
 
@@ -784,7 +772,6 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv)
        zclient->zebra_connected = bfdd_zebra_connected;
 
        /* Learn interfaces from zebra instead of the OS. */
-       zclient->interface_add = bfdd_interface_update;
        zclient->interface_delete = bfdd_interface_update;
 
        /* Learn about interface VRF. */
index ee523e51cbfae825f5e0b1a803bd13d336f21a54..3477b9491737e927a2ccb0eabce062bbeef95363 100644 (file)
@@ -202,29 +202,6 @@ static void bgp_nbr_connected_delete(struct bgp *bgp, struct nbr_connected *ifc,
        }
 }
 
-/* Inteface addition message from zebra. */
-static int bgp_interface_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct bgp *bgp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-       if (!ifp) // unexpected
-               return 0;
-
-       if (BGP_DEBUG(zebra, ZEBRA) && ifp)
-               zlog_debug("Rx Intf add VRF %u IF %s", vrf_id, ifp->name);
-
-       bgp = bgp_lookup_by_vrf_id(vrf_id);
-       if (!bgp)
-               return 0;
-
-       bgp_mac_add_mac_entry(ifp);
-
-       bgp_update_interface_nbrs(bgp, ifp, ifp);
-       return 0;
-}
-
 static int bgp_interface_delete(ZAPI_CALLBACK_ARGS)
 {
        struct stream *s;
@@ -2723,6 +2700,18 @@ extern struct zebra_privs_t bgpd_privs;
 
 static int bgp_ifp_create(struct interface *ifp)
 {
+       struct bgp *bgp;
+
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("Rx Intf add VRF %u IF %s", ifp->vrf_id, ifp->name);
+
+       bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
+       if (!bgp)
+               return 0;
+
+       bgp_mac_add_mac_entry(ifp);
+
+       bgp_update_interface_nbrs(bgp, ifp, ifp);
        return 0;
 }
 
@@ -2753,7 +2742,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_add = bgp_interface_add;
        zclient->interface_delete = bgp_interface_delete;
        zclient->interface_address_add = bgp_interface_address_add;
        zclient->interface_address_delete = bgp_interface_address_delete;
index 76e101b0101ecb9ac2bd85fb3456dbf6c495e930..f2faf22e80e19f3e9afe23a23313d598fe26f9f1 100644 (file)
@@ -124,6 +124,15 @@ int eigrp_if_delete_hook(struct interface *ifp)
 
 static int eigrp_ifp_create(struct interface *ifp)
 {
+       struct eigrp_interface *ei = ifp->info;
+
+       if (!ei)
+               return 0;
+
+       ei->params.type = eigrp_default_iftype(ifp);
+
+       eigrp_if_update(ifp);
+
        return 0;
 }
 
index 63cbe84ef21ea4558a0880fe476715085d376e55..8c8f73b5b03ff06bb79f682c1f0d9c14c945c5c2 100644 (file)
@@ -53,7 +53,6 @@
 #include "eigrpd/eigrp_topology.h"
 #include "eigrpd/eigrp_fsm.h"
 
-static int eigrp_interface_add(ZAPI_CALLBACK_ARGS);
 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);
@@ -114,7 +113,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_add = eigrp_interface_add;
        zclient->interface_delete = eigrp_interface_delete;
        zclient->interface_up = eigrp_interface_state_up;
        zclient->interface_down = eigrp_interface_state_down;
@@ -151,26 +149,6 @@ static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-/* Inteface addition message from zebra. */
-static int eigrp_interface_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct eigrp_interface *ei;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
-       if (!ifp->info)
-               return 0;
-
-       ei = ifp->info;
-
-       ei->params.type = eigrp_default_iftype(ifp);
-
-       eigrp_if_update(ifp);
-
-       return 0;
-}
-
 static int eigrp_interface_delete(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
index 64ec047054300789b54709e7b1e385ae79c4cc85..c78554e5e97327978426f046bdff85f0eaaebe3b 100644 (file)
@@ -61,6 +61,8 @@
 
 DEFINE_QOBJ_TYPE(isis_circuit)
 
+DEFINE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp))
+
 /*
  * Prototypes.
  */
@@ -1391,6 +1393,12 @@ int isis_if_delete_hook(struct interface *ifp)
 
 static int isis_ifp_create(struct interface *ifp)
 {
+       if (if_is_operative(ifp))
+               isis_csm_state_change(IF_UP_FROM_Z, circuit_scan_by_ifp(ifp),
+                                     ifp);
+
+       hook_call(isis_if_new_hook, ifp);
+
        return 0;
 }
 
index e3541644aa9052ec5d4a86f8da37406b7edb6840..e834e31600c809f562a780b63f2701b406a2385f 100644 (file)
@@ -32,6 +32,8 @@
 #include "isis_constants.h"
 #include "isis_common.h"
 
+DECLARE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp));
+
 struct isis_lsp;
 
 struct password {
index 39a2f6ef3502de674fe85e87cd8801c05ca863bd..ea4622db3140014592c49ef479a7b0fea7e88f74 100644 (file)
@@ -53,8 +53,6 @@
 
 struct zclient *zclient = NULL;
 
-DEFINE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp))
-
 /* Router-id update message from zebra. */
 static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
 {
@@ -74,21 +72,6 @@ static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int isis_zebra_if_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
-       if (if_is_operative(ifp))
-               isis_csm_state_change(IF_UP_FROM_Z, circuit_scan_by_ifp(ifp),
-                                     ifp);
-
-       hook_call(isis_if_new_hook, ifp);
-
-       return 0;
-}
-
 static int isis_zebra_if_del(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
@@ -388,7 +371,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_add = isis_zebra_if_add;
        zclient->interface_delete = isis_zebra_if_del;
        zclient->interface_up = isis_zebra_if_state_up;
        zclient->interface_down = isis_zebra_if_state_down;
index 83a32108eb13c74b642cc585b58b888df2845d5b..d00f348c8e310da35360982c01d412c15608ee2d 100644 (file)
@@ -24,8 +24,6 @@
 
 extern struct zclient *zclient;
 
-DECLARE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp));
-
 void isis_zebra_init(struct thread_master *);
 void isis_zebra_stop(void);
 
index 251df738889c49f6bfc73acaf6367b0d6ec55542..d24079f41a1c217ac1789dbaebd7b8cd24d7f79a 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_add(ZAPI_CALLBACK_ARGS);
 static int      ldp_interface_delete(ZAPI_CALLBACK_ARGS);
 static int      ldp_interface_status_change(ZAPI_CALLBACK_ARGS);
 static int      ldp_interface_address_add(ZAPI_CALLBACK_ARGS);
@@ -264,19 +263,17 @@ ldp_router_id_update(ZAPI_CALLBACK_ARGS)
 }
 
 static int
-ldp_interface_add(ZAPI_CALLBACK_ARGS)
+ldp_ifp_create(struct interface *ifp)
 {
-       struct interface        *ifp;
        struct kif               kif;
 
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
        debug_zebra_in("interface add %s index %d mtu %d", ifp->name,
            ifp->ifindex, ifp->mtu);
 
        ifp2kif(ifp, &kif);
        main_imsg_compose_both(IMSG_IFSTATUS, &kif, sizeof(kif));
 
-       return (0);
+       return 0;
 }
 
 static int
@@ -532,11 +529,6 @@ ldp_zebra_connected(struct zclient *zclient)
 
 extern struct zebra_privs_t ldpd_privs;
 
-static int ldp_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 static int ldp_ifp_up(struct interface *ifp)
 {
        return 0;
@@ -565,7 +557,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_add = ldp_interface_add;
        zclient->interface_delete = ldp_interface_delete;
        zclient->interface_up = ldp_interface_status_change;
        zclient->interface_down = ldp_interface_status_change;
index 9d316856da5542fedcb0964d6d153d12d741dd30..8d68e1958eeaadef5468e40d0bb0babc85768e9e 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -175,6 +175,12 @@ static struct interface *if_create_backend(const char *name, ifindex_t ifindex,
        return ifp;
 }
 
+void if_new_via_zapi(struct interface *ifp)
+{
+       if (ifp_master.create_hook)
+               (*ifp_master.create_hook)(ifp);
+}
+
 struct interface *if_create(const char *name, vrf_id_t vrf_id)
 {
        return if_create_backend(name, IFINDEX_INTERNAL, vrf_id);
index ce79a3a46389c1b826f5173269051a2f4244333c..0261f03f78a4011998b9f7d1b82798c5e674cf94 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -563,6 +563,8 @@ extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
                              int (*down)(struct interface *ifp),
                              int (*destroy)(struct interface *ifp));
 
+extern void if_new_via_zapi(struct interface *ifp);
+
 extern const struct frr_yang_module_info frr_interface_info;
 
 #ifdef __cplusplus
index 92a495ac61719954ac1f1e6c799104e27d23b0f8..ea151be53a04ec4af56c4ac1e767122e3d800603 100644 (file)
@@ -1547,10 +1547,11 @@ static void zclient_vrf_delete(struct zclient *zclient, vrf_id_t vrf_id)
        vrf_delete(vrf);
 }
 
-struct interface *zebra_interface_add_read(struct stream *s, vrf_id_t vrf_id)
+static void zclient_interface_add(struct zclient *zclient, vrf_id_t vrf_id)
 {
        struct interface *ifp;
        char ifname_tmp[INTERFACE_NAMSIZ];
+       struct stream *s = zclient->ibuf;
 
        /* Read interface name. */
        stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
@@ -1560,15 +1561,14 @@ struct interface *zebra_interface_add_read(struct stream *s, vrf_id_t vrf_id)
 
        zebra_interface_if_set_value(s, ifp);
 
-       return ifp;
+       if_new_via_zapi(ifp);
 }
 
 /*
  * Read interface up/down msg (ZEBRA_INTERFACE_UP/ZEBRA_INTERFACE_DOWN)
  * from zebra server.  The format of this message is the same as
- * that sent for ZEBRA_INTERFACE_ADD/ZEBRA_INTERFACE_DELETE (see
- * comments for zebra_interface_add_read), except that no sockaddr_dl
- * is sent at the tail of the message.
+ * that sent for ZEBRA_INTERFACE_ADD/ZEBRA_INTERFACE_DELETE,
+ * except that no sockaddr_dl is sent at the tail of the message.
  */
 struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
 {
@@ -2789,9 +2789,7 @@ static int zclient_read(struct thread *thread)
                zclient_vrf_delete(zclient, vrf_id);
                break;
        case ZEBRA_INTERFACE_ADD:
-               if (zclient->interface_add)
-                       (*zclient->interface_add)(command, zclient, length,
-                                                 vrf_id);
+               zclient_interface_add(zclient, vrf_id);
                break;
        case ZEBRA_INTERFACE_DELETE:
                if (zclient->interface_delete)
index eb3c97b111c4912f1da7d0b48bbe90b8d8c98a21..9361b56c31ec0791ce22eac60a9892a866b7d4bf 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_add)(ZAPI_CALLBACK_ARGS);
        int (*interface_delete)(ZAPI_CALLBACK_ARGS);
        int (*interface_up)(ZAPI_CALLBACK_ARGS);
        int (*interface_down)(ZAPI_CALLBACK_ARGS);
@@ -617,7 +616,6 @@ extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
 extern void zclient_interface_set_master(struct zclient *client,
                                         struct interface *master,
                                         struct interface *slave);
-extern struct interface *zebra_interface_add_read(struct stream *, vrf_id_t);
 extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
 extern struct connected *zebra_interface_address_read(int, struct stream *,
                                                      vrf_id_t);
index 31e19eda3ed383b141d8dafc42643133eb70279d..5d47d0ae8aad7c1fbadbdcc9a9f93350875e1715 100644 (file)
@@ -296,15 +296,8 @@ void nhrp_interface_update(struct interface *ifp)
        }
 }
 
-int nhrp_interface_add(ZAPI_CALLBACK_ARGS)
+int nhrp_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       /* read and add the interface in the iflist. */
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-       if (ifp == NULL)
-               return 0;
-
        debugf(NHRP_DEBUG_IF, "if-add: %s, ifindex: %u, hw_type: %d %s",
               ifp->name, ifp->ifindex, ifp->ll_type,
               if_link_type_str(ifp->ll_type));
@@ -437,11 +430,6 @@ void nhrp_interface_set_source(struct interface *ifp, const char *ifname)
        nhrp_interface_update_nbma(ifp);
 }
 
-int nhrp_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 int nhrp_ifp_up(struct interface *ifp)
 {
        return 0;
index a788eb2efb0f3a06a34b0ca6a4a2841a414f4f34..3d0bd780408762859cb0b1e254607950f06b56aa 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_add = nhrp_interface_add;
        zclient->interface_delete = nhrp_interface_delete;
        zclient->interface_up = nhrp_interface_up;
        zclient->interface_down = nhrp_interface_down;
index 50e9f80cc21d167105e793430c3f1260aec5fced..ca0e945186084da082abfc00097f56fa8137c46a 100644 (file)
@@ -42,6 +42,7 @@
 #include "ospf6_spf.h"
 #include "ospf6d.h"
 #include "ospf6_bfd.h"
+#include "ospf6_zebra.h"
 
 DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names")
 DEFINE_QOBJ_TYPE(ospf6_interface)
@@ -1937,6 +1938,11 @@ static struct cmd_node interface_node = {
 
 static int ospf6_ifp_create(struct interface *ifp)
 {
+       if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+               zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
+                          ifp->ifindex, ifp->mtu6);
+       ospf6_interface_if_add(ifp);
+
        return 0;
 }
 
index 8454016b2e0ed111c79b58a7e69e3953fa948416..d809cff6c5d850ab9d6266d5e3b7bb2f5f42c9fe 100644 (file)
@@ -97,19 +97,6 @@ void ospf6_zebra_no_redistribute(int type)
                                        AFI_IP6, type, 0, VRF_DEFAULT);
 }
 
-/* Inteface addition message from zebra. */
-static int ospf6_zebra_if_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-       if (IS_OSPF6_DEBUG_ZEBRA(RECV))
-               zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
-                          ifp->ifindex, ifp->mtu6);
-       ospf6_interface_if_add(ifp);
-       return 0;
-}
-
 static int ospf6_zebra_if_del(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
@@ -583,7 +570,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_add = ospf6_zebra_if_add;
        zclient->interface_delete = ospf6_zebra_if_del;
        zclient->interface_up = ospf6_zebra_if_state_update;
        zclient->interface_down = ospf6_zebra_if_state_update;
index 3324740d59464f18d294e2f40baed1536c57693f..c132a344788e281c3d5b71c3b0690f0ccba10680 100644 (file)
@@ -50,6 +50,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))
 
 int ospf_interface_neighbor_count(struct ospf_interface *oi)
 {
@@ -1218,8 +1219,41 @@ uint8_t ospf_default_iftype(struct interface *ifp)
                return OSPF_IFTYPE_BROADCAST;
 }
 
+void ospf_if_interface(struct interface *ifp)
+{
+       hook_call(ospf_if_update, ifp);
+}
+
 static int ospf_ifp_create(struct interface *ifp)
 {
+       struct ospf *ospf = NULL;
+
+       if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
+               zlog_debug(
+                       "Zebra: interface add %s vrf %s[%u] index %d flags %llx metric %d mtu %d speed %u",
+                       ifp->name, ospf_vrf_id_to_name(ifp->vrf_id),
+                       ifp->vrf_id, ifp->ifindex,
+                       (unsigned long long)ifp->flags, ifp->metric, ifp->mtu,
+                       ifp->speed);
+
+       assert(ifp->info);
+
+       if (IF_DEF_PARAMS(ifp)
+           && !OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
+               SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
+               IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
+       }
+
+       ospf = ospf_lookup_by_vrf_id(ifp->vrf_id);
+       if (!ospf)
+               return 0;
+
+       ospf_if_recalculate_output_cost(ifp);
+
+       ospf_if_update(ospf, ifp);
+
+       hook_call(ospf_if_update, ifp);
+
        return 0;
 }
 
index 0c903954d321b2aab78d3bd63085e7d933e967de..f8350c48dd7f7a7d07009ec1c88234a2dade919e 100644 (file)
@@ -321,7 +321,10 @@ extern int ospf_interface_neighbor_count(struct ospf_interface *oi);
    state of the interface. */
 extern void ospf_if_set_multicast(struct ospf_interface *);
 
+extern void ospf_if_interface(struct interface *ifp);
+
 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))
 #endif /* _ZEBRA_OSPF_INTERFACE_H */
index b478832d848284d20828727523fd2cc24dce13c8..62c7cdd446301c4f9d7e8811d669b9094dd03100 100644 (file)
@@ -55,7 +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_update, (struct interface * ifp), (ifp))
 DEFINE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
 
 /* Zebra structure to hold current status. */
@@ -97,45 +96,6 @@ static int ospf_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-/* Inteface addition message from zebra. */
-static int ospf_interface_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp = NULL;
-       struct ospf *ospf = NULL;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-       if (ifp == NULL)
-               return 0;
-
-       if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE))
-               zlog_debug(
-                       "Zebra: interface add %s vrf %s[%u] index %d flags %llx metric %d mtu %d speed %u",
-                       ifp->name, ospf_vrf_id_to_name(ifp->vrf_id),
-                       ifp->vrf_id, ifp->ifindex,
-                       (unsigned long long)ifp->flags, ifp->metric, ifp->mtu,
-                       ifp->speed);
-
-       assert(ifp->info);
-
-       if (IF_DEF_PARAMS(ifp)
-           && !OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type)) {
-               SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
-               IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
-       }
-
-       ospf = ospf_lookup_by_vrf_id(vrf_id);
-       if (!ospf)
-               return 0;
-
-       ospf_if_recalculate_output_cost(ifp);
-
-       ospf_if_update(ospf, ifp);
-
-       hook_call(ospf_if_update, ifp);
-
-       return 0;
-}
-
 static int ospf_interface_delete(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
@@ -283,7 +243,7 @@ static int ospf_interface_address_add(ZAPI_CALLBACK_ARGS)
 
        ospf_if_update(ospf, c->ifp);
 
-       hook_call(ospf_if_update, c->ifp);
+       ospf_if_interface(c->ifp);
 
        return 0;
 }
@@ -325,7 +285,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
        /* Call interface hook functions to clean up */
        ospf_if_free(oi);
 
-       hook_call(ospf_if_update, c->ifp);
+       ospf_if_interface(c->ifp);
 
        connected_free(c);
 
@@ -1524,7 +1484,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_add = ospf_interface_add;
        zclient->interface_delete = ospf_interface_delete;
        zclient->interface_up = ospf_interface_state_up;
        zclient->interface_down = ospf_interface_state_down;
index 673730653226f6e300ca97f481f41a7a9c21b6ef..3622d91e0784492aec7f87b51e4398ada1d530dc 100644 (file)
@@ -87,7 +87,6 @@ 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_update, (struct interface * ifp), (ifp))
 DECLARE_HOOK(ospf_if_delete, (struct interface * ifp), (ifp))
 
 #endif /* _ZEBRA_OSPF_ZEBRA_H */
index f4de2558778cd7edd5315a361d803e692670016f..b12fa63723639b9bd1fc6f317d31d191f142a67c 100644 (file)
@@ -1339,6 +1339,7 @@ void ospf_if_update(struct ospf *ospf, struct interface *ifp)
 
        /* Update connected redistribute. */
        update_redistributed(ospf, 1);
+
 }
 
 void ospf_remove_vls_through_area(struct ospf *ospf, struct ospf_area *area)
index b8df7fc5ae940ceb16732dc829cc3cc95b4644ac..af4b1e83237be855299b1486e61a2adadd485891 100644 (file)
@@ -59,15 +59,8 @@ struct pbr_interface *pbr_if_new(struct interface *ifp)
 }
 
 /* Inteface addition message from zebra. */
-static int interface_add(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
-       if (!ifp)
-               return 0;
-
        DEBUGD(&pbr_dbg_zebra,
               "%s: %s", __PRETTY_FUNCTION__, ifp->name);
 
@@ -447,7 +440,6 @@ void pbr_zebra_init(void)
 
        zclient_init(zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs);
        zclient->zebra_connected = zebra_connected;
-       zclient->interface_add = interface_add;
        zclient->interface_delete = interface_delete;
        zclient->interface_up = interface_state_up;
        zclient->interface_down = interface_state_down;
@@ -580,11 +572,6 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,
        zclient_send_message(zclient);
 }
 
-int pbr_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 int pbr_ifp_up(struct interface *ifp)
 {
        return 0;
index d20713b9c520553d1a3b7540933dd677a6a1908e..94b92a7b0c8d0081332a5d33ef9b90c037b15381 100644 (file)
@@ -1529,6 +1529,53 @@ int pim_if_ifchannel_count(struct pim_interface *pim_ifp)
 
 int pim_ifp_create(struct interface *ifp)
 {
+       struct pim_instance *pim;
+
+       pim = pim_get_pim_instance(ifp->vrf_id);
+       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)) {
+               struct pim_interface *pim_ifp;
+
+               pim_ifp = ifp->info;
+               /*
+                * If we have a pim_ifp already and this is an if_add
+                * that means that we probably have a vrf move event
+                * If that is the case, set the proper vrfness.
+                */
+               if (pim_ifp)
+                       pim_ifp->pim = pim;
+               pim_if_addr_add_all(ifp);
+       }
+
+       /*
+        * If we are a vrf device that is up, open up the pim_socket for
+        * listening
+        * to incoming pim messages irrelevant if the user has configured us
+        * for pim or not.
+        */
+       if (pim_if_is_vrf_device(ifp)) {
+               struct pim_interface *pim_ifp;
+
+               if (!ifp->info) {
+                       pim_ifp = pim_if_new(ifp, false, false, false,
+                                            false /*vxlan_term*/);
+                       ifp->info = pim_ifp;
+               }
+
+               pim_sock_add(ifp);
+       }
+
+       if (!strncmp(ifp->name, PIM_VXLAN_TERM_DEV_NAME,
+                    sizeof(PIM_VXLAN_TERM_DEV_NAME)))
+               pim_vxlan_add_term_dev(pim, ifp);
+
        return 0;
 }
 
index b0db23f54ac0ec3428e0c5e78eca1b84a6df6773..a2b356759611b1fd2d10bf3eb21162f628ac6b83 100644 (file)
@@ -63,82 +63,11 @@ static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int pim_zebra_if_add(ZAPI_CALLBACK_ARGS)
-{
-       struct interface *ifp;
-       struct pim_instance *pim;
-
-       /*
-         zebra api adds/dels interfaces using the same call
-         interface_add_read below, see comments in lib/zclient.c
-       */
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-       if (!ifp)
-               return 0;
-
-       pim = pim_get_pim_instance(vrf_id);
-       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)) {
-               struct pim_interface *pim_ifp;
-
-               pim_ifp = ifp->info;
-               /*
-                * If we have a pim_ifp already and this is an if_add
-                * that means that we probably have a vrf move event
-                * If that is the case, set the proper vrfness.
-                */
-               if (pim_ifp)
-                       pim_ifp->pim = pim;
-               pim_if_addr_add_all(ifp);
-       }
-
-       /*
-        * If we are a vrf device that is up, open up the pim_socket for
-        * listening
-        * to incoming pim messages irrelevant if the user has configured us
-        * for pim or not.
-        */
-       if (pim_if_is_vrf_device(ifp)) {
-               struct pim_interface *pim_ifp;
-
-               if (!ifp->info) {
-                       pim_ifp = pim_if_new(ifp, false, false, false,
-                                       false /*vxlan_term*/);
-                       ifp->info = pim_ifp;
-               }
-
-               pim_sock_add(ifp);
-       }
-
-       if (!strncmp(ifp->name, PIM_VXLAN_TERM_DEV_NAME,
-                               sizeof(PIM_VXLAN_TERM_DEV_NAME)))
-               pim_vxlan_add_term_dev(pim, ifp);
-
-       return 0;
-}
-
 static int pim_zebra_if_del(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
        struct pim_instance *pim;
 
-       /*
-         zebra api adds/dels interfaces using the same call
-         interface_add_read below, see comments in lib/zclient.c
-
-         comments in lib/zclient.c seem to indicate that calling
-         zebra_interface_add_read is the correct call, but that
-         results in an attemted out of bounds read which causes
-         pimd to assert. Other clients use zebra_interface_state_read
-         and it appears to work just fine.
-       */
        ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
        if (!ifp)
                return 0;
@@ -793,7 +722,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_add = pim_zebra_if_add;
        zclient->interface_delete = pim_zebra_if_del;
        zclient->interface_up = pim_zebra_if_state_up;
        zclient->interface_down = pim_zebra_if_state_down;
index f20058a173d86b34f9a3bd3879c0d159dd89c6a3..11657536b668400b32593f0d7f9f1b6900f5a760 100644 (file)
@@ -405,11 +405,8 @@ int rip_interface_up(ZAPI_CALLBACK_ARGS)
 }
 
 /* Inteface addition message from zebra. */
-int rip_interface_add(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
        rip_interface_sync(ifp);
 
        if (IS_RIP_DEBUG_ZEBRA)
@@ -1253,11 +1250,6 @@ static int rip_interface_delete_hook(struct interface *ifp)
        return 0;
 }
 
-static int rip_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 static int rip_ifp_up(struct interface *ifp)
 {
        return 0;
index 0c88cb202bd4db7c274ab81b155397fce83f346e..92d37bdcaca6da55dc518242fd24506c201bb8d2 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_add = rip_interface_add;
        zclient->interface_delete = rip_interface_delete;
        zclient->interface_address_add = rip_interface_address_add;
        zclient->interface_address_delete = rip_interface_address_delete;
index 02c35e04cac08b74cd17d6e497a7971c529024b9..7b0ebd42c0a47f26b7455cfe78bd90e9f4db2eb2 100644 (file)
@@ -256,11 +256,8 @@ int ripng_interface_down(ZAPI_CALLBACK_ARGS)
 }
 
 /* Inteface addition message from zebra. */
-int ripng_interface_add(ZAPI_CALLBACK_ARGS)
+static int ripng_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
        ripng_interface_sync(ifp);
 
        if (IS_RIPNG_DEBUG_ZEBRA)
@@ -989,11 +986,6 @@ static struct cmd_node interface_node = {
        INTERFACE_NODE, "%s(config-if)# ", 1 /* VTYSH */
 };
 
-static int ripng_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 static int ripng_ifp_up(struct interface *ifp)
 {
        return 0;
index a557a90c829a5e937f06104ad1b069a168794459..a0e096bc6c075fadad6f0e08bab4f994c6eda9a3 100644 (file)
@@ -244,7 +244,6 @@ void zebra_init(struct thread_master *master)
        zclient->zebra_connected = ripng_zebra_connected;
        zclient->interface_up = ripng_interface_up;
        zclient->interface_down = ripng_interface_down;
-       zclient->interface_add = ripng_interface_add;
        zclient->interface_delete = ripng_interface_delete;
        zclient->interface_address_add = ripng_interface_address_add;
        zclient->interface_address_delete = ripng_interface_address_delete;
index 6e34785554237fb0b57a0ef3a10c26bdd499fd79..343ac67d0024545df3a34a3397bb6f45cfe8ab2f 100644 (file)
@@ -58,15 +58,8 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)
 }
 
 /* Inteface addition message from zebra. */
-static int interface_add(ZAPI_CALLBACK_ARGS)
+static int sharp_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
-       if (!ifp->info)
-               return 0;
-
        return 0;
 }
 
@@ -392,11 +385,6 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static int sharp_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 static int sharp_ifp_up(struct interface *ifp)
 {
        return 0;
@@ -425,7 +413,6 @@ void sharp_zebra_init(void)
 
        zclient_init(zclient, ZEBRA_ROUTE_SHARP, 0, &sharp_privs);
        zclient->zebra_connected = zebra_connected;
-       zclient->interface_add = interface_add;
        zclient->interface_delete = interface_delete;
        zclient->interface_up = interface_state_up;
        zclient->interface_down = interface_state_down;
index c18cbed6bac748744eb8a2322868bd13ecc436ee..2a6bfbd60145c169795212611e0306db3b23ed38 100644 (file)
@@ -61,16 +61,10 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)
 }
 
 /* Inteface addition message from zebra. */
-static int interface_add(ZAPI_CALLBACK_ARGS)
+static int static_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
-       if (!ifp)
-               return 0;
-
        static_ifindex_update(ifp, true);
+
        return 0;
 }
 
@@ -505,11 +499,6 @@ extern void static_zebra_route_add(struct route_node *rn,
                           zclient, &api);
 }
 
-static int static_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 static int static_ifp_up(struct interface *ifp)
 {
        return 0;
@@ -537,7 +526,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_add = interface_add;
        zclient->interface_delete = interface_delete;
        zclient->interface_up = interface_state_up;
        zclient->interface_down = interface_state_down;
index 0844b90266e7d2c61252b2c1689a17c54caa8c31..b4fcc3c36f764bd8612a551648384e579fab68be 100644 (file)
@@ -80,21 +80,9 @@ static int vrrp_router_id_update_zebra(int command, struct zclient *zclient,
        return 0;
 }
 
-static int vrrp_zebra_if_add(int command, struct zclient *zclient,
-                            zebra_size_t length, vrf_id_t vrf_id)
+int vrrp_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       /*
-        * zebra api adds/dels interfaces using the same call
-        * interface_add_read below, see comments in lib/zclient.c
-        */
-       ifp = zebra_interface_add_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_add(ifp);
 
@@ -236,11 +224,6 @@ int vrrp_zclient_send_interface_protodown(struct interface *ifp, bool down)
                                                down);
 }
 
-int vrrp_ifp_create(struct interface *ifp)
-{
-       return 0;
-}
-
 int vrrp_ifp_up(struct interface *ifp)
 {
        return 0;
@@ -266,7 +249,6 @@ void vrrp_zebra_init(void)
 
        zclient->zebra_connected = vrrp_zebra_connected;
        zclient->router_id_update = vrrp_router_id_update_zebra;
-       zclient->interface_add = vrrp_zebra_if_add;
        zclient->interface_delete = vrrp_zebra_if_del;
        zclient->interface_up = vrrp_zebra_if_state_up;
        zclient->interface_down = vrrp_zebra_if_state_down;