Re: Issues found by inetutils-ifconfig.
Quoting Mats Erik Andersson (2015-07-16 18:41:00)
> 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:
> >
> > % grep 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'?
Yes, see pfinet/iioctl-ops.c:286
> Also, for Ethernet devices, is ARPHRD_ETHER assigned ro `dev->type'?
Yes.
> 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.
I can't find that in the inetutils source as packaged by Debian.
Furthermore, I cannot get ifconfig to do that ioctl:
teythoon@darnassus:~/inetutils/inetutils-1.9.4$ rpctrace 2>&1 inetutils-ifconfig --interface=lo | grep iioctl
159<--158(pid9220)->iioctl_siocgifindex ("lo" 18810080) = 0 "lo" 1
159<--160(pid9220)->iioctl_siocgifindex ("lo" 18923840) = 0 "lo" 1
157<--156(pid9220)->iioctl_siocgifaddr ("lo" "") = 0 "lo" ""
157<--156(pid9220)->iioctl_siocgifaddr ("lo" "") = 0 "lo" ""
157<--156(pid9220)->iioctl_siocgifnetmask ("lo" "") = 0 "lo" ""
157<--156(pid9220)->iioctl_siocgifnetmask ("lo" "") = 0 "lo" ""
157<--156(pid9220)->iioctl_siocgifflags ("lo" 512) = 0 "lo" 73
157<--156(pid9220)->iioctl_siocgifflags ("lo" 73) = 0 "lo" 73
157<--156(pid9220)->iioctl_siocgifflags ("lo" 73) = 0 "lo" 73
157<--156(pid9220)->iioctl_siocgifflags ("lo" 73) = 0 "lo" 73
157<--156(pid9220)->iioctl_siocgifmtu ("lo" 73) = 0 "lo" 3924
157<--156(pid9220)->iioctl_siocgifmtu ("lo" 3924) = 0 "lo" 3924
157<--156(pid9220)->iioctl_siocgifmetric ("lo" 3924) = 0 "lo" 0
Hurds ioctl mechanism does some non-trivial manual decoding of the
arguments in the libc. It could be that the value is truncated there.
> > > * 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!
Cool!
> 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?
Easy. This functionality is not implemented. See
pfinet/iioctl-ops.c:218 and :238 respectively.
Justus
Reply to: