Commit 2432eadf authored by Ben Walker's avatar Ben Walker Committed by Konrad Sztyber
Browse files

sock: Add spdk_sock_get_default_impl



Sometimes code wants to set a socket option, but it doesn't know which
impl the user has selected. Add a way to get it.

Change-Id: Iecfb9b9776d8e8729dda11459eda47a18366cba8
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18006


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 84c04174
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -597,7 +597,7 @@ int spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_o
			    size_t len);

/**
 * Set the given sock implementation to be used a default one.
 * Set the given sock implementation to be used as the default one.
 *
 * Note: passing a specific sock implementation name in some sock API functions
 * (such as @ref spdk_sock_connect, @ref spdk_sock_listen and etc) ignores the default value set by this function.
@@ -607,6 +607,13 @@ int spdk_sock_impl_set_opts(const char *impl_name, const struct spdk_sock_impl_o
 */
int spdk_sock_set_default_impl(const char *impl_name);

/**
 * Get the name of the current default implementation
 *
 * \return The name of the default implementation
 */
const char *spdk_sock_get_default_impl(void);;

/**
 * Write socket subsystem configuration into provided JSON context.
 *
+17 −0
Original line number Diff line number Diff line
@@ -954,4 +954,21 @@ spdk_sock_set_default_impl(const char *impl_name)
	return 0;
}

const char *
spdk_sock_get_default_impl(void)
{
	struct spdk_net_impl *impl = NULL;

	if (g_default_impl) {
		return g_default_impl->name;
	}

	impl = STAILQ_FIRST(&g_net_impls);
	if (impl) {
		return impl->name;
	}

	return NULL;
}

SPDK_LOG_REGISTER_COMPONENT(sock)
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
	spdk_sock_impl_get_opts;
	spdk_sock_impl_set_opts;
	spdk_sock_set_default_impl;
	spdk_sock_get_default_impl;
	spdk_sock_write_config_json;

	# internal function in spdk_internal/sock.h