diff options
Diffstat (limited to 'ldpd/ldp_zebra.c')
| -rw-r--r-- | ldpd/ldp_zebra.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index 884ae159be..4df1fc0304 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -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) { @@ -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; |
