1 From foo@baz Sun 09 Jun 2019 09:24:16 AM CEST
2 From: David Ahern <dsahern@gmail.com>
3 Date: Wed, 1 May 2019 18:18:42 -0700
4 Subject: neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
6 From: David Ahern <dsahern@gmail.com>
8 [ Upstream commit 4b2a2bfeb3f056461a90bd621e8bd7d03fa47f60 ]
10 Commit cd9ff4de0107 changed the key for IFF_POINTOPOINT devices to
11 INADDR_ANY but neigh_xmit which is used for MPLS encapsulations was not
12 updated to use the altered key. The result is that every packet Tx does
13 a lookup on the gateway address which does not find an entry, a new one
14 is created only to find the existing one in the table right before the
15 insert since arp_constructor was updated to reset the primary key. This
16 is seen in the allocs and destroys counters:
17 ip -s -4 ntable show | head -10 | grep alloc
19 which increase for each packet showing the unnecessary overhread.
21 Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE.
23 Fixes: cd9ff4de0107 ("ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY")
24 Reported-by: Alan Maguire <alan.maguire@oracle.com>
25 Signed-off-by: David Ahern <dsahern@gmail.com>
26 Tested-by: Alan Maguire <alan.maguire@oracle.com>
27 Signed-off-by: David S. Miller <davem@davemloft.net>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 net/core/neighbour.c | 9 ++++++++-
31 1 file changed, 8 insertions(+), 1 deletion(-)
33 --- a/net/core/neighbour.c
34 +++ b/net/core/neighbour.c
36 #include <linux/times.h>
37 #include <net/net_namespace.h>
38 #include <net/neighbour.h>
42 #include <net/netevent.h>
43 @@ -2984,7 +2985,13 @@ int neigh_xmit(int index, struct net_dev
47 - neigh = __neigh_lookup_noref(tbl, addr, dev);
48 + if (index == NEIGH_ARP_TABLE) {
49 + u32 key = *((u32 *)addr);
51 + neigh = __ipv4_neigh_lookup_noref(dev, key);
53 + neigh = __neigh_lookup_noref(tbl, addr, dev);
56 neigh = __neigh_create(tbl, addr, dev, false);