]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: add dplane type for NETCONF data
authorMark Stapp <mstapp@nvidia.com>
Thu, 28 Oct 2021 15:19:32 +0000 (11:19 -0400)
committerMark Stapp <mstapp@nvidia.com>
Fri, 25 Feb 2022 14:53:02 +0000 (09:53 -0500)
Add a new dplane op for interface NETCONF data; add the new
enum value to several switch statements.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
zebra/dplane_fpm_nl.c
zebra/kernel_netlink.c
zebra/zebra_dplane.c
zebra/zebra_dplane.h
zebra/zebra_nhg.c
zebra/zebra_rib.c
zebra/zebra_script.c

index 0baef5bdb561329e609ee8ebda469bed1faea72f..8c8004190bb2c7805fba73ccc5da83e44e313e76 100644 (file)
@@ -811,6 +811,7 @@ static int fpm_nl_enqueue(struct fpm_nl_ctx *fnc, struct zebra_dplane_ctx *ctx)
        case DPLANE_OP_GRE_SET:
        case DPLANE_OP_INTF_ADDR_ADD:
        case DPLANE_OP_INTF_ADDR_DEL:
+       case DPLANE_OP_INTF_NETCONFIG:
        case DPLANE_OP_NONE:
                break;
 
index 8e472b4728498cf6ce17e2920b0e08d70ac366ec..44389ae01146ccfa19f2cbab783d27b25dd934b4 100644 (file)
@@ -1492,6 +1492,7 @@ static enum netlink_msg_status nl_put_msg(struct nl_batch *bth,
 
        case DPLANE_OP_INTF_ADDR_ADD:
        case DPLANE_OP_INTF_ADDR_DEL:
+       case DPLANE_OP_INTF_NETCONFIG:
        case DPLANE_OP_NONE:
                return FRR_NETLINK_ERROR;
        }
index 1967345d2228402d13c590f4f3f98b6ac5113cb6..a062ad0cb69212886ec456797b8eee031d1d096a 100644 (file)
@@ -290,6 +290,19 @@ struct dplane_gre_ctx {
        unsigned int mtu;
        struct zebra_l2info_gre info;
 };
+
+
+/*
+ * Network interface configuration info - aligned with netlink's NETCONF
+ * info. The flags values are public, in the dplane.h file...
+ */
+struct dplane_netconf_info {
+       ns_id_t ns_id;
+       ifindex_t ifindex;
+       enum dplane_netconf_status_e mpls_val;
+       enum dplane_netconf_status_e mcast_val;
+};
+
 /*
  * The context block used to exchange info about route updates across
  * the boundary between the zebra main context (and pthread) and the
@@ -347,6 +360,7 @@ struct zebra_dplane_ctx {
                } ipset_entry;
                struct dplane_neigh_table neightable;
                struct dplane_gre_ctx gre;
+               struct dplane_netconf_info netconf;
        } u;
 
        /* Namespace info, used especially for netlink kernel communication */
@@ -769,6 +783,7 @@ static void dplane_ctx_free_internal(struct zebra_dplane_ctx *ctx)
                }
                break;
        case DPLANE_OP_GRE_SET:
+       case DPLANE_OP_INTF_NETCONFIG:
                break;
        }
 }
@@ -1053,6 +1068,9 @@ const char *dplane_op2str(enum dplane_op_e op)
 
        case DPLANE_OP_INTF_ADDR_DEL:
                return "INTF_ADDR_DEL";
+
+       case DPLANE_OP_INTF_NETCONFIG:
+               return "INTF_NETCONFIG";
        }
 
        return ret;
@@ -2239,6 +2257,10 @@ uint32_t dplane_intf_extra_get_status(const struct dplane_intf_extra *ptr)
        return ptr->status;
 }
 
+/*
+ * End of interface extra info accessors
+ */
+
 uint8_t dplane_ctx_neightable_get_family(const struct zebra_dplane_ctx *ctx)
 {
        DPLANE_CTX_VALID(ctx);
@@ -2270,9 +2292,66 @@ dplane_ctx_neightable_get_mcast_probes(const struct zebra_dplane_ctx *ctx)
        return ctx->u.neightable.mcast_probes;
 }
 
-/*
- * End of interface extra info accessors
- */
+ifindex_t dplane_ctx_get_netconf_ifindex(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.netconf.ifindex;
+}
+
+ns_id_t dplane_ctx_get_netconf_ns_id(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.netconf.ns_id;
+}
+
+void dplane_ctx_set_netconf_ifindex(struct zebra_dplane_ctx *ctx,
+                                   ifindex_t ifindex)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       ctx->u.netconf.ifindex = ifindex;
+}
+
+void dplane_ctx_set_netconf_ns_id(struct zebra_dplane_ctx *ctx, ns_id_t ns_id)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       ctx->u.netconf.ns_id = ns_id;
+}
+
+enum dplane_netconf_status_e
+dplane_ctx_get_netconf_mpls(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.netconf.mpls_val;
+}
+
+enum dplane_netconf_status_e
+dplane_ctx_get_netconf_mcast(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.netconf.mcast_val;
+}
+
+void dplane_ctx_set_netconf_mpls(struct zebra_dplane_ctx *ctx,
+                                enum dplane_netconf_status_e val)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       ctx->u.netconf.mpls_val = val;
+}
+
+void dplane_ctx_set_netconf_mcast(struct zebra_dplane_ctx *ctx,
+                                 enum dplane_netconf_status_e val)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       ctx->u.netconf.mcast_val = val;
+}
 
 /*
  * Retrieve the limit on the number of pending, unprocessed updates.
@@ -5113,6 +5192,14 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx)
                           dplane_ctx_get_ifname(ctx),
                           dplane_ctx_get_intf_addr(ctx));
                break;
+
+       case DPLANE_OP_INTF_NETCONFIG:
+               zlog_debug("%s: ifindex %d, mpls %d, mcast %d",
+                          dplane_op2str(dplane_ctx_get_op(ctx)),
+                          dplane_ctx_get_netconf_ifindex(ctx),
+                          dplane_ctx_get_netconf_mpls(ctx),
+                          dplane_ctx_get_netconf_mcast(ctx));
+               break;
        }
 }
 
@@ -5258,6 +5345,7 @@ static void kernel_dplane_handle_result(struct zebra_dplane_ctx *ctx)
        /* TODO -- error counters for incoming events? */
        case DPLANE_OP_INTF_ADDR_ADD:
        case DPLANE_OP_INTF_ADDR_DEL:
+       case DPLANE_OP_INTF_NETCONFIG:
                break;
 
        case DPLANE_OP_NONE:
index a7a5f99e451a4743ac9d02bf048ec250a286626e..29555d5b5662a27e978cea45c3235de399047756 100644 (file)
@@ -185,6 +185,9 @@ enum dplane_op_e {
        /* Incoming interface address events */
        DPLANE_OP_INTF_ADDR_ADD,
        DPLANE_OP_INTF_ADDR_DEL,
+
+       /* Incoming interface config events */
+       DPLANE_OP_INTF_NETCONFIG,
 };
 
 /*
@@ -222,6 +225,22 @@ enum dplane_op_e {
 
 #define DPLANE_BR_PORT_NON_DF (1 << 0)
 
+/* Definitions for the dplane 'netconf' apis, corresponding to the netlink
+ * NETCONF api.
+ * Sadly, netlink sends incremental updates, so its messages may contain
+ * just a single changed attribute, and not necessarily
+ * a complete snapshot of the attributes.
+ */
+enum dplane_netconf_status_e {
+       DPLANE_NETCONF_STATUS_UNKNOWN = 0,
+       DPLANE_NETCONF_STATUS_ENABLED,
+       DPLANE_NETCONF_STATUS_DISABLED
+};
+
+/* Some special ifindex values that may be part of the dplane netconf api. */
+#define DPLANE_NETCONF_IFINDEX_ALL     -1
+#define DPLANE_NETCONF_IFINDEX_DEFAULT -2
+
 /* Enable system route notifications */
 void dplane_enable_sys_route_notifs(void);
 
@@ -564,6 +583,21 @@ dplane_ctx_gre_get_mtu(const struct zebra_dplane_ctx *ctx);
 const struct zebra_l2info_gre *
 dplane_ctx_gre_get_info(const struct zebra_dplane_ctx *ctx);
 
+/* Interface netconf info */
+ifindex_t dplane_ctx_get_netconf_ifindex(const struct zebra_dplane_ctx *ctx);
+ns_id_t dplane_ctx_get_netconf_ns_id(const struct zebra_dplane_ctx *ctx);
+void dplane_ctx_set_netconf_ifindex(struct zebra_dplane_ctx *ctx,
+                                   ifindex_t ifindex);
+void dplane_ctx_set_netconf_ns_id(struct zebra_dplane_ctx *ctx, ns_id_t ns_id);
+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);
+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);
+
 /* Namespace fd info - esp. for netlink communication */
 const struct zebra_dplane_info *dplane_ctx_get_ns(
        const struct zebra_dplane_ctx *ctx);
index c1b104aec7ca8c4d123ceba5893c6b0ad9997f63..858309f3e7520ac1c8edfea76119bc13ea7c26bc 100644 (file)
@@ -2989,6 +2989,7 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
        case DPLANE_OP_GRE_SET:
        case DPLANE_OP_INTF_ADDR_ADD:
        case DPLANE_OP_INTF_ADDR_DEL:
+       case DPLANE_OP_INTF_NETCONFIG:
                break;
        }
 
index c386fc4871e075489d7e3cfc2cbdfafeb359f72b..bfcbe645dd7c36089e4a2a9d3177e6aa1101f0d5 100644 (file)
@@ -4334,6 +4334,7 @@ static void rib_process_dplane_results(struct thread *thread)
                        case DPLANE_OP_BR_PORT_UPDATE:
                        case DPLANE_OP_NEIGH_TABLE_UPDATE:
                        case DPLANE_OP_GRE_SET:
+                       case DPLANE_OP_INTF_NETCONFIG:
                        case DPLANE_OP_NONE:
                                /* Don't expect this: just return the struct? */
                                dplane_ctx_fini(&ctx);
index 0e19376abe24c491765bc9ae1e186404e43520f2..4087749fd753aeb3bede8609219834037a8cc76a 100644 (file)
@@ -412,6 +412,8 @@ void lua_pushzebra_dplane_ctx(lua_State *L, const struct zebra_dplane_ctx *ctx)
                        lua_setfield(L, -2, "mtu");
                }
                lua_setfield(L, -2, "gre");
+
+       case DPLANE_OP_INTF_NETCONFIG: /*NYI*/
        case DPLANE_OP_NONE:
                break;
        } /* Dispatch by op code */