* [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
@ 2019-05-03 15:55 David Ahern
2019-05-05 17:42 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2019-05-03 15:55 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.
Define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set.
v2
- define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set as
reported by kbuild test robot
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>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
include/net/arp.h | 8 ++++++++
net/core/neighbour.c | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/net/arp.h b/include/net/arp.h
index 977aabfcdc03..c8f580a0e6b1 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -18,6 +18,7 @@ static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32
return val * hash_rnd[0];
}
+#ifdef CONFIG_INET
static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
{
if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
@@ -25,6 +26,13 @@ static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev
return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);
}
+#else
+static inline
+struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
+{
+ return NULL;
+}
+#endif
static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key)
{
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 30f6fd8f68e0..0ba5018ccb7f 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>
@@ -2982,7 +2983,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] 4+ messages in thread
* Re: [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
2019-05-03 15:55 [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit David Ahern
@ 2019-05-05 17:42 ` David Miller
2019-05-05 17:43 ` David Ahern
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2019-05-05 17:42 UTC (permalink / raw)
To: dsahern; +Cc: netdev, alan.maguire, jwestfall, dsahern
From: David Ahern <dsahern@kernel.org>
Date: Fri, 3 May 2019 08:55:01 -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.
> Define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set.
>
> v2
> - define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set as
> reported by kbuild test robot
>
> 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>
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Double signoff and this patch doesn't apply to the net tree.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
2019-05-05 17:42 ` David Miller
@ 2019-05-05 17:43 ` David Ahern
2019-05-05 17:53 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2019-05-05 17:43 UTC (permalink / raw)
To: David Miller, dsahern; +Cc: netdev, alan.maguire, jwestfall
On 5/5/19 11:42 AM, David Miller wrote:
> From: David Ahern <dsahern@kernel.org>
> Date: Fri, 3 May 2019 08:55:01 -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.
>> Define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set.
>>
>> v2
>> - define __ipv4_neigh_lookup_noref in case CONFIG_INET is not set as
>> reported by kbuild test robot
>>
>> 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>
>>
>> Signed-off-by: David Ahern <dsahern@gmail.com>
>
> Double signoff and this patch doesn't apply to the net tree.
>
oops on the double signoff; you actually took v1 so I need to send a delta.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit
2019-05-05 17:43 ` David Ahern
@ 2019-05-05 17:53 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-05-05 17:53 UTC (permalink / raw)
To: dsahern; +Cc: dsahern, netdev, alan.maguire, jwestfall
From: David Ahern <dsahern@gmail.com>
Date: Sun, 5 May 2019 11:43:39 -0600
> oops on the double signoff; you actually took v1 so I need to send a delta.
Aha, I see, thanks for catching that.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-05 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 15:55 [PATCH v2 net] neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit David Ahern
2019-05-05 17:42 ` David Miller
2019-05-05 17:43 ` David Ahern
2019-05-05 17:53 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).