Line data Source code
1 : /* SPDX-License-Identifier: BSD-3-Clause 2 : * Copyright (C) 2021 Intel Corporation. 3 : * Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved. 4 : */ 5 : 6 : #include "spdk/stdinc.h" 7 : #include "spdk/sock.h" 8 : #include "spdk_internal/init.h" 9 : #include "spdk_internal/sock.h" 10 : #include "spdk/log.h" 11 : 12 : static void 13 0 : sock_subsystem_init(void) 14 : { 15 0 : const char *sock_impl_override = getenv("SPDK_SOCK_IMPL_DEFAULT"); 16 0 : int rc = 0; 17 : 18 0 : if (sock_impl_override) { 19 0 : rc = spdk_sock_set_default_impl(sock_impl_override); 20 0 : if (rc) { 21 0 : SPDK_ERRLOG("Could not override socket implementation with: %s," 22 : " set by SPDK_SOCK_IMPL_DEFAULT environment variable\n", 23 : sock_impl_override); 24 : } else { 25 0 : SPDK_NOTICELOG("Default socket implementation override: %s\n", 26 : sock_impl_override); 27 : } 28 : } 29 : 30 0 : spdk_subsystem_init_next(rc); 31 0 : } 32 : 33 : static void 34 0 : sock_subsystem_fini(void) 35 : { 36 0 : spdk_subsystem_fini_next(); 37 0 : } 38 : 39 : static void 40 0 : sock_subsystem_write_config_json(struct spdk_json_write_ctx *w) 41 : { 42 0 : spdk_sock_write_config_json(w); 43 0 : } 44 : 45 : static struct spdk_subsystem g_spdk_subsystem_sock = { 46 : .name = "sock", 47 : .init = sock_subsystem_init, 48 : .fini = sock_subsystem_fini, 49 : .write_config_json = sock_subsystem_write_config_json, 50 : }; 51 : 52 0 : SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_sock);