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

Re: Issues found by inetutils-ifconfig.

Dear Justus Winter!

[CC is desirable]

Thursday den 16 July 2015 klockan 13:01 skrev Justus Winter detta:
> >   * The hardware type of an adaper is encoded in the member
> >     `ifr_hwaddr.sa_family' of `struct ifreq'. An ethernet
> > ...
> That is surprising indeed.  A superficial look revealed that it should
> indeed be set to ARPHRD_LOOPBACK:
> pfinet/linux-src/include/linux/if_arp.h:#define ARPHRD_LOOPBACK   772             /* Loopback device              */
> [...]
> pfinet/loopback.c:        dev->type               = ARPHRD_LOOPBACK;

Is `type' mapped correctly to the correct member of `struct sockaddr',
i.e., to `sa_family'? Also, for Ethernet devices, is ARPHRD_ETHER
assigned ro `dev->type'?

For our common reference in this discussion, the structure populating
call is ioctl(sfd, SIOCGIFHWADDR, &ifr), after which evaluation
of `ifr.ifr_hwaddr.sa_family' should follow. GNU/Linux does return
772 for ARPHRD_LOOPBACK, while BSD systems use a different mechanism
for best portability over different versions.

> >   * The ioctl calls for SIOCGIFDSTADDR of `lo' as well as of
> > ...
> Hmmm.  Currently, the call returns the `ifa_address' field, which for
> PTP is the peer address, but for normal interfaces is the interfaces
> address itself.  Do you want the call to fail for non-PTP interfaces?

I have identified this as a regression in our code, as of
Februay 2014, so the issue is now resolved. As a side effect
the broadcast address is printed also in the default output
format 'gnu', not only in 'unix'. Another pending change is
that the ethernet address will also be printed after next commit!

A new issue appeared today when setting various values using
a parsed command line of ifconfig: ioctl(sfd, SIOCSIFMETRIC, &ifr)
fails with 'Inappropriate ioctl for device', meaning that this
system call is not implemented. The identical generic code snippet
works for GNU/Linux and OpenIndiana, and has done so for BSD in
the past. Explanation?

Best regards,
  Mats Erik Andersson

Reply to: