]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.73/net-fix-proc-net-arp-for-ax.25.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.73 / net-fix-proc-net-arp-for-ax.25.patch
1 From foo@baz Thu Jun 15 11:13:01 CEST 2017
2 From: Ralf Baechle <ralf@linux-mips.org>
3 Date: Tue, 23 May 2017 21:53:37 -0400
4 Subject: NET: Fix /proc/net/arp for AX.25
5
6 From: Ralf Baechle <ralf@linux-mips.org>
7
8
9 [ Upstream commit 4872e57c812dd312bf8193b5933fa60585cda42f ]
10
11 When sending ARP requests over AX.25 links the hwaddress in the neighbour
12 cache are not getting initialized. For such an incomplete arp entry
13 ax2asc2 will generate an empty string resulting in /proc/net/arp output
14 like the following:
15
16 $ cat /proc/net/arp
17 IP address HW type Flags HW address Mask Device
18 192.168.122.1 0x1 0x2 52:54:00:00:5d:5f * ens3
19 172.20.1.99 0x3 0x0 * bpq0
20
21 The missing field will confuse the procfs parsing of arp(8) resulting in
22 incorrect output for the device such as the following:
23
24 $ arp
25 Address HWtype HWaddress Flags Mask Iface
26 gateway ether 52:54:00:00:5d:5f C ens3
27 172.20.1.99 (incomplete) ens3
28
29 This changes the content of /proc/net/arp to:
30
31 $ cat /proc/net/arp
32 IP address HW type Flags HW address Mask Device
33 172.20.1.99 0x3 0x0 * * bpq0
34 192.168.122.1 0x1 0x2 52:54:00:00:5d:5f * ens3
35
36 To do so it change ax2asc to put the string "*" in buf for a NULL address
37 argument. Finally the HW address field is left aligned in a 17 character
38 field (the length of an ethernet HW address in the usual hex notation) for
39 readability.
40
41 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
42 Signed-off-by: David S. Miller <davem@davemloft.net>
43 Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
44 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45 ---
46 net/ipv4/arp.c | 12 ++++++------
47 1 file changed, 6 insertions(+), 6 deletions(-)
48
49 --- a/net/ipv4/arp.c
50 +++ b/net/ipv4/arp.c
51 @@ -1250,7 +1250,7 @@ void __init arp_init(void)
52 /*
53 * ax25 -> ASCII conversion
54 */
55 -static char *ax2asc2(ax25_address *a, char *buf)
56 +static void ax2asc2(ax25_address *a, char *buf)
57 {
58 char c, *s;
59 int n;
60 @@ -1272,10 +1272,10 @@ static char *ax2asc2(ax25_address *a, ch
61 *s++ = n + '0';
62 *s++ = '\0';
63
64 - if (*buf == '\0' || *buf == '-')
65 - return "*";
66 -
67 - return buf;
68 + if (*buf == '\0' || *buf == '-') {
69 + buf[0] = '*';
70 + buf[1] = '\0';
71 + }
72 }
73 #endif /* CONFIG_AX25 */
74
75 @@ -1309,7 +1309,7 @@ static void arp_format_neigh_entry(struc
76 }
77 #endif
78 sprintf(tbuf, "%pI4", n->primary_key);
79 - seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
80 + seq_printf(seq, "%-16s 0x%-10x0x%-10x%-17s * %s\n",
81 tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
82 read_unlock(&n->lock);
83 }