Re: notion of a local address [was: Re: ioctl SIOCGIFNETMASK: ip aliasbug 2.4.9 and 2.2.19]

From: Julian Anastasov (ja@ssi.bg)
Date: Fri Sep 07 2001 - 05:10:01 EST


        Hello,

Andrey Savochkin wrote:

> > > connect a datagram socket (which won't produce any actual traffic) to
> > > the remote host with INADDR_ANY as the local address, and then query
> > > the local address. If the local address is the same as the remote
> > > address, the address is local.
> >
> > That will always work, even when you have multiple ethernet
> > interfaces??
>
> It will work almost always, except cases where administrator set different
> preffered sources in local routes.

        It seems if connect() is called without bind() and the target
is local address the selected source is the same (the preferred address
is not used). The postfix guys simply can try this proposal (I don't
know whether they tried it already). I don't expect netfilter to make
loops by connecting the both ends on same host, so such solution can
return the best actual result that is possible at the time of the request.
Any assumptions on daemon start what are the local IP addresses can be
wrong for some strange setups.

        May be someone can check whether this is a portable way to
check whether one IP is local. [We know that bind() to IP is not such
solution, at least in Linux]. If this is true, I think, it is better than
using ioctls or talking rtnetlink.

        As for the "local networks" there is no such thing. There are
trusted and non-trusted networks, gatewayed and non-gatewayed, etc. So, it
should be a user-defined setting, if used somehow at all.

> I.e. it is indeed a very good approximation, but autofs shouldn't still hang
> or do nasty things if the check with the datagram socket shows that address
> isn't local, but in reality it happens to be local.
> A subtle misbehavior or loss of efficiency are acceptable, in my opinion.

Regards

--
Julian Anastasov <ja@ssi.bg>

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Sep 07 2001 - 21:00:39 EST