Fix incorrect ARP output
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:
Ralf Baechle <ralf@linux-mips.org>
Showing
Please register or sign in to comment