Commit 5dc69b17 authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Tomasz Zawadzki
Browse files

sock/posix: return errno instead -1 on ssl conf



This is a prework change for future updates where more precise errors
will be returned to the user.

Note that passing the SSL error directly is not an option, as SSL errors
do not use errno. Instead, EPROTO was chosen as a generic error code for
SSL-related issues.

As part of this change, errno was also removed from log messages, since
the SSL utility functions do not set it.

Change-Id: I7d47eb0ad0d93292e7a98ad4460e0944dba6d2cc
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26105


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
parent ee36df5b
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -765,16 +765,16 @@ posix_sock_configure_ssl(struct spdk_posix_sock *sock, bool client)
	sock->ssl_ctx = posix_sock_create_ssl_context(client ? TLS_client_method() : TLS_server_method(),
			&sock->base.impl_opts);
	if (!sock->ssl_ctx) {
		SPDK_ERRLOG("posix_sock_create_ssl_context() failed, errno = %d\n", errno);
		return -1;
		SPDK_ERRLOG("posix_sock_create_ssl_context() failed\n");
		return -EPROTO;
	}

	sock->ssl = setup_fn(sock->ssl_ctx, sock->fd);
	if (!sock->ssl) {
		SPDK_ERRLOG("ssl_sock_setup_%s() failed, errno = %d\n", client ? "connect" : "accept", errno);
		SPDK_ERRLOG("ssl_sock_setup_%s() failed\n", client ? "connect" : "accept");
		SSL_CTX_free(sock->ssl_ctx);
		sock->ssl_ctx = NULL;
		return -1;
		return -EPROTO;
	}

	SSL_set_app_data(sock->ssl, &sock->base.impl_opts);