zebra: Add ability for netconf dplane to handle global values

Add the ability for the netconf dplane code to handle
the global NETCONFA_IFINDEX_DEFAULT and NETCONF_IFINDEX_ALL
values.  Then store our interested values when we get
them from the kernel as well as being able to display
them to the end operator.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-06-27 15:30:55 -04:00
parent d53dc9bd81
commit 385d37ab31
4 changed files with 80 additions and 46 deletions

View File

@ -1404,29 +1404,44 @@ done:
* pthread so it can update zebra data structs.
*/
static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
struct interface *ifp)
struct interface *ifp,
ifindex_t ifindex)
{
struct zebra_if *zif;
struct zebra_if *zif = NULL;
afi_t afi;
enum dplane_netconf_status_e mpls, mcast_on, linkdown;
bool *mcast_set, *linkdown_set;
zif = ifp->info;
afi = dplane_ctx_get_afi(ctx);
mpls = dplane_ctx_get_netconf_mpls(ctx);
linkdown = dplane_ctx_get_netconf_linkdown(ctx);
mcast_on = dplane_ctx_get_netconf_mcast(ctx);
if (ifindex == DPLANE_NETCONF_IFINDEX_ALL) {
if (afi == AFI_IP) {
mcast_set = &zrouter.all_mc_forwardingv4;
linkdown_set = &zrouter.all_linkdownv4;
} else {
mcast_set = &zrouter.all_mc_forwardingv6;
linkdown_set = &zrouter.all_linkdownv6;
}
} else if (ifindex == DPLANE_NETCONF_IFINDEX_DEFAULT) {
if (afi == AFI_IP) {
mcast_set = &zrouter.default_mc_forwardingv4;
linkdown_set = &zrouter.default_linkdownv4;
} else {
mcast_set = &zrouter.default_mc_forwardingv6;
linkdown_set = &zrouter.default_linkdownv6;
}
} else {
zif = ifp ? ifp->info : NULL;
if (!zif) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: if %s(%u) zebra info pointer is NULL",
zlog_debug(
"%s: if %s(%u) zebra info pointer is NULL",
__func__, ifp->name, ifp->ifindex);
return;
}
afi = dplane_ctx_get_afi(ctx);
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 (afi == AFI_IP) {
mcast_set = &zif->v4mcast_on;
linkdown_set = &zif->linkdown;
@ -1435,13 +1450,20 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
linkdown_set = &zif->linkdownv6;
}
linkdown = dplane_ctx_get_netconf_linkdown(ctx);
/*
* mpls netconf data is neither v4 or v6 it's AF_MPLS!
*/
if (mpls == DPLANE_NETCONF_STATUS_ENABLED)
zif->mpls = true;
else if (mpls == DPLANE_NETCONF_STATUS_DISABLED)
zif->mpls = false;
}
if (linkdown == DPLANE_NETCONF_STATUS_ENABLED)
*linkdown_set = true;
else if (linkdown == DPLANE_NETCONF_STATUS_DISABLED)
*linkdown_set = false;
mcast_on = dplane_ctx_get_netconf_mcast(ctx);
if (mcast_on == DPLANE_NETCONF_STATUS_ENABLED)
*mcast_set = true;
else if (mcast_on == DPLANE_NETCONF_STATUS_DISABLED)
@ -1450,8 +1472,10 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"%s: afi: %d if %s, ifindex %d, mpls %s mc_forwarding: %s linkdown %s",
__func__, afi, ifp->name, ifp->ifindex,
(zif->mpls ? "ON" : "OFF"), (*mcast_set ? "ON" : "OFF"),
__func__, afi, ifp ? ifp->name : "Global",
ifp ? ifp->ifindex : ifindex,
(zif ? (zif->mpls ? "ON" : "OFF") : "OFF"),
(*mcast_set ? "ON" : "OFF"),
(*linkdown_set ? "ON" : "OFF"));
}
@ -1485,12 +1509,16 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx)
ifp = if_lookup_by_index_per_ns(zns, ifindex);
if (ifp == NULL) {
if (op != DPLANE_OP_INTF_NETCONFIG ||
(ifindex != -1 && ifindex != -2)) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: can't find ifp at nsid %u index %d",
zlog_debug(
"%s: can't find ifp at nsid %u index %d",
__func__, ns_id, ifindex);
goto done;
}
}
switch (op) {
case DPLANE_OP_INTF_ADDR_ADD:
@ -1505,7 +1533,7 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx)
break;
case DPLANE_OP_INTF_NETCONFIG:
zebra_if_netconf_update_ctx(ctx, ifp);
zebra_if_netconf_update_ctx(ctx, ifp, ifindex);
break;
case DPLANE_OP_ROUTE_INSTALL:

View File

@ -119,23 +119,6 @@ int netlink_netconf_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifindex = *(ifindex_t *)RTA_DATA(tb[NETCONFA_IFINDEX]);
switch (ifindex) {
case NETCONFA_IFINDEX_ALL:
case NETCONFA_IFINDEX_DEFAULT:
/*
* We need the ability to handle netlink messages intended
* for all and default interfaces. I am not 100% sure
* what that is yet, or where we would store it.
*/
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: Ignoring global ifindex %d",
__func__, ifindex);
return 0;
default:
break;
}
if (tb[NETCONFA_INPUT]) {
ival = *(uint32_t *)RTA_DATA(tb[NETCONFA_INPUT]);
if (ival != 0)

View File

@ -220,6 +220,11 @@ struct zebra_router {
bool supports_nhgs;
bool all_mc_forwardingv4, default_mc_forwardingv4;
bool all_mc_forwardingv6, default_mc_forwardingv6;
bool all_linkdownv4, default_linkdownv4;
bool all_linkdownv6, default_linkdownv6;
#define ZEBRA_DEFAULT_NHG_KEEP_TIMER 180
uint32_t nhg_keep;
};

View File

@ -3976,6 +3976,24 @@ DEFUN (show_zebra,
ttable_add_row(table, "Kernel NHG|%s",
zrouter.supports_nhgs ? "Available" : "Unavailable");
ttable_add_row(table, "v4 All LinkDown Routes|%s",
zrouter.all_linkdownv4 ? "On" : "Off");
ttable_add_row(table, "v4 Default LinkDown Routes|%s",
zrouter.default_linkdownv4 ? "On" : "Off");
ttable_add_row(table, "v6 All LinkDown Routes|%s",
zrouter.all_linkdownv6 ? "On" : "Off");
ttable_add_row(table, "v6 Default LinkDown Routes|%s",
zrouter.default_linkdownv6 ? "On" : "Off");
ttable_add_row(table, "v4 All MC Forwarding|%s",
zrouter.all_mc_forwardingv4 ? "On" : "Off");
ttable_add_row(table, "v4 Default MC Forwarding|%s",
zrouter.default_mc_forwardingv4 ? "On" : "Off");
ttable_add_row(table, "v6 All MC Forwarding|%s",
zrouter.all_mc_forwardingv6 ? "On" : "Off");
ttable_add_row(table, "v6 Default MC Forwarding|%s",
zrouter.default_mc_forwardingv6 ? "On" : "Off");
out = ttable_dump(table, "\n");
vty_out(vty, "%s\n", out);
XFREE(MTYPE_TMP, out);