-
Notifications
You must be signed in to change notification settings - Fork 29
Fix tls python offload with libxlio #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,10 +116,34 @@ template <typename T> static void dlsym_default(T &ptr, const char *name) | |
| dlsym_handle(ptr, name, RTLD_DEFAULT); | ||
| } | ||
|
|
||
| #define XLIO_TLS_API_FIND(__name) dlsym_default(s_tls_api.__name, #__name); | ||
| static void *openssl_handle = nullptr; | ||
|
|
||
| void xlio_tls_api_setup() | ||
| #define XLIO_TLS_API_FIND(__name) dlsym_handle(s_tls_api.__name, #__name, openssl_handle); | ||
|
|
||
| inline bool check_openssl_loaded() | ||
| { | ||
| openssl_handle = dlopen("libssl.so.3", RTLD_NOW | RTLD_GLOBAL); | ||
| if (!openssl_handle) { | ||
| vlog_printf(VLOG_DEBUG, "Failed to dlopen libssl.so.3: %s", dlerror()); | ||
| return false; | ||
| } else { | ||
| vlog_printf(VLOG_DEBUG, "Successfully loaded libssl.so.3"); | ||
| return true; | ||
| } | ||
| } | ||
|
Comment on lines
+123
to
+133
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using |
||
|
|
||
| inline void xlio_tls_api_setup() | ||
| { | ||
| if (openssl_handle) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest trying the symbols first the old way without openssl_handle as this is a more generic way and does not require loading a specific lib file. And only if it fails then to fallback to dlopen
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, the application can be statically linked. |
||
| // OpenSSL symbols is already loaded | ||
| return; | ||
| } | ||
|
|
||
| if (!check_openssl_loaded()) { | ||
| vlog_printf(VLOG_DEBUG, "OpenSSL library not found or failed to load"); | ||
| return; | ||
| } | ||
|
|
||
| XLIO_TLS_API_FIND(EVP_CIPHER_CTX_new); | ||
| XLIO_TLS_API_FIND(EVP_CIPHER_CTX_free); | ||
| XLIO_TLS_API_FIND(EVP_CIPHER_CTX_reset); | ||
|
|
@@ -132,6 +156,7 @@ void xlio_tls_api_setup() | |
| XLIO_TLS_API_FIND(EVP_EncryptInit_ex); | ||
| XLIO_TLS_API_FIND(EVP_EncryptUpdate); | ||
| XLIO_TLS_API_FIND(EVP_EncryptFinal_ex); | ||
|
|
||
| if (s_tls_api.EVP_CIPHER_CTX_new && s_tls_api.EVP_CIPHER_CTX_free && | ||
| s_tls_api.EVP_CIPHER_CTX_reset && s_tls_api.EVP_aes_128_gcm && s_tls_api.EVP_aes_256_gcm && | ||
| s_tls_api.EVP_DecryptInit_ex && s_tls_api.EVP_DecryptUpdate && | ||
|
|
@@ -508,6 +533,9 @@ int sockinfo_tcp_ops_tls::setsockopt(int __level, int __optname, const void *__o | |
| return -1; | ||
| } | ||
| } else { | ||
| #ifdef DEFINED_UTLS | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for this ifdef this whole code is under this ifdef
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we put it just before if (unlikely(!g_tls_api)) ? |
||
| xlio_tls_api_setup(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current implementation is not thread safe. Such a runtime initialization needs to be protected. consider some kind of thread safe singleton assuming that a pointer assignment is an atomic operation on the target platforms (no need to lock the check for openssl API initialization) |
||
| #endif /* DEFINED_UTLS */ | ||
| /* RX offload checks. */ | ||
| if (unlikely(!m_p_sock->is_utls_supported(UTLS_MODE_RX))) { | ||
| si_ulp_logdbg("TLS_RX is not supported."); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the library can change in the future. at least it should be some changeable define somewhere