Skip to contentSkip to conversation

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

PATCH In review Zheng Li 3 participants 3 messages Apr 12, 2024 – Apr 15, 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 IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

---
 net/core/neighbour.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/neighbour.c +4 -1
index 552719c3bbc3..d96dee3d4af6 100644
@@ -734,7 +734,10 @@ ___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);
+	if (dev->flags & IFF_LOOPBACK)
+		return ___neigh_create(tbl, pkey, dev, 0, true, want_ref);
+	else
+		return ___neigh_create(tbl, pkey, dev, 0, false, want_ref);
 }
 EXPORT_SYMBOL(__neigh_create);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 10 lines · On Fri, 12 Apr 2024 20:25:38 +0800 Zheng Li wrote:

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 IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

Please repost this and CC appropriate maintainers.

scripts/get_maintainer doesn't bite.

Signature · 1 line
pw-bot: cr
reviewer
#2 lore raw
In reply to Zheng Li
Quoted 23 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 IPv4 addresses, run "ssh localhost" on console interface, then the command will get timeout.

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

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

Quoted 10 lines
net/core/neighbour.c +4 -1
@@ -734,7 +734,10 @@ ___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);
+	if (dev->flags & IFF_LOOPBACK)
+		return ___neigh_create(tbl, pkey, dev, 0, true, want_ref);
+	else
+		return ___neigh_create(tbl, pkey, dev, 0, false, want_ref);
 }
 EXPORT_SYMBOL(__neigh_create);

Hi James,

I'm not commenting on the merits of your patch - I'm sure the maintainers will do so when you repost as Jakub has suggested.

But wile looking at this it seemed to me that the following might be a cleaner way to express your change.

struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
struct net_device *dev, bool want_ref)

{
	bool exempt_from_gc = !!(dev->flags & IFF_LOOPBACK);

	return ___neigh_create(tbl, pkey, dev, 0, exempt_from_gc,  want_ref);
}