diff options
Diffstat (limited to 'zebra/interface.c')
| -rw-r--r-- | zebra/interface.c | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index e4e80ec4e9..c30f43456c 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -64,7 +64,7 @@ DEFINE_HOOK(zebra_if_config_wr, (struct vty * vty, struct interface *ifp), static void if_down_del_nbr_connected(struct interface *ifp); -static int if_zebra_speed_update(struct thread *thread) +static void if_zebra_speed_update(struct thread *thread) { struct interface *ifp = THREAD_ARG(thread); struct zebra_if *zif = ifp->info; @@ -81,7 +81,7 @@ static int if_zebra_speed_update(struct thread *thread) * note that loopback & virtual interfaces can return 0 as speed */ if (error < 0) - return 1; + return; if (new_speed != ifp->speed) { zlog_info("%s: %s old speed: %u new speed: %u", __func__, @@ -96,8 +96,6 @@ static int if_zebra_speed_update(struct thread *thread) &zif->speed_update); thread_ignore_late_timer(zif->speed_update); } - - return 1; } static void zebra_if_node_destroy(route_table_delegate_t *delegate, @@ -158,6 +156,16 @@ static int if_zebra_new_hook(struct interface *ifp) rtadv->AdvReachableTime = 0; rtadv->AdvRetransTimer = 0; rtadv->AdvCurHopLimit = RTADV_DEFAULT_HOPLIMIT; + memset(&rtadv->lastadvcurhoplimit, 0, + sizeof(rtadv->lastadvcurhoplimit)); + memset(&rtadv->lastadvmanagedflag, 0, + sizeof(rtadv->lastadvmanagedflag)); + memset(&rtadv->lastadvotherconfigflag, 0, + sizeof(rtadv->lastadvotherconfigflag)); + memset(&rtadv->lastadvreachabletime, 0, + sizeof(rtadv->lastadvreachabletime)); + memset(&rtadv->lastadvretranstimer, 0, + sizeof(rtadv->lastadvretranstimer)); rtadv->AdvDefaultLifetime = -1; /* derive from MaxRtrAdvInterval */ rtadv->HomeAgentPreference = 0; @@ -1310,6 +1318,56 @@ done: dplane_ctx_fini(&ctx); } +/* + * Handle netconf change from a dplane context object; runs in the main + * pthread so it can update zebra data structs. + */ +int zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx) +{ + struct zebra_ns *zns; + struct interface *ifp; + struct zebra_if *zif; + enum dplane_netconf_status_e mpls; + int ret = 0; + + zns = zebra_ns_lookup(dplane_ctx_get_netconf_ns_id(ctx)); + if (zns == NULL) { + ret = -1; + goto done; + } + + ifp = if_lookup_by_index_per_ns(zns, + dplane_ctx_get_netconf_ifindex(ctx)); + if (ifp == NULL) { + ret = -1; + goto done; + } + + zif = ifp->info; + if (zif == NULL) { + ret = -1; + goto done; + } + + mpls = dplane_ctx_get_netconf_mpls(ctx); + + if (mpls == DPLANE_NETCONF_STATUS_ENABLED) + zif->mpls = true; + else if (mpls == DPLANE_NETCONF_STATUS_DISABLED) + zif->mpls = false; + + if (IS_ZEBRA_DEBUG_KERNEL) + zlog_debug("%s: if %s, ifindex %d, mpls %s", + __func__, ifp->name, ifp->ifindex, + (zif->mpls ? "ON" : "OFF")); + +done: + /* Free the context */ + dplane_ctx_fini(&ctx); + + return ret; +} + /* Dump if address information to vty. */ static void connected_dump_vty(struct vty *vty, json_object *json, struct connected *connected) @@ -1662,6 +1720,9 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) vty_out(vty, "mtu6 %d ", ifp->mtu6); vty_out(vty, "\n flags: %s\n", if_flag_dump(ifp->flags)); + if (zebra_if->mpls) + vty_out(vty, " MPLS enabled\n"); + /* Hardware address. */ vty_out(vty, " Type: %s\n", if_link_type_str(ifp->ll_type)); if (ifp->hw_addr_len != 0) { @@ -1982,6 +2043,8 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, json_object_string_add(json_if, "OsDescription", zebra_if->desc); + json_object_boolean_add(json_if, "mplsEnabled", zebra_if->mpls); + if (ifp->ifindex == IFINDEX_INTERNAL) { json_object_boolean_add(json_if, "pseudoInterface", true); return; |
