If net.ipv4.ip_nonlocal_bind is enabled, the following code in
tcp_conn_from_tap gets very confused:
if (!bind(s, sa, sl)) {
tcp_rst(c, conn); /* Nobody is listening then */
return;
}
if (errno != EADDRNOTAVAIL && errno != EACCES)
conn_flag(c, conn, LOCAL);
This is especially visible if net.ipv4.ip_unprivileged_port_start is
set to a value lower than the default. For example, if
net.ipv4.ip_unprivileged_port_start=443 and
net.ipv4.ip_nonlocal_bind=1, the bind()==0 branch will be hit for all
outgoing connections going to port 443 because bind() succeeds even
when "sa" contains the remote address, and pretty much nothing will
work.
It might the best to skip the check and marking connections as LOCAL if
net.ipv4.ip_nonlocal_bind is enabled? If that doesn't seem reasonable,
then maybe show a warning at start and/or just document that the
ip_nonlocal_bind setting shouldn't be used with passt?
-Valtteri