5 ms·
Has anyone seen a good code example of sending server response data in a SYN+ACK packet on Linux? Last time I tried it didn't seem to work - I could only get da
by mkj 5y ago
Has anyone seen a good code example of sending server response data in a SYN+ACK packet on Linux? Last time I tried it didn't seem to work - I could only get data in the client's SYN, the server sends an empty SYN+ACK. Perhaps I'm mistaken in what Fast Open is mean to allow.
- paraboul 5y agoTCP_DEFER_ACCEPT is probably what you're looking for (SO_ACCEPTFILTER on BSD/macos) : https://github.com/paraboul/libapenetwork/blob/6e5acac08467b818914ba600a9985e04ccfd32c6/src/ape_socket.c#L266-L334 https://github.com/paraboul/libapenetwork/blob/6e5acac08467b...
- mkj 5y agoI don't think TCP_DEFER_ACCEPT does that - "Allow a listener to be awakened only when data arrives on" it just changes the timing of accept()? What you describe sounds more like TCP_CORK, but I don't think that'll work. Looking a bit more at the network stack perhaps the SYN+ACK is sent straight from the SYN handler with no chance for userspace to pack any data in. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/tcp_input.c?h=v5.13#n6860 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin... Edit: Ah, you are right about TCP_DEFER_ACCEPT putting data in the ACK on the client side, I'd forgotten about that. https://lore.kernel.org/netdev/CAK3+h2ydKQ15U1_2dqWsHAL_LKYm-1xbJvUbeaMJShoOCU_TsA@mail.gmail.com/ https://lore.kernel.org/netdev/CAK3+h2ydKQ15U1_2dqWsHAL_LKYm...
- paraboul 5y agoOops my bad, indeed.