bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ifconfig and some minor fixes.


From: Sergey Poznyakoff
Subject: Re: ifconfig and some minor fixes.
Date: Sat, 23 Jun 2001 16:24:23 +0300

> >   Not sure I understand the #include <sys/sockio.h>
> >   but I've use it in if_index.c too.
> 
> We should remove it if nobody knows what it is for.  Sergey?
> (I don't want to start the first release of ifconfig with anonymous cruft ;)

sys/sockio.h is where Solaris defines SIOCSIF.* and SIOCGIF.* stuff.
It can safely be omitted provided <sys/ioctl.h> is included instead
(which is the case with new if_index.c).

> I reverted the SYSTEM_{SHORT,LONG}_OPTIONS change in options.c.  I don't
> know why everybody thinks they should be defined.  They are only to be
> defined if the system provides additional options.  I plan to use them to
> decide if such options are provided later on.  Defining them to nothing will
> defeat this.  Every place where they are used (only one currently, this is
> still not worked out) will be protected by #ifdef.

Actually, the reason for this change was that SYSTEM_.*_OPTIONS
were not protected by ifdef in the version 1.1 of options.c :^)


Another note about if_index.c: It works fine, but there seems to be
an inconsistency in using SIOCGIFINDEX. if_nameindex() contains:

# if defined(SIOCGIFINDEX)
      if (ioctl (fd, SIOCGIFINDEX, cur) < 0)
        idx[i].if_index = cur->ifr_index;
      else
# endif
        idx[i].if_index =  i + 1;

i.e. if SIOCGIFINDEX is defined but fails, the information about
the interface is returned anyway. On the other hand,
if_nametoindex() just returns error when it fails:

  if (ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
    {
      int saved_errno = errno;
      close (fd);
      if (saved_errno == EINVAL)
        errno = ENOSYS;
      return 0;
    }

As usual, the problem manifests itself on Solaris :^)
On the Solaris box where I am testing the stuff, SIOCGIFINDEX
call fails for all interfaces. if_nameindex() returns all the
interfaces correctly, but if_nametoindex() bails out and makes
the program quit. After changing if_nametoindex() to work as
if SIOCGIFINDEX was not defined, everything worked smoothly.
Apparently, SIOCGIFINDEX is broken on this version of Solaris
(it was 5.7 Generic). I am going to check it on SPARCs also. 
Nevertheless I would suggest that both if_nametoindex() and
if_nameindex() behave in the same manner: if SIOCGIFINDEX fails
they both should fall back to the similar method of assigning
the index. 

Regards,
Sergey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]