Skip to content
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

Merged
merged 12 commits into from Aug 12, 2021

Conversation

chrisvest
Copy link
Contributor

@chrisvest chrisvest commented Aug 6, 2021

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.

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);
Copy link
Member

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

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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

@chrisvest
Copy link
Contributor Author

@Scottmitch addressed your comments, please take a look.

endpoints.sae_dstaddrlen = dstaddrlen;
}

int socket = (int) socketFd;
Copy link
Member

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

@chrisvest chrisvest added this to the 4.1.67.Final milestone Aug 10, 2021
@chrisvest
Copy link
Contributor Author

@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.

@chrisvest chrisvest marked this pull request as ready for review August 10, 2021 13:20
Copy link
Member

@Scottmitch Scottmitch left a 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)

@chrisvest
Copy link
Contributor Author

@Scottmitch yeah, been working on adding this to the kqueue test permutations

Copy link
Member

@NiteshKant NiteshKant left a 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.

@chrisvest chrisvest merged commit f750e2e into netty:4.1 Aug 12, 2021
@chrisvest chrisvest deleted the 41-kqueue-tfo branch August 12, 2021 11:38
chrisvest added a commit that referenced this pull request Aug 12, 2021
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.
laosijikaichele pushed a commit to laosijikaichele/netty that referenced this pull request Dec 16, 2021
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.
laosijikaichele pushed a commit to laosijikaichele/netty that referenced this pull request Dec 16, 2021
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.
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
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.
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.

None yet

3 participants