Commit 4872e57c authored by Ralf Baechle's avatar Ralf Baechle Committed by David S. Miller

NET: Fix /proc/net/arp for AX.25

When sending ARP requests over AX.25 links the hwaddress in the neighbour
cache are not getting initialized.  For such an incomplete arp entry
ax2asc2 will generate an empty string resulting in /proc/net/arp output
like the following:

$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
192.168.122.1    0x1         0x2         52:54:00:00:5d:5f     *        ens3
172.20.1.99      0x3         0x0              *        bpq0

The missing field will confuse the procfs parsing of arp(8) resulting in
incorrect output for the device such as the following:

$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
gateway                  ether   52:54:00:00:5d:5f   C                     ens3
172.20.1.99                      (incomplete)                              ens3

This changes the content of /proc/net/arp to:

$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
172.20.1.99      0x3         0x0         *                     *        bpq0
192.168.122.1    0x1         0x2         52:54:00:00:5d:5f     *        ens3

To do so it change ax2asc to put the string "*" in buf for a NULL address
argument.  Finally the HW address field is left aligned in a 17 character
field (the length of an ethernet HW address in the usual hex notation) for
readability.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ebf692f8
...@@ -1263,7 +1263,7 @@ void __init arp_init(void) ...@@ -1263,7 +1263,7 @@ void __init arp_init(void)
/* /*
* ax25 -> ASCII conversion * ax25 -> ASCII conversion
*/ */
static char *ax2asc2(ax25_address *a, char *buf) static void ax2asc2(ax25_address *a, char *buf)
{ {
char c, *s; char c, *s;
int n; int n;
...@@ -1285,10 +1285,10 @@ static char *ax2asc2(ax25_address *a, char *buf) ...@@ -1285,10 +1285,10 @@ static char *ax2asc2(ax25_address *a, char *buf)
*s++ = n + '0'; *s++ = n + '0';
*s++ = '\0'; *s++ = '\0';
if (*buf == '\0' || *buf == '-') if (*buf == '\0' || *buf == '-') {
return "*"; buf[0] = '*';
buf[1] = '\0';
return buf; }
} }
#endif /* CONFIG_AX25 */ #endif /* CONFIG_AX25 */
...@@ -1322,7 +1322,7 @@ static void arp_format_neigh_entry(struct seq_file *seq, ...@@ -1322,7 +1322,7 @@ static void arp_format_neigh_entry(struct seq_file *seq,
} }
#endif #endif
sprintf(tbuf, "%pI4", n->primary_key); sprintf(tbuf, "%pI4", n->primary_key);
seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n", seq_printf(seq, "%-16s 0x%-10x0x%-10x%-17s * %s\n",
tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name); tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
read_unlock(&n->lock); read_unlock(&n->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment