On 2016-10-24 at 02:34 +0100, Jeremy Harris wrote:
> Of course, secondary thoughts, we don't know that the same sequences
> of library calls on FreeBSD as on Linux will do what's wanted. Any
> information you can find about TCP Fast Open on that platform will
> be welcome.
FreeBSD TCP_FASTOPEN:
Support in header files can be present without being enabled in the
kernel, as of FreeBSD 10.2.
FreeBSD 10.1 is still officially supported until the end of this year
and does not have it in header files. (10.2 expires at the same time,
10.1 was an LTS and is the OS under the exbot42 buildfarm animal).
Example code which supposedly works when the kernel is built with
support can be found at:
https://people.freebsd.org/~pkelsey/tfo-tools/
Design doc with state transition diagrams, socket options and sysctls
at:
https://people.freebsd.org/~pkelsey/TFO_Design_Details.pdf
So:
* Need to guard against flag being undef
* Need to gracefully handle the setsockopt() call failing
Looking at <
https://reviews.freebsd.org/rS292706#eeb9b3e9> and searching
for `V_tcp_fastopen_enabled` in the tcp_usrreq.c handling we can see the
setsockopt handling:
--------------------8< tcp_usrreq.c TCP_FASTOPEN >8---------------------
#ifdef TCP_RFC7413
case TCP_FASTOPEN:
INP_WUNLOCK(inp);
if (!V_tcp_fastopen_enabled)
return (EPERM);
error = sooptcopyin(sopt, &optval, sizeof optval,
sizeof optval);
--------------------8< tcp_usrreq.c TCP_FASTOPEN >8---------------------
So, you can expect to get EPERM on many currently deployed FreeBSD
systems.
It's been a decade since I was routinely building my own FreeBSD kernels
instead of running with GENERIC, but if I am finding my way around
right, then:
https://svnweb.freebsd.org/base/head/sys/amd64/conf/
it doesn't look like support is enabled by default even in HEAD for
amd64 yet. So it will fail for almost everyone.
-Phil