lkml.org 
[lkml]   [2001]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: notion of a local address [was: Re: ioctl SIOCGIFNETMASK: ip alias bug 2.4.9 and 2.2.19]
On Thu, Sep 06, 2001 at 12:50:51PM -0400, Wietse Venema wrote:
> That is not practical. Surely there is an API to find out if an IP
> address connects to the machine itself. If every UNIX system on
> this planet can do it, then surely Linux can do it.

It's not possible in the general case; e.g. it has to ignore NAT rules
and some of the more advanced features of policy routing

The API is rtnetlink. You can send a RTM_GETROUTE message and the kernel
will send you the routing entry for it; which has the RTN_LOCAL type for
local addresses.

> The same issue is true for local subnets. Surely there exists an
> API to find out what subnetworks a machine is attached to. If every
> UNIX system on this planet can do it, then surely Linux can do it.

You could resolve the backwards address using rtnetlink again and check
the resulting route for LINK scope. Again it is only an approximation
and will break in some/many cases.


-Andi
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:17    [W:0.285 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site