• Ralf Baechle's avatar
    Fix incorrect ARP output · 479bb4a7
    Ralf Baechle authored
    arp(8) obtains the information it prints the old way from /proc/net/arp
    which for incomplete ARP entries contains no HW address such as in the
    following example:
    
    IP address       HW type     Flags       HW address            Mask     Device
    192.168.122.99   0x1         0x0         00:00:00:00:00:00     *        ens3
    192.168.122.98   0x1         0x0         00:00:00:00:00:00     *        ens3
    192.168.122.1    0x1         0x2         52:54:00:00:5d:5f     *        ens3
    172.20.1.99      0x3         0x0              *        bpq0
    10.0.0.2         0x1         0x0         00:00:00:00:00:00     *        ens7
    
    This means the scanf call will incorrectly scan the * character for the
    HW address, the device (bpq0 in above example) for the mask and nothing
    for the device, that is the last scanf'ed device name or "-" if non has
    been read before, will be used resulting in the following incorrect output
    for 172.20.1.99:
    
    Address                  HWtype  HWaddress           Flags Mask            Iface
    [...]
    172.20.1.99                      (incomplete)                              ens3
    
    Fixed by calling scanf a 2nd time if we notice that the first time around
    only 5 elements were read.
    
    Arguably this is a kernel bug caused by the silly attempt of printing a
    MAC address that consists of only blanks for incomplete ARP entries of
    HW type 0x3 but it exists for so long that it virtually has become part of
    the API so this just tries to live with it.
    Signed-off-by: 's avatarRalf Baechle <ralf@linux-mips.org>
    479bb4a7
Name
Last commit
Last update
RPM Loading commit data...
include Loading commit data...
lib Loading commit data...
man Loading commit data...
po Loading commit data...
.cvsignore Loading commit data...
.gitignore Loading commit data...
ABOUT-NLS Loading commit data...
COPYING Loading commit data...
INSTALLING Loading commit data...
Makefile Loading commit data...
README Loading commit data...
THANKS Loading commit data...
TODO Loading commit data...
arp.c Loading commit data...
config.in Loading commit data...
configure.sh Loading commit data...
hostname.c Loading commit data...
ifconfig.c Loading commit data...
intl.h Loading commit data...
ipmaddr.c Loading commit data...
iptunnel.c Loading commit data...
mii-tool.c Loading commit data...
nameif.c Loading commit data...
netstat.c Loading commit data...
plipconfig.c Loading commit data...
rarp.c Loading commit data...
route.c Loading commit data...
slattach.c Loading commit data...
statistics.c Loading commit data...