]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Add ability for netconf dplane to handle global values
authorDonald Sharp <sharpd@nvidia.com>
Mon, 27 Jun 2022 19:30:55 +0000 (15:30 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 27 Jun 2022 20:30:20 +0000 (16:30 -0400)
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>
zebra/interface.c
zebra/netconf_netlink.c
zebra/zebra_router.h
zebra/zebra_vty.c

index 00eac3ee56e79a86f829fca75bdc8489ea012a6c..9800e6450335d0a54e6dde00d1ea7b947d156b35 100644 (file)
@@ -1404,44 +1404,66 @@ 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;
-       if (!zif) {
-               if (IS_ZEBRA_DEBUG_KERNEL)
-                       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);
+       linkdown = dplane_ctx_get_netconf_linkdown(ctx);
+       mcast_on = dplane_ctx_get_netconf_mcast(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;
+       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 {
-               mcast_set = &zif->v6mcast_on;
-               linkdown_set = &zif->linkdownv6;
+               zif = ifp ? ifp->info : NULL;
+               if (!zif) {
+                       if (IS_ZEBRA_DEBUG_KERNEL)
+                               zlog_debug(
+                                       "%s: if %s(%u) zebra info pointer is NULL",
+                                       __func__, ifp->name, ifp->ifindex);
+                       return;
+               }
+               if (afi == AFI_IP) {
+                       mcast_set = &zif->v4mcast_on;
+                       linkdown_set = &zif->linkdown;
+               } else {
+                       mcast_set = &zif->v6mcast_on;
+                       linkdown_set = &zif->linkdownv6;
+               }
+
+               /*
+                * 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;
        }
 
-       linkdown = dplane_ctx_get_netconf_linkdown(ctx);
        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,11 +1509,15 @@ void zebra_if_dplane_result(struct zebra_dplane_ctx *ctx)
 
        ifp = if_lookup_by_index_per_ns(zns, ifindex);
        if (ifp == NULL) {
-               if (IS_ZEBRA_DEBUG_KERNEL)
-                       zlog_debug("%s: can't find ifp at nsid %u index %d",
-                                  __func__, ns_id, ifindex);
+               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",
+                                       __func__, ns_id, ifindex);
 
-               goto done;
+                       goto done;
+               }
        }
 
        switch (op) {
@@ -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:
index 0b9dbe03a1421d488499d4e023ae38ef2c5d22eb..f9cb37a3cf7dd691b2a73f8d8c872b26a95c9b60 100644 (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)
index c96c8e5f46c203e3d99b35cc701830cc7f6e22e3..74f87c7b1a5ced3a16645bd6c3189e918d7eba64 100644 (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;
 };
index 011fa2a1e5d466bc4e09f604e16f118dffcf466e..01dce47638bb3a973e855ae39618eeb3a163dd1e 100644 (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);