zebra: Add interface sysctl ignore on linkdown status

Add the ability to decode the ignore on linkdown nexthop
status for an interface.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-06-23 11:00:08 -04:00
parent c704cb44a9
commit 3689905d32
5 changed files with 62 additions and 9 deletions

View File

@ -1407,7 +1407,7 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
struct interface *ifp)
{
struct zebra_if *zif;
enum dplane_netconf_status_e mpls;
enum dplane_netconf_status_e mpls, linkdown;
zif = ifp->info;
if (!zif) {
@ -1424,10 +1424,17 @@ static void zebra_if_netconf_update_ctx(struct zebra_dplane_ctx *ctx,
else if (mpls == DPLANE_NETCONF_STATUS_DISABLED)
zif->mpls = false;
linkdown = dplane_ctx_get_netconf_linkdown(ctx);
if (linkdown == DPLANE_NETCONF_STATUS_ENABLED)
zif->linkdown = true;
else if (linkdown == DPLANE_NETCONF_STATUS_DISABLED)
zif->linkdown = false;
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: if %s, ifindex %d, mpls %s",
zlog_debug("%s: if %s, ifindex %d, mpls %s linkdown %s",
__func__, ifp->name, ifp->ifindex,
(zif->mpls ? "ON" : "OFF"));
(zif->mpls ? "ON" : "OFF"),
(zif->linkdown ? "ON" : "OFF"));
}
void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx)
@ -1890,6 +1897,9 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
if (zebra_if->mpls)
vty_out(vty, " MPLS enabled\n");
if (zebra_if->linkdown)
vty_out(vty, " Ignore all routes with linkdown\n");
/* Hardware address. */
vty_out(vty, " Type: %s\n", if_link_type_str(ifp->ll_type));
if (ifp->hw_addr_len != 0) {
@ -2211,6 +2221,7 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
zebra_if->desc);
json_object_boolean_add(json_if, "mplsEnabled", zebra_if->mpls);
json_object_boolean_add(json_if, "linkDown", zebra_if->linkdown);
if (ifp->ifindex == IFINDEX_INTERNAL) {
json_object_boolean_add(json_if, "pseudoInterface", true);

View File

@ -129,6 +129,9 @@ struct zebra_if {
/* MPLS status. */
bool mpls;
/* Linkdown status */
bool linkdown;
/* Router advertise configuration. */
uint8_t rtadv_enable;

View File

@ -45,9 +45,11 @@ static struct rtattr *netconf_rta(struct netconfmsg *ncm)
* Handle netconf update about a single interface: create dplane
* context, and enqueue for processing in the main zebra pthread.
*/
static int netlink_netconf_dplane_update(ns_id_t ns_id, ifindex_t ifindex,
enum dplane_netconf_status_e mpls_on,
enum dplane_netconf_status_e mcast_on)
static int
netlink_netconf_dplane_update(ns_id_t ns_id, ifindex_t ifindex,
enum dplane_netconf_status_e mpls_on,
enum dplane_netconf_status_e mcast_on,
enum dplane_netconf_status_e linkdown_on)
{
struct zebra_dplane_ctx *ctx;
@ -58,6 +60,7 @@ static int netlink_netconf_dplane_update(ns_id_t ns_id, ifindex_t ifindex,
dplane_ctx_set_netconf_mpls(ctx, mpls_on);
dplane_ctx_set_netconf_mcast(ctx, mcast_on);
dplane_ctx_set_netconf_linkdown(ctx, linkdown_on);
/* Enqueue ctx for main pthread to process */
dplane_provider_enqueue_to_zebra(ctx);
@ -77,6 +80,8 @@ int netlink_netconf_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
uint32_t ival;
enum dplane_netconf_status_e mpls_on = DPLANE_NETCONF_STATUS_UNKNOWN;
enum dplane_netconf_status_e mcast_on = DPLANE_NETCONF_STATUS_UNKNOWN;
enum dplane_netconf_status_e linkdown_on =
DPLANE_NETCONF_STATUS_UNKNOWN;
if (h->nlmsg_type != RTM_NEWNETCONF && h->nlmsg_type != RTM_DELNETCONF)
return 0;
@ -133,12 +138,23 @@ int netlink_netconf_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
mcast_on = DPLANE_NETCONF_STATUS_DISABLED;
}
if (tb[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN]) {
ival = *(uint32_t *)RTA_DATA(
tb[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN]);
if (ival != 0)
linkdown_on = DPLANE_NETCONF_STATUS_ENABLED;
else
linkdown_on = DPLANE_NETCONF_STATUS_DISABLED;
}
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("%s: interface %u is mpls on: %d multicast on: %d",
__func__, ifindex, mpls_on, mcast_on);
zlog_debug(
"%s: interface %u is mpls on: %d multicast on: %d linkdown: %d",
__func__, ifindex, mpls_on, mcast_on, linkdown_on);
/* Create a dplane context and pass it along for processing */
netlink_netconf_dplane_update(ns_id, ifindex, mpls_on, mcast_on);
netlink_netconf_dplane_update(ns_id, ifindex, mpls_on, mcast_on,
linkdown_on);
return 0;
}

View File

@ -303,6 +303,7 @@ struct dplane_gre_ctx {
struct dplane_netconf_info {
enum dplane_netconf_status_e mpls_val;
enum dplane_netconf_status_e mcast_val;
enum dplane_netconf_status_e linkdown_val;
};
/*
@ -2348,6 +2349,14 @@ dplane_ctx_get_netconf_mcast(const struct zebra_dplane_ctx *ctx)
return ctx->u.netconf.mcast_val;
}
enum dplane_netconf_status_e
dplane_ctx_get_netconf_linkdown(const struct zebra_dplane_ctx *ctx)
{
DPLANE_CTX_VALID(ctx);
return ctx->u.netconf.linkdown_val;
}
void dplane_ctx_set_netconf_mpls(struct zebra_dplane_ctx *ctx,
enum dplane_netconf_status_e val)
{
@ -2364,6 +2373,15 @@ void dplane_ctx_set_netconf_mcast(struct zebra_dplane_ctx *ctx,
ctx->u.netconf.mcast_val = val;
}
void dplane_ctx_set_netconf_linkdown(struct zebra_dplane_ctx *ctx,
enum dplane_netconf_status_e val)
{
DPLANE_CTX_VALID(ctx);
ctx->u.netconf.linkdown_val = val;
}
/*
* Retrieve the limit on the number of pending, unprocessed updates.
*/

View File

@ -596,10 +596,15 @@ enum dplane_netconf_status_e
dplane_ctx_get_netconf_mpls(const struct zebra_dplane_ctx *ctx);
enum dplane_netconf_status_e
dplane_ctx_get_netconf_mcast(const struct zebra_dplane_ctx *ctx);
enum dplane_netconf_status_e
dplane_ctx_get_netconf_linkdown(const struct zebra_dplane_ctx *ctx);
void dplane_ctx_set_netconf_mpls(struct zebra_dplane_ctx *ctx,
enum dplane_netconf_status_e val);
void dplane_ctx_set_netconf_mcast(struct zebra_dplane_ctx *ctx,
enum dplane_netconf_status_e val);
void dplane_ctx_set_netconf_linkdown(struct zebra_dplane_ctx *ctx,
enum dplane_netconf_status_e val);
/* Namespace fd info - esp. for netlink communication */
const struct zebra_dplane_info *dplane_ctx_get_ns(