Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Oct 2001 14:13:24 -0500
From:      Jonathan Lemon <jlemon@flugsvamp.com>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        Jonathan Lemon <jlemon@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sbin/ifconfig ifconfig.c
Message-ID:  <20011017141324.N75389@prism.flugsvamp.com>
In-Reply-To: <Pine.NEB.3.96L.1011017145148.36202A-100000@fledge.watson.org>
References:  <200110171830.f9HIUEW68725@freefall.freebsd.org> <Pine.NEB.3.96L.1011017145148.36202A-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 17, 2001 at 02:52:30PM -0400, Robert Watson wrote:
> 
> On Wed, 17 Oct 2001, Jonathan Lemon wrote:
> 
> > jlemon      2001/10/17 11:30:14 PDT
> > 
> >   Modified files:
> >     sbin/ifconfig        ifconfig.c 
> >   Log:
> >   When specifying an interface to ifconfig, first look up the interface
> >   index, then retrieve statistics for that index, rather than retrieving
> >   all interfaces and then looking for a matching name.  This allows the
> >   user to refer to an interface via an alias name.
> >   
> >   While I'm here, also perform a few assorted cleanups.
> >   
> >   Revision  Changes    Path
> >   1.70      +12 -26    src/sbin/ifconfig/ifconfig.c
> 
> Without looking at the commit itself, that sounds like it's subject to a
> race condition.  How about adding the ability to retrieve interface
> statistics by name, rather than the indirection? 

Well, the information reported by ifconfig is actually built up by
a series of ioctl() calls, all which refer to the interface by name,
as well as a sysctl() call to get interface statistics.

The way ifconfig work(ed) was to perform the sysctl which retrieved a MIB
set listing the interfaces, and then walked down the set looking for the
interface in question.  If found, it then used the name to make further
ioctl() calls to get more information.  I can't change the format of the
data returned (to return interface aliases as well) without breaking 
backward compatability.  :-(

What changed is that we now use the documented if_nametoindex() call
to transform the name into an index, and then use the index to retrieve
the MIB statistics for a specific interface.  The sysctl interface doesn't
allow specification by interface name, unlike the ioctls().  

The ioctls() themselves will now work with either the canonical name or
an alias for the device, so there is some progress in that direction.

We could introduce a new API which allows the interface to be specified
by name instead of index, which would probably be nice to have.  However,
this will not eliminate the myriad races which are already present.
-- 
Jonathan

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011017141324.N75389>