In my opinion, the priorities in address selection should be the following:
1. always use prefsrc if it is specified
2. then for local routes, use destination
3. as a last resort, call that function guessing the address...
> 127.0.0.1). Hm, may be then a bind() call to the same IP will be required
> before connecting? If bind fails, then the address is not local. If
> not, connect() should succeed and getsockname should return the same
> IP (the preferred source will not be considered in this case from
> the kernel).
I would say that using of bound sockets is a bit risky.
I'm not sure whether such a connect may succeed with 2.2 kernels and
transparent proxy support, for example.
An unbound UDP connect, as autofs does, is a good solution if the mistakes are
The behavior of autofs in case of a mistake, as Peter explained, looks
reasonable and acceptable for me.
Using GETROUTE as Andi suggested is the other good alternative.
But it won't work without NETLINK socket support compiled in.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/