]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/ldp_zebra.c
Merge pull request #5681 from opensourcerouting/manpage-rename
[mirror_frr.git] / ldpd / ldp_zebra.c
index 884ae159be437b7c4062bbc099fd62b10e69c9f5..946b51e4eea1a250b941cfb5f471acb5b1f42253 100644 (file)
@@ -39,9 +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);
 static int      ldp_interface_address_delete(ZAPI_CALLBACK_ARGS);
 static int      ldp_zebra_read_route(ZAPI_CALLBACK_ARGS);
@@ -264,39 +261,27 @@ 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
-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));
 
@@ -304,22 +289,13 @@ ldp_interface_delete(ZAPI_CALLBACK_ARGS)
 }
 
 static int
-ldp_interface_status_change(ZAPI_CALLBACK_ARGS)
+ldp_interface_status_change_helper(struct interface *ifp)
 {
-       struct interface        *ifp;
        struct listnode         *node;
        struct connected        *ifc;
        struct kif               kif;
        struct kaddr             ka;
 
-       /*
-        * 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 %s state update", ifp->name);
 
        ifp2kif(ifp, &kif);
@@ -342,6 +318,16 @@ ldp_interface_status_change(ZAPI_CALLBACK_ARGS)
        return (0);
 }
 
+static int ldp_ifp_up(struct interface *ifp)
+{
+       return ldp_interface_status_change_helper(ifp);
+}
+
+static int ldp_ifp_down(struct interface *ifp)
+{
+       return ldp_interface_status_change_helper(ifp);
+}
+
 static int
 ldp_interface_address_add(ZAPI_CALLBACK_ARGS)
 {
@@ -382,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))
@@ -535,6 +521,9 @@ extern struct zebra_privs_t ldpd_privs;
 void
 ldp_zebra_init(struct thread_master *master)
 {
+       if_zapi_callbacks(ldp_ifp_create, ldp_ifp_up,
+                         ldp_ifp_down, ldp_ifp_destroy);
+
        /* Set default values. */
        zclient = zclient_new(master, &zclient_options_default);
        zclient_init(zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs);
@@ -542,10 +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_add = ldp_interface_add;
-       zclient->interface_delete = ldp_interface_delete;
-       zclient->interface_up = ldp_interface_status_change;
-       zclient->interface_down = ldp_interface_status_change;
        zclient->interface_address_add = ldp_interface_address_add;
        zclient->interface_address_delete = ldp_interface_address_delete;
        zclient->redistribute_route_add = ldp_zebra_read_route;