@@ -61,6 +61,13 @@ dp_netdev_impl_get_default(void)
return 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".
@@ -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".
*/
@@ -990,6 +990,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)
@@ -1288,6 +1309,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;
}
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@intel.com> --- v5: - Initial version of this command --- lib/dpif-netdev-private-dpif.c | 7 +++++++ lib/dpif-netdev-private-dpif.h | 6 ++++++ lib/dpif-netdev.c | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+)