* [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
@ 2019-05-02 1:18 David Ahern
2019-05-02 9:54 ` Alan Maguire
2019-05-04 4:41 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2019-05-02 1:18 UTC (permalink / raw)
To: davem; +Cc: netdev, alan.maguire, jwestfall, David Ahern
From: David Ahern <dsahern@gmail.com>
Commit cd9ff4de0107 changed the key for IFF_POINTOPOINT devices to
INADDR_ANY but neigh_xmit which is used for MPLS encapsulations was not
updated to use the altered key. The result is that every packet Tx does
a lookup on the gateway address which does not find an entry, a new one
is created only to find the existing one in the table right before the
insert since arp_constructor was updated to reset the primary key. This
is seen in the allocs and destroys counters:
ip -s -4 ntable show | head -10 | grep alloc
which increase for each packet showing the unnecessary overhread.
Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE.
Fixes: cd9ff4de0107 ("ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY")
Reported-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/core/neighbour.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index aff051e5521d..9b9da5142613 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -31,6 +31,7 @@
#include <linux/times.h>
#include <net/net_namespace.h>
#include <net/neighbour.h>
+#include <net/arp.h>
#include <net/dst.h>
#include <net/sock.h>
#include <net/netevent.h>
@@ -2984,7 +2985,13 @@ int neigh_xmit(int index, struct net_device *dev,
if (!tbl)
goto out;
rcu_read_lock_bh();
- neigh = __neigh_lookup_noref(tbl, addr, dev);
+ if (index == NEIGH_ARP_TABLE) {
+ u32 key = *((u32 *)addr);
+
+ neigh = __ipv4_neigh_lookup_noref(dev, key);
+ } else {
+ neigh = __neigh_lookup_noref(tbl, addr, dev);
+ }
if (!neigh)
neigh = __neigh_create(tbl, addr, dev, false);
err = PTR_ERR(neigh);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
2019-05-02 1:18 [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit David Ahern
@ 2019-05-02 9:54 ` Alan Maguire
2019-05-04 4:41 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Alan Maguire @ 2019-05-02 9:54 UTC (permalink / raw)
To: David Ahern; +Cc: davem, netdev, alan.maguire, jwestfall, David Ahern
On Wed, 1 May 2019, David Ahern wrote:
> From: David Ahern <dsahern@gmail.com>
>
> Commit cd9ff4de0107 changed the key for IFF_POINTOPOINT devices to
> INADDR_ANY but neigh_xmit which is used for MPLS encapsulations was not
> updated to use the altered key. The result is that every packet Tx does
> a lookup on the gateway address which does not find an entry, a new one
> is created only to find the existing one in the table right before the
> insert since arp_constructor was updated to reset the primary key. This
> is seen in the allocs and destroys counters:
> ip -s -4 ntable show | head -10 | grep alloc
>
> which increase for each packet showing the unnecessary overhread.
>
> Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE.
>
> Fixes: cd9ff4de0107 ("ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY")
> Reported-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> net/core/neighbour.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index aff051e5521d..9b9da5142613 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -31,6 +31,7 @@
> #include <linux/times.h>
> #include <net/net_namespace.h>
> #include <net/neighbour.h>
> +#include <net/arp.h>
> #include <net/dst.h>
> #include <net/sock.h>
> #include <net/netevent.h>
> @@ -2984,7 +2985,13 @@ int neigh_xmit(int index, struct net_device *dev,
> if (!tbl)
> goto out;
> rcu_read_lock_bh();
> - neigh = __neigh_lookup_noref(tbl, addr, dev);
> + if (index == NEIGH_ARP_TABLE) {
> + u32 key = *((u32 *)addr);
> +
> + neigh = __ipv4_neigh_lookup_noref(dev, key);
> + } else {
> + neigh = __neigh_lookup_noref(tbl, addr, dev);
> + }
> if (!neigh)
> neigh = __neigh_create(tbl, addr, dev, false);
> err = PTR_ERR(neigh);
> --
> 2.11.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
2019-05-02 1:18 [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit David Ahern
2019-05-02 9:54 ` Alan Maguire
@ 2019-05-04 4:41 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-04 4:41 UTC (permalink / raw)
To: dsahern; +Cc: netdev, alan.maguire, jwestfall, dsahern
From: David Ahern <dsahern@kernel.org>
Date: Wed, 1 May 2019 18:18:42 -0700
> From: David Ahern <dsahern@gmail.com>
>
> Commit cd9ff4de0107 changed the key for IFF_POINTOPOINT devices to
> INADDR_ANY but neigh_xmit which is used for MPLS encapsulations was not
> updated to use the altered key. The result is that every packet Tx does
> a lookup on the gateway address which does not find an entry, a new one
> is created only to find the existing one in the table right before the
> insert since arp_constructor was updated to reset the primary key. This
> is seen in the allocs and destroys counters:
> ip -s -4 ntable show | head -10 | grep alloc
>
> which increase for each packet showing the unnecessary overhread.
>
> Fix by having neigh_xmit use __ipv4_neigh_lookup_noref for NEIGH_ARP_TABLE.
>
> Fixes: cd9ff4de0107 ("ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY")
> Reported-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-04 4:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 1:18 [PATCH net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit David Ahern
2019-05-02 9:54 ` Alan Maguire
2019-05-04 4:41 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.