omniosorg / illumos-omnios

Community developed and maintained version of the OS/Net consolidation
https://omnios.org
161 stars 78 forks source link

Why is SO_REUSEPORT only defined for _KERNEL? #1410

Open bsiegert opened 8 months ago

bsiegert commented 8 months ago

Hi! pkgsrc developer here. One of our users wanted to compile Caddy (a Go binary) with support for SO_REUSEPORT. I tried adding the definition to golang.org/x/sys using the standard way, which involves taking values from C header files.

I found that commit b98c37dfd78bd387b2889c2f1bc6db5e2ff64987 added this support for OmniOS but put the constant into an #ifdef _KERNEL block. This seems wrong to me, since _KERNEL typically switches from user-mode to intra-kernel interfaces. Is this a bug? Or is it deliberate?

/cc @pfmooney, who wrote that code.

danmcd commented 8 months ago

SO_REUSEPORT is not generalized, and is there, for now exclusively, for LX brand sockets. Hence the _KERNEL ifdef.

pfmooney commented 8 months ago

To add a little more color: The SO_REUSEPORT implementation added for LX is TCP-only, and really lacking in functionality. It only basically covers the "I want to reload haproxy without closing the socket" use case, and isn't especially robust at that. Because of its shortcomings, it was not exposed to the native system.