From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <alexandre.ferrieux@gmail.com>
Cc: <alexandre.ferrieux@orange.com>, <edumazet@google.com>,
<horms@kernel.org>, <netdev@vger.kernel.org>,
Johannes Berg <johannes@sipsolutions.net>,
<linux-wireless@vger.kernel.org>, <kuniyu@amazon.com>
Subject: Re: RFC: Should net namespaces scale up (>10k) ?
Date: Tue, 8 Oct 2024 10:47:51 -0700 [thread overview]
Message-ID: <20241008174751.2995-1-kuniyu@amazon.com> (raw)
In-Reply-To: <CAKYWH0Ti3=4GeeuVyWKJ9LyTuRnf3Wy9GKg4Jb7tdeaT39qADA@mail.gmail.com>
+Johannes and wireless ML.
From: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
Date: Sun, 15 Sep 2024 22:49:22 +0200
> (thanks Simon, reposting with another account to avoid the offending disclaimer)
>
> Hi,
>
> Currently, netns don't really scale beyond a few thousands, for
> mundane reasons (see below). But should they ? Is there, in the
> design, an assumption that tens of thousands of network namespaces are
> considered "unreasonable" ?
>
> A typical use case for such ridiculous numbers is a tester for
> firewalls or carrier-grade NATs. In these, you typically want tens of
> thousands of tunnels, each of which is perfectly instantiated as an
> interface. And, to avoid an explosion in source routing rules, you
> want them in separate namespaces.
>
> Now why don't they scale *today* ? For two independent, seemingly
> accidental, O(N) scans of the netns list.
>
> 1. The "netdevice notifier" from the Wireless Extensions subsystem
> insists on scanning the whole list regardless of the nature of the
> change, nor wondering whether all these namespaces hold any wireless
> interface, nor even whether the system has _any_ wireless hardware...
>
> for_each_net(net) {
> while ((skb = skb_dequeue(&net->wext_nlevents)))
> rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL,
> GFP_KERNEL);
> }
>
Alex forwarded this mail to me and asked about 1.
I checked 8bf862739a778, but I didn't see why wext_netdev_notifier_call()
needs to iterate all netns.
Is there a case where flushing messages in the notified dev's netns is not
enough for wext dev ?
---8<---
diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
index 838ad6541a17..d4b613fc650c 100644
--- a/net/wireless/wext-core.c
+++ b/net/wireless/wext-core.c
@@ -343,17 +343,22 @@ static const int compat_event_type_size[] = {
/* IW event code */
-void wireless_nlevent_flush(void)
+static void wireless_nlevent_flush_net(struct net *net)
{
struct sk_buff *skb;
+
+ while ((skb = skb_dequeue(&net->wext_nlevents)))
+ rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL,
+ GFP_KERNEL);
+}
+
+void wireless_nlevent_flush(void)
+{
struct net *net;
down_read(&net_rwsem);
- for_each_net(net) {
- while ((skb = skb_dequeue(&net->wext_nlevents)))
- rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL,
- GFP_KERNEL);
- }
+ for_each_net(net)
+ wireless_nlevent_flush_net(net);
up_read(&net_rwsem);
}
EXPORT_SYMBOL_GPL(wireless_nlevent_flush);
@@ -361,6 +366,8 @@ EXPORT_SYMBOL_GPL(wireless_nlevent_flush);
static int wext_netdev_notifier_call(struct notifier_block *nb,
unsigned long state, void *ptr)
{
+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+
/*
* When a netdev changes state in any way, flush all pending messages
* to avoid them going out in a strange order, e.g. RTM_NEWLINK after
@@ -368,7 +375,7 @@ static int wext_netdev_notifier_call(struct notifier_block *nb,
* or similar - all of which could otherwise happen due to delays from
* schedule_work().
*/
- wireless_nlevent_flush();
+ wireless_nlevent_flush_net(dev_net(dev));
return NOTIFY_OK;
}
---8<---
next prev parent reply other threads:[~2024-10-08 17:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 20:49 RFC: Should net namespaces scale up (>10k) ? Alexandre Ferrieux
2024-09-16 10:13 ` Przemek Kitszel
2024-09-16 14:01 ` Simon Horman
2024-09-16 22:05 ` Alexandre Ferrieux
2024-09-17 6:40 ` Przemek Kitszel
2024-09-17 11:06 ` Alexandre Ferrieux
2024-09-17 6:59 ` Eric Dumazet
2024-09-17 12:30 ` Nicolas Dichtel
2024-09-24 14:06 ` Massive hash collisions on FIB Alexandre Ferrieux
2024-09-24 14:36 ` Eric Dumazet
2024-09-24 17:18 ` Alexandre Ferrieux
2024-09-25 19:06 ` Alexandre Ferrieux
2024-09-25 19:25 ` Eric Dumazet
2024-09-25 19:46 ` Alexandre Ferrieux
2024-09-25 20:12 ` Eric Dumazet
2024-09-25 21:26 ` Alexandre Ferrieux
2024-09-16 21:36 ` RFC: Should net namespaces scale up (>10k) ? Alexandre Ferrieux
2024-10-08 17:47 ` Kuniyuki Iwashima [this message]
2024-10-08 18:22 ` Johannes Berg
2024-10-08 18:56 ` Kuniyuki Iwashima
-- strict thread matches above, loose matches on Subject: below --
2024-09-14 22:34 alexandre.ferrieux
2024-09-15 18:58 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241008174751.2995-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=alexandre.ferrieux@gmail.com \
--cc=alexandre.ferrieux@orange.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).