From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:49611 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbdFDIMX (ORCPT ); Sun, 4 Jun 2017 04:12:23 -0400 From: "Levin, Alexander (Sasha Levin)" Cc: Ralf Baechle , "David S . Miller" , "Levin, Alexander (Sasha Levin)" To: "stable@vger.kernel.org" Subject: [PATCH for v4.9 LTS 012/111] NET: Fix /proc/net/arp for AX.25 Date: Sun, 4 Jun 2017 08:11:51 +0000 Message-ID: <20170604081123.19462-12-alexander.levin@verizon.com> References: <20170604081123.19462-1-alexander.levin@verizon.com> In-Reply-To: <20170604081123.19462-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Ralf Baechle [ Upstream commit 4872e57c812dd312bf8193b5933fa60585cda42f ] 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 Dev= ice 192.168.122.1 0x1 0x2 52:54:00:00:5d:5f * ens= 3 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 Dev= ice 172.20.1.99 0x3 0x0 * * bpq= 0 192.168.122.1 0x1 0x2 52:54:00:00:5d:5f * ens= 3 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: Ralf Baechle Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/arp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 89a8cac4726a..51b27ae09fbd 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1263,7 +1263,7 @@ void __init arp_init(void) /* * ax25 -> ASCII conversion */ -static char *ax2asc2(ax25_address *a, char *buf) +static void ax2asc2(ax25_address *a, char *buf) { char c, *s; int n; @@ -1285,10 +1285,10 @@ static char *ax2asc2(ax25_address *a, char *buf) *s++ =3D n + '0'; *s++ =3D '\0'; =20 - if (*buf =3D=3D '\0' || *buf =3D=3D '-') - return "*"; - - return buf; + if (*buf =3D=3D '\0' || *buf =3D=3D '-') { + buf[0] =3D '*'; + buf[1] =3D '\0'; + } } #endif /* CONFIG_AX25 */ =20 @@ -1322,7 +1322,7 @@ static void arp_format_neigh_entry(struct seq_file *s= eq, } #endif 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); read_unlock(&n->lock); } --=20 2.11.0