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 sock_subsystem_init(void) 14 { 15 const char *sock_impl_override = getenv("SPDK_SOCK_IMPL_DEFAULT"); 16 int rc = 0; 17 18 if (sock_impl_override) { 19 rc = spdk_sock_set_default_impl(sock_impl_override); 20 if (rc) { 21 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 SPDK_NOTICELOG("Default socket implementation override: %s\n", 26 sock_impl_override); 27 } 28 } 29 30 spdk_subsystem_init_next(rc); 31 } 32 33 static void 34 sock_subsystem_fini(void) 35 { 36 spdk_subsystem_fini_next(); 37 } 38 39 static void 40 sock_subsystem_write_config_json(struct spdk_json_write_ctx *w) 41 { 42 spdk_sock_write_config_json(w); 43 } 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 SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_sock); 53