]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/neighbor-call-__ipv4_neigh_lookup_noref-in-neigh_xmit.patch
51fbc0e27871657c5fd72362ff1b8e6b2c1be18e
[thirdparty/kernel/stable-queue.git] / queue-5.1 / neighbor-call-__ipv4_neigh_lookup_noref-in-neigh_xmit.patch
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
5
6 From: David Ahern <dsahern@gmail.com>
7
8 [ Upstream commit 4b2a2bfeb3f056461a90bd621e8bd7d03fa47f60 ]
9
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
18
19 which increase for each packet showing the unnecessary overhread.
20
21 Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE.
22
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>
29 ---
30 net/core/neighbour.c | 9 ++++++++-
31 1 file changed, 8 insertions(+), 1 deletion(-)
32
33 --- a/net/core/neighbour.c
34 +++ b/net/core/neighbour.c
35 @@ -31,6 +31,7 @@
36 #include <linux/times.h>
37 #include <net/net_namespace.h>
38 #include <net/neighbour.h>
39 +#include <net/arp.h>
40 #include <net/dst.h>
41 #include <net/sock.h>
42 #include <net/netevent.h>
43 @@ -2984,7 +2985,13 @@ int neigh_xmit(int index, struct net_dev
44 if (!tbl)
45 goto out;
46 rcu_read_lock_bh();
47 - neigh = __neigh_lookup_noref(tbl, addr, dev);
48 + if (index == NEIGH_ARP_TABLE) {
49 + u32 key = *((u32 *)addr);
50 +
51 + neigh = __ipv4_neigh_lookup_noref(dev, key);
52 + } else {
53 + neigh = __neigh_lookup_noref(tbl, addr, dev);
54 + }
55 if (!neigh)
56 neigh = __neigh_create(tbl, addr, dev, false);
57 err = PTR_ERR(neigh);