Skip to content

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

Open
wants to merge 2 commits into
base: vNext
Choose a base branch
from

Conversation

BasharRadya
Copy link
Collaborator

Description

Please provide a summary of the change.

What

Subject: what this PR is doing in one line.

Why ?

Justification for the PR. If there is existing issue/bug please reference.

How ?

It is optional but for complex PRs please provide information about the design,
architecture, approach, etc.

Change type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Check list

  • Code follows the style de facto guidelines of this project
  • Comments have been inserted in hard to understand places
  • Documentation has been updated (if necessary)
  • Test has been added (if possible)

@BasharRadya BasharRadya requested a review from pasis May 7, 2025 11:03
@BasharRadya
Copy link
Collaborator Author

bot:retest

Added getsockopt SO_TYPE option in SOL_SOCKET

Signed-off-by: Bashar Abdelgafer <[email protected]>
Load libssl symbols from speicific handle.

Signed-off-by: Bashar Abdelgafer <[email protected]>
@BasharRadya
Copy link
Collaborator Author

bot:retest

@galnoam galnoam requested review from AlexanderGrissik and removed request for pasis May 8, 2025 11:32
@galnoam
Copy link
Collaborator

galnoam commented May 8, 2025

Hi @pasis , can you review? please give priority its for customer

@galnoam galnoam requested review from pasis and removed request for AlexanderGrissik May 8, 2025 11:52
@@ -508,6 +533,9 @@ int sockinfo_tcp_ops_tls::setsockopt(int __level, int __optname, const void *__o
return -1;
}
} else {
#ifdef DEFINED_UTLS
Copy link
Collaborator

@AlexanderGrissik AlexanderGrissik May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this ifdef this whole code is under this ifdef

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we put it just before if (unlikely(!g_tls_api)) ?


inline bool check_openssl_loaded()
{
openssl_handle = dlopen("libssl.so.3", RTLD_NOW | RTLD_GLOBAL);
Copy link
Collaborator

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

{
if (openssl_handle) {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, the application can be statically linked.

@AlexanderGrissik
Copy link
Collaborator

The changes are OK to be provided as temporary patch

Comment on lines +123 to +133
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;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using dl_iterate_phdr(). It's not standardized and appeared in glibc-2.2.4. I'm not sure you can obtain the handle object to use in dlsym() (don't see a way to obtain the handle from dladdr() and address from the iterator), but at least you can find the libssl exact name (path?). Note that not only the lib name can change over time, but also libssl can be loaded from non-standard paths.

{
if (openssl_handle) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, the application can be statically linked.

@@ -508,6 +533,9 @@ int sockinfo_tcp_ops_tls::setsockopt(int __level, int __optname, const void *__o
return -1;
}
} else {
#ifdef DEFINED_UTLS
xlio_tls_api_setup();
Copy link
Member

Choose a reason for hiding this comment

The 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)

@BasharRadya
Copy link
Collaborator Author

bot:retest

1 similar comment
@BasharRadya
Copy link
Collaborator Author

bot:retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants