if_nameindex with 2.2 kernel

Roland McGrath roland@frob.com
Wed Jul 24 14:03:00 GMT 2002


> > So in my tree I have made it try AF_INET first unconditionally, so my
> > getifaddrs implementation can work (and I noticed along the way that
> > the reorder option in /etc/host.conf can't possibly be working without
> > that change).
> 
> Why the latter?  And maybe the __opensock interface needs to be revised.

It uses SIOCGIFNETMASK to do its essential work.  That ioctl is only
supported by an AF_INET socket or an AF_PACKET socket in a kernel with inet
support.  Anyone making use of reorder in host.conf would seem to be asking
for IPv4-specific support.

It's not clear to me that __opensock is actually useful for anything other
than if_nameindex.  The extant other user is res_hconf.c, which
specifically needs IPv4 information and so might as well just create an
AF_INET socket directly.  I've written a getifaddrs using it, but that too
requires specifically an IPv4 socket for SIOCGIFADDR et al to work.  I'm
not sure exactly what getifaddrs ought to do to support IPv6 or other
families.  AFAICT there aren't ioctl interfaces for fetching that
information from the other network stacks, so if there were support for
IPv6 or other types it would use some different method (/proc/net or
whatever).  The getifaddrs interface doesn't provide a way to report
multiple addresses for an interface e.g. in the case of one that has both
ipv6 and ipv4 addresses.  So this might reasonably be considered another
case that is ipv4-specific and hence can use an AF_INET socket unconditionally.
So that still leaves nothing but if_nameindex using __opensock at all.



More information about the Libc-hacker mailing list