[PATCH] Added so_freebind and so_transparent to the listen directive

Piotr Sikora piotr at cloudflare.com
Thu Mar 27 20:38:10 UTC 2014

Hi Trygve,

> Added so_freebind and so_transparent to the listen directive
> This solves a Linux/IPv6-specific problem.
> To be able to listen to an IPv6 address that is not yet available on the host,
> one need to use the IP_FREEBIND and IP_TRANSPARENT socket options.
> The use case in question is for a failover setup with several service-
> addresses in a IPv6-only environment.
> IPv4 has a sysctl available (ip_nonlocal_bind), which is not available for
> IPv6 - thus making these patches necessary.

Non-local bind() isn't Linux-specific feature. FreeBSD has
IP_BINDANY/IPV6_BINDANY options and OpenBSD has SO_BINDANY option, so
it would be good to add support for all of them.

Also, requiring user to add both: "so_freebind" and "so_transparent"
options to enable single feature doesn't look very user friendly,
especially because according to your description, non-local bind()
would work just fine with only "so_freebind" for IPv4 addresses, but
it would fail for IPv6 addresses... I don't think that the "so_"
prefix is necessary, how about just "bindany" or "nonlocal"
("freebind" is just stupid name)?

Best regards,
Piotr Sikora

More information about the nginx-devel mailing list