Skip to contentSkip to conversation

neighbour: guarantee the localhost connections be established successfully even the ARP table is full

PATCH Applied Zheng Li 5 participants 6 messages Apr 16, 2024 – Apr 18, 2024

Subsystems (3)
lore
Share & tools
lore

Zheng Li

author
#0 lore raw

PATCH 1/1 neighbour: guarantee the localhost connections be established successfully even the ARP table is full

From: Zheng Li <[email protected]>

Inter-process communication on localhost should be established successfully even the ARP table is full, many processes on server machine use the localhost to communicate such as command-line interface (CLI), servers hope all CLI commands can be executed successfully even the arp table is full. Right now CLI commands got timeout when the arp table is full. Set the parameter of exempt_from_gc to be true for LOOPBACK net device to keep localhost neigh in arp table, not removed by gc.

the steps of reproduced:
server with "gc_thresh3 = 1024" setting, ping server from more than 1024 same netmask Lan IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

---
 net/core/neighbour.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/neighbour.c +3 -1
index 552719c3bbc3..47d07b122f7a 100644
@@ -734,7 +734,9 @@ ___neigh_create(struct neigh_table *tbl, const void *pkey,
 struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
 				 struct net_device *dev, bool want_ref)
 {
-	return ___neigh_create(tbl, pkey, dev, 0, false, want_ref);
+	bool exempt_from_gc = !!(dev->flags & IFF_LOOPBACK);
+
+	return ___neigh_create(tbl, pkey, dev, 0, exempt_from_gc, want_ref);
 }
 EXPORT_SYMBOL(__neigh_create);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 26 lines · Zheng Li

From: Zheng Li <[email protected]>

Inter-process communication on localhost should be established successfully even the ARP table is full, many processes on server machine use the localhost to communicate such as command-line interface (CLI), servers hope all CLI commands can be executed successfully even the arp table is full. Right now CLI commands got timeout when the arp table is full. Set the parameter of exempt_from_gc to be true for LOOPBACK net device to keep localhost neigh in arp table, not removed by gc.

the steps of reproduced:
server with "gc_thresh3 = 1024" setting, ping server from more than 1024 same netmask Lan IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

---
 net/core/neighbour.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/neighbour.c +0 -0
index 552719c3bbc3..47d07b122f7a 100644

net/core/neighbour.c ___neigh_create(struct neigh_table *tbl, const void *pkey, · line 742

Quoted 10 lines
net/core/neighbour.c +3 -1
@@ -734,7 +734,9 @@ ___neigh_create(struct neigh_table *tbl, const void *pkey,
 struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
                                 struct net_device *dev, bool want_ref)
 {
-       return ___neigh_create(tbl, pkey, dev, 0, false, want_ref);
+       bool exempt_from_gc = !!(dev->flags & IFF_LOOPBACK);
+
+       return ___neigh_create(tbl, pkey, dev, 0, exempt_from_gc, want_ref);
 }
 EXPORT_SYMBOL(__neigh_create);
 

Hmmm...

Loopback IPv4 can hold 2^24 different addresses, that is 16384 * 1024

#2 lore raw

Internal Use - Confidential
-----Original Message-----
From: Eric Dumazet <[email protected]>
Sent: Tuesday, April 16, 2024 6:02 PM
To: Zheng Li <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Li, James Zheng <[email protected]>
Subject: Re: [PATCH] neighbour: guarantee the localhost connections be established successfully even the ARP table is full

[EXTERNAL EMAIL]

Quoted 34 lines · Zheng Li

From: Zheng Li <[email protected]>

Inter-process communication on localhost should be established
successfully even the ARP table is full, many processes on server
machine use the localhost to communicate such as command-line
interface (CLI), servers hope all CLI commands can be executed
successfully even the arp table is full. Right now CLI commands got
timeout when the arp table is full. Set the parameter of
exempt_from_gc to be true for LOOPBACK net device to keep localhost neigh in arp table, not removed by gc.

the steps of reproduced:
server with "gc_thresh3 = 1024" setting, ping server from more than 1024 same netmask Lan IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

---
 net/core/neighbour.c | 4 +-+-+--
 1 file changed, 3 insertions(+-), 1 deletion(-)
net/core/neighbour.c index renamed from net/core/neighbour.c +0 -0

552719c3bbc3..47d07b122f7a 100644
--- a/net/core/neighbour.c
+-+-+- b/net/core/neighbour.c
@@ -734,7 +-734,9 @@ ___neigh_create(struct neigh_table *tbl, const
void *pkey, struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
struct net_device *dev, bool
want_ref) {
- return ___neigh_create(tbl, pkey, dev, 0, false, want_ref);

+-       bool exempt_from_gc = !!(dev->flags & IFF_LOOPBACK);
+-
+-       return ___neigh_create(tbl, pkey, dev, 0, exempt_from_gc,
+- want_ref);
Quoted 7 lines

}
EXPORT_SYMBOL(__neigh_create);

Hmmm...

Loopback IPv4 can hold 2^24 different addresses, that is 16384 * 1024

There is only one Loopback neigh "0.0.0.0 dev lo lladdr 00:00:00:00:00:00 NOARP" existing even you have configured 2^24 different addresses on the loopback device.

maintainer
#3 lore raw
Quoted 7 lines · James Zheng
Quoted 3 lines · Eric Dumazet

Hmmm...

Loopback IPv4 can hold 2^24 different addresses, that is 16384 * 1024

There is only one Loopback neigh "0.0.0.0 dev lo lladdr 00:00:00:00:00:00 NOARP" existing even you have configured 2^24 different addresses on the loopback device.

Eric, I think James is right, in __ipv4_neigh_lookup_noref():

	if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
                key = INADDR_ANY;

	return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);

So there should be at most one neigh entry over the loopback device. The patch looks safe to me, am I missing something?

Thanks,

Paolo

Reviewed-by
#4 lore raw
Quoted 12 lines · Paolo Abeni
Quoted 7 lines · James Zheng
Quoted 3 lines · Eric Dumazet

Hmmm...

Loopback IPv4 can hold 2^24 different addresses, that is 16384 * 1024

There is only one Loopback neigh "0.0.0.0 dev lo lladdr 00:00:00:00:00:00 NOARP" existing even you have configured 2^24 different addresses on the loopback device.

Eric, I think James is right, in __ipv4_neigh_lookup_noref():

Quoted 7 lines
        if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
                key = INADDR_ANY;

        return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);

So there should be at most one neigh entry over the loopback device. The patch looks safe to me, am I missing something?

This seems fine, thanks.

It is unfortunate ip command does not seem to display these neighbours, for some reason.

(I am about to send a series of three patches to remove RTNL from "ip neighbour show")

#5 lore raw
In reply to Zheng Li
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Tue, 16 Apr 2024 17:53:43 +0800 you wrote:

From: Zheng Li <[email protected]>

Inter-process communication on localhost should be established successfully even the ARP table is full, many processes on server machine use the localhost to communicate such as command-line interface (CLI), servers hope all CLI commands can be executed successfully even the arp table is full. Right now CLI commands got timeout when the arp table is full. Set the parameter of exempt_from_gc to be true for LOOPBACK net device to keep localhost neigh in arp table, not removed by gc.

[...]

Here is the summary with links:
- neighbour: guarantee the localhost connections be established successfully even the ARP table is full

    https://git.kernel.org/netdev/net-next/c/eabf425bc6ad

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html