[ovs-dev] [v12 07/16] dpif-netdev: Add command to get dpif implementations.
Stokes, Ian
ian.stokes at intel.com
Wed Jun 2 17:38:48 UTC 2021
> This commit adds a new command to retrieve the list of available
> DPIF implementations. This can be used by to check what implementations
> of the DPIF are available in any given OVS binary.
>
> Usage:
> $ ovs-appctl dpif-netdev/dpif-get
>
> Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Thanks Harry/Cian. Overall LGTM.
Ian
> ---
> lib/dpif-netdev-private-dpif.c | 8 ++++++++
> lib/dpif-netdev-private-dpif.h | 6 ++++++
> lib/dpif-netdev.c | 24 ++++++++++++++++++++++++
> 3 files changed, 38 insertions(+)
>
> diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c
> index e417fa86d..9ea038748 100644
> --- a/lib/dpif-netdev-private-dpif.c
> +++ b/lib/dpif-netdev-private-dpif.c
> @@ -73,6 +73,14 @@ dp_netdev_impl_set_default(dp_netdev_input_func func)
> default_dpif_func = func;
> }
>
> +uint32_t
> +dp_netdev_impl_get(const struct dpif_netdev_impl_info_t **out_impls)
> +{
> + ovs_assert(out_impls);
> + *out_impls = dpif_impls;
> + return ARRAY_SIZE(dpif_impls);
> +}
> +
> /* This function checks all available DPIF implementations, and selects the
> * returns the function pointer to the one requested by "name".
> */
> diff --git a/lib/dpif-netdev-private-dpif.h b/lib/dpif-netdev-private-dpif.h
> index fb5380d2c..3bd67cbcd 100644
> --- a/lib/dpif-netdev-private-dpif.h
> +++ b/lib/dpif-netdev-private-dpif.h
> @@ -47,6 +47,12 @@ struct dpif_netdev_impl_info_t {
> const char *name;
> };
>
> +/* This function returns all available implementations to the caller. The
> + * quantity of implementations is returned by the int return value.
> + */
> +uint32_t
> +dp_netdev_impl_get(const struct dpif_netdev_impl_info_t **out_impls);
> +
> /* This function checks all available DPIF implementations, and selects the
> * returns the function pointer to the one requested by "name".
> */
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 2dfe9003e..b35ccbe3b 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -993,6 +993,27 @@ dpif_netdev_subtable_lookup_set(struct unixctl_conn
> *conn, int argc,
> ds_destroy(&reply);
> }
>
> +static void
> +dpif_netdev_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
> + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
> +{
> + const struct dpif_netdev_impl_info_t *dpif_impls;
> + uint32_t count = dp_netdev_impl_get(&dpif_impls);
> + if (count == 0) {
> + unixctl_command_reply_error(conn, "error getting dpif names");
> + return;
> + }
> +
> + /* Add all dpif functions to reply string. */
> + struct ds reply = DS_EMPTY_INITIALIZER;
> + ds_put_cstr(&reply, "Available DPIF implementations:\n");
> + for (uint32_t i = 0; i < count; i++) {
> + ds_put_format(&reply, " %s\n", dpif_impls[i].name);
> + }
> + unixctl_command_reply(conn, ds_cstr(&reply));
> + ds_destroy(&reply);
> +}
> +
> static void
> dpif_netdev_impl_set(struct unixctl_conn *conn, int argc,
> const char *argv[], void *aux OVS_UNUSED)
> @@ -1294,6 +1315,9 @@ dpif_netdev_init(void)
> "dpif_implementation_name [dp]",
> 1, 2, dpif_netdev_impl_set,
> NULL);
> + unixctl_command_register("dpif-netdev/dpif-get", "",
> + 0, 0, dpif_netdev_impl_get,
> + NULL);
> return 0;
> }
>
> --
> 2.31.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
More information about the dev
mailing list