Skip to content

ares_conn: use sock_funcs.agetsockname() instead of getsockname()#895

Merged
bradh352 merged 1 commit intoc-ares:mainfrom
tchaikov:set_self_ip
Oct 9, 2024
Merged

ares_conn: use sock_funcs.agetsockname() instead of getsockname()#895
bradh352 merged 1 commit intoc-ares:mainfrom
tchaikov:set_self_ip

Conversation

@tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Oct 9, 2024

this change addresses an issue with DNS cookie invalidation for users of the legacy API and custom network stacks (e.g., Seastar's DNS).

in 0274543, we added an optional agetsockname to ares_socket_functions_ex struct, and intended to skip calling this function in DNS cookie invalidation if this function is not available for legacy API users.

but we are still calling this system call directly, this fails Seastar's DNS which uses c-ares to resolve names, and it uses the socket function table to override the network stack to use its own userspace TCP/IP stack, in that case, the fd passed to c-ares is not a valid file descriptor, hence the call fails.

in this change, we

  • replace direct getsockname() call with sock_funcs.agetsockname()
  • skip the call if agetsockname() is not configured

Refs 0274543

this change addresses an issue with DNS cookie invalidation for users of
the legacy API and custom network stacks (e.g., Seastar's DNS).

in 0274543, we added an optional `agetsockname` to `ares_socket_functions_ex`
struct, and intended to skip calling this function in DNS cookie
invalidation if this function is not available for legacy API users.

but we are still calling this system call directly, this fails
Seastar's DNS which uses c-ares to resolve names, and it uses the
socket function table to override the network stack to use its own
userspace TCP/IP stack, in that case, the fd passed to c-ares is not a
valid file descriptor, hence the call fails.

in this change, we

- replace direct getsockname() call with sock_funcs.agetsockname()
- skip the call if agetsockname() is not configured

Refs 0274543

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
@tchaikov
Copy link
Contributor Author

tchaikov commented Oct 9, 2024

@bradh352 hi Brad, could you please help review this change? i tested the main HEAD with Seastar, the dns tests failed with the same error. but after applying this change, the tests exercising seastar's dns subsystem passed.

@tchaikov
Copy link
Contributor Author

tchaikov commented Oct 9, 2024

see also the discussion at #893 (comment)

@bradh352
Copy link
Member

bradh352 commented Oct 9, 2024

ugh, I apparently committed the changes to ares_conn.c in a different branch I was working on. Sorry about that. I'll go ahead and accept this PR as mine did basically the same thing.

@bradh352 bradh352 merged commit 3f55f80 into c-ares:main Oct 9, 2024
@tchaikov tchaikov deleted the set_self_ip branch October 9, 2024 10:38
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.

2 participants