Commit 68d213ea authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

sock: add default impl override



Read environmental variable 'SPDK_SOCK_IMPL_DEFAULT' and override the
default socket implementation (POSIX) with its value during
sock_subsystem_init().

This is done mainly to enable original behavior where a socket with
highest priority would be used by default (e.g. uring if configure
was run with '--with-uring' option). That way we may explicitly enable
chosen implementation as default, without relying on RPC interface.

As part of this patch, link sock modules into the app_repeat test app.
The method used here works even when for the app repeat case, so let's test it.
This allows us to just generally declare this flag for all tests and not have
to worry about apps like app_repeat that link in the sock library but none of
the sock modules.

Change-Id: I6af633cbe5bfba065580ba6c501169cbb5b64541
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22691


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 7521dc6f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ DEPDIRS-event_scsi := init scsi event_bdev
DEPDIRS-event_iscsi := init iscsi event_scheduler event_scsi event_sock
DEPDIRS-event_vhost_blk := init vhost
DEPDIRS-event_vhost_scsi := init vhost event_scheduler event_scsi
DEPDIRS-event_sock := init sock
DEPDIRS-event_sock := init sock log
DEPDIRS-event_vfu_tgt := init vfu_tgt
DEPDIRS-event_iobuf := init log thread util $(JSON_LIBS)
DEPDIRS-event_keyring := init json keyring
+18 −1
Original line number Diff line number Diff line
@@ -6,11 +6,28 @@
#include "spdk/stdinc.h"
#include "spdk/sock.h"
#include "spdk_internal/init.h"
#include "spdk_internal/sock.h"
#include "spdk/log.h"

static void
sock_subsystem_init(void)
{
	spdk_subsystem_init_next(0);
	const char *sock_impl_override = getenv("SPDK_SOCK_IMPL_DEFAULT");
	int rc = 0;

	if (sock_impl_override) {
		rc = spdk_sock_set_default_impl(sock_impl_override);
		if (rc) {
			SPDK_ERRLOG("Could not override socket implementation with: %s,"
				    " set by SPDK_SOCK_IMPL_DEFAULT environment variable\n",
				    sock_impl_override);
		} else {
			SPDK_NOTICELOG("Default socket implementaion override: %s\n",
				       sock_impl_override);
		}
	}

	spdk_subsystem_init_next(rc);
}

static void
+7 −1
Original line number Diff line number Diff line
@@ -17,8 +17,14 @@ SPDK_LIB_LIST += event_nbd

BLOCKDEV_LIST = bdev_malloc bdev_null
BLOCKDEV_LIST += bdev_aio

SOCK_LIST = sock_posix
ifeq ($(CONFIG_URING),y)
SOCK_LIST += sock_uring
endif

SYS_LIBS += -laio

SPDK_LIB_LIST += $(BLOCKDEV_LIST) event
SPDK_LIB_LIST += $(BLOCKDEV_LIST) $(SOCK_LIST) event

include $(SPDK_ROOT_DIR)/mk/spdk.app.mk