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
Add support for client-side TCP FastOpen to KQueue MacOS #11560
Conversation
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java
Outdated
Show resolved
Hide resolved
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java
Outdated
Show resolved
Hide resolved
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java
Outdated
Show resolved
Hide resolved
const struct iovec* iov = (const struct iovec*) iovAddress; | ||
unsigned int iovcnt = (unsigned int) iovCount; | ||
size_t len = (size_t) iovDataLength; | ||
int result = connectx(socket, &endpoints, SAE_ASSOCID_ANY, flags, iov, iovcnt, &len, NULL); |
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.
nit: if result
isn't needed outside the conditional consider inlining the call to connectx
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.
It takes a lot of arguments, so I find this style easier to read.
endpoints.sae_dstaddrlen = dstaddrlen; | ||
} | ||
|
||
int socket = (int) socketFd; |
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.
nit: these calls can be inlined, may make it easier for compiler to remove intermediate storage and less intermediate variable noise in the code if they are only used once.
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.
I don't understand this concern with local variables.
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.
fine to leave as is but the goal would be to decrease noise in the code and aid readability (why are there multiple variables, can their values change independently, what is the memory lifetime/location of each, etc.).
@Scottmitch addressed your comments, please take a look. |
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/Native.java
Outdated
Show resolved
Hide resolved
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java
Outdated
Show resolved
Hide resolved
endpoints.sae_dstaddrlen = dstaddrlen; | ||
} | ||
|
||
int socket = (int) socketFd; |
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.
fine to leave as is but the goal would be to decrease noise in the code and aid readability (why are there multiple variables, can their values change independently, what is the memory lifetime/location of each, etc.).
@Scottmitch @NiteshKant @normanmaurer I've verified that this works locally; was able to establish a TFO connection from a MacOS host, running with kqueue, to a Linux guest VM running with Epoll, and see the SslHandlers ClientHello get transferred with the SYN packet on repeated connections. |
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.
lgtm assuming this has been tested/verified locally ... ideally a unit test would be added to verify that nothing breaks when these options are used (even if we don't verify that app data is included in the SYN)
@Scottmitch yeah, been working on adding this to the kqueue test permutations |
932a5d9
to
c735f6c
Compare
…lues as class constants in Native
…INPROGRESS Make sure we handle that as a successful call.
Also fix a bug where using TFO with KQueue would prematurely consider the socket connected. Instead, the socket should assume to be connect-in-progress when using TFO since all our sockets are non-blocking.
c735f6c
to
4577097
Compare
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.
As C is greek for me, I am relying on Scott's review of the C code. Overall looks good to me, just a few questions about the return value.
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/BsdSocket.java
Outdated
Show resolved
Hide resolved
transport-native-kqueue/src/main/java/io/netty/channel/kqueue/KQueueSocketChannel.java
Outdated
Show resolved
Hide resolved
…g connectx/TCP FastOpen on MacOS
Motivation: The MacOS-specific `connectx(2)` system call make it possible to establish client-side connections with TCP FastOpen. Modification: Add support for TCP FastOpen to the KQueue transport, and add the `connectx(2)` system call to `BsdSocket`. Result: It's now possible to use TCP FastOpen when initiating connections on MacOS.
Motivation: The MacOS-specific `connectx(2)` system call make it possible to establish client-side connections with TCP FastOpen. Modification: Add support for TCP FastOpen to the KQueue transport, and add the `connectx(2)` system call to `BsdSocket`. Result: It's now possible to use TCP FastOpen when initiating connections on MacOS.
Motivation: The MacOS-specific `connectx(2)` system call make it possible to establish client-side connections with TCP FastOpen. Modification: Add support for TCP FastOpen to the KQueue transport, and add the `connectx(2)` system call to `BsdSocket`. Result: It's now possible to use TCP FastOpen when initiating connections on MacOS.
Motivation: The MacOS-specific `connectx(2)` system call make it possible to establish client-side connections with TCP FastOpen. Modification: Add support for TCP FastOpen to the KQueue transport, and add the `connectx(2)` system call to `BsdSocket`. Result: It's now possible to use TCP FastOpen when initiating connections on MacOS.
Motivation:
The MacOS-specific
connectx(2)
system call make it possible to establish client-side connections with TCP FastOpen.Modification:
Add support for TCP FastOpen to the KQueue transport, and add the
connectx(2)
system call toBsdSocket
.Result:
It's now possible to use TCP FastOpen when initiating connections on MacOS.