From patchwork Mon Oct 14 20:55:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 835775 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E233C1D0B9B for ; Mon, 14 Oct 2024 20:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.49.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939374; cv=none; b=srTCJ9zLPz+aADRdqdSTCSR7nViZlOyzAzsB98/Y5cckBlT8XvmTqjcBmwoEd1OeWiptaBX8izqZ+slRCwH5ckDhULASYpM4BJnKTKbq6PCqrUQ5iEVEH7lYUzuON68gD1QPjfkwxAecR83FuOoEz1D4agTmz6fO4ROUx1M8ON8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939374; c=relaxed/simple; bh=hMzQxBDyrGsZ1w+Utbf2ii3rYMTMAVua+VyaLeJ96lA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TRhDLEy8S8C2AFgmcOAUkBT/+MSbybNZeMIJSgF836ackOVw4KoVUKwRtdq8Pi5jfBUQWkqbBZDuiiil7MiW2UHpLhK/cW3/w31HmqT2ZH0iSvW2RD+6L2voa7k5KaG9PLigdlr8j2SzCmTfEPFyhcu8L7S4LvQ9sfvp/VbQWyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=p9wAE1UX; arc=none smtp.client-ip=52.95.49.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="p9wAE1UX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1728939373; x=1760475373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5PCVUGqBIB9Z66+UMJ2tXFmGcFdyToB2bnYnw/GOuHU=; b=p9wAE1UXZdOoHDk+EEK/8yZ/o++/bo+QengftS7pelpBuSyYBF6EWONV qQLpTsy/HWCQRlTUFaXIHkwAb5OsdOHpOxJznOoiaO3SL8tfacqWMhXjN g2UbGolGqobYLLFKcEJWlSE3kan99S3ttgUcVDzKzMtr9dw2Jeq+ZkMuC o=; X-IronPort-AV: E=Sophos;i="6.11,203,1725321600"; d="scan'208";a="440753089" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 20:56:09 +0000 Received: from EX19MTAUWC002.ant.amazon.com [10.0.7.35:45872] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.29:2525] with esmtp (Farcaster) id ab3589ff-fae7-46a9-8f66-b1ad8bb9bf64; Mon, 14 Oct 2024 20:56:09 +0000 (UTC) X-Farcaster-Flow-ID: ab3589ff-fae7-46a9-8f66-b1ad8bb9bf64 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Mon, 14 Oct 2024 20:56:08 +0000 Received: from 6c7e67c6786f.amazon.com (10.106.101.44) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.35; Mon, 14 Oct 2024 20:56:06 +0000 From: Kuniyuki Iwashima To: Johannes Berg CC: Alexandre Ferrieux , Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 wl-next 1/3] wifi: wext: Move wext_nlevents to net->gen[]. Date: Mon, 14 Oct 2024 13:55:41 -0700 Message-ID: <20241014205543.94787-2-kuniyu@amazon.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241014205543.94787-1-kuniyu@amazon.com> References: <20241014205543.94787-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D045UWC002.ant.amazon.com (10.13.139.230) To EX19D004ANA001.ant.amazon.com (10.37.240.138) CONFIG_WEXT_CORE cannot be built as a module and is enabled in a generic kernel in major distros. We will namespacify wireless_nlevent_work that would require yet another wext-specific field in struct net. Given wext has already registered its pernet_operations, we can use struct net_generic for wext-specific storage. Let's move wext_nlevents to net->gen[]. Signed-off-by: Kuniyuki Iwashima --- include/net/net_namespace.h | 3 --- net/wireless/wext-core.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 873c0f9fdac6..f720225f7f6d 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -150,9 +150,6 @@ struct net { #if IS_ENABLED(CONFIG_NF_FLOW_TABLE) struct netns_ft ft; #endif -#endif -#ifdef CONFIG_WEXT_CORE - struct sk_buff_head wext_nlevents; #endif struct net_generic __rcu *gen; diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index 3bb04b05c5ce..bfc13e0d9883 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c @@ -20,6 +20,7 @@ #include #include #include +#include typedef int (*wext_ioctl_func)(struct net_device *, struct iwreq *, unsigned int, struct iw_request_info *, @@ -343,6 +344,17 @@ static const int compat_event_type_size[] = { /* IW event code */ +struct wext_net { + struct sk_buff_head nlevents; +}; + +static int wext_net_id; + +static struct wext_net *wext_net(struct net *net) +{ + return net_generic(net, wext_net_id); +} + void wireless_nlevent_flush(void) { struct sk_buff *skb; @@ -350,7 +362,9 @@ void wireless_nlevent_flush(void) down_read(&net_rwsem); for_each_net(net) { - while ((skb = skb_dequeue(&net->wext_nlevents))) + struct wext_net *wnet = wext_net(net); + + while ((skb = skb_dequeue(&wnet->nlevents))) rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_KERNEL); } @@ -379,18 +393,25 @@ static struct notifier_block wext_netdev_notifier = { static int __net_init wext_pernet_init(struct net *net) { - skb_queue_head_init(&net->wext_nlevents); + struct wext_net *wnet = wext_net(net); + + skb_queue_head_init(&wnet->nlevents); + return 0; } static void __net_exit wext_pernet_exit(struct net *net) { - skb_queue_purge(&net->wext_nlevents); + struct wext_net *wnet = wext_net(net); + + skb_queue_purge(&wnet->nlevents); } static struct pernet_operations wext_pernet_ops = { .init = wext_pernet_init, .exit = wext_pernet_exit, + .id = &wext_net_id, + .size = sizeof(struct wext_net), }; static int __init wireless_nlevent_init(void) @@ -462,6 +483,7 @@ void wireless_send_event(struct net_device * dev, int wrqu_off = 0; /* Offset in wrqu */ /* Don't "optimise" the following variable, it will crash */ unsigned int cmd_index; /* *MUST* be unsigned */ + struct wext_net *wnet; struct sk_buff *skb; struct nlmsghdr *nlh; struct nlattr *nla; @@ -632,7 +654,8 @@ void wireless_send_event(struct net_device * dev, skb_shinfo(skb)->frag_list = compskb; #endif - skb_queue_tail(&dev_net(dev)->wext_nlevents, skb); + wnet = wext_net(dev_net(dev)); + skb_queue_tail(&wnet->nlevents, skb); schedule_work(&wireless_nlevent_work); } EXPORT_SYMBOL(wireless_send_event); From patchwork Mon Oct 14 20:55:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 835384 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3E5E1D0B9B for ; Mon, 14 Oct 2024 20:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.49.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939392; cv=none; b=ruP4OWAoz+dKtC74uJbBF52/0U7ZhtEZxOUOYvN5o3TV37ttwOvrBrSfVh2k/a9FRN+TQ4Y0cV+ScZKXQt9h1RCCeUa+lg4DVJfpUmeUBhHazWTBZCN6oNBbinwvR5pFv2kOah5JVOY2hnVjPnuoQpckciF1FB54OTSBrvCpCng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939392; c=relaxed/simple; bh=NPvDKmuVn6SLlT3u9SVVKp0wu1ZIulav4z1ZVQ6GSr8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=itwAz3iphHMf7HirWUlpi0KTHk/pg+o8dIuu198OznRvRIj0hmD/2bsbeQnrN8OFCzjuA/EQwmLe4p8Soms/Bfs/BH5FKbqVHCglRowDuYgo1zOjWGibHC06pfxc9VPhh+f1cYrZTL49RpUFbdpNCgcmPdRSNNR6RvVXTG5URt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=JR8R6uil; arc=none smtp.client-ip=52.95.49.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="JR8R6uil" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1728939391; x=1760475391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wyxzhCH+RCz4TZof/qFBe9QhQjwPHrezipTzY+vYTNU=; b=JR8R6uil8/PWa7JEAKourTtC2AHIXGazCi7KDlXWTonTDVBiPDcNtNXp LgpTXZhTKaBNXCsTbVdooJGZhcn05X18AWd2iaEMNaR9yZ4x1xoXUDfkL zV5traSv0/345w0qch8bi+NbUnXCljiIz3qxt2xla7O2dUjvCaaJbSwc3 E=; X-IronPort-AV: E=Sophos;i="6.11,203,1725321600"; d="scan'208";a="440753173" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 20:56:29 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.21.151:20236] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.29:2525] with esmtp (Farcaster) id 0b66a69c-5cba-473b-99e5-860f1058305c; Mon, 14 Oct 2024 20:56:29 +0000 (UTC) X-Farcaster-Flow-ID: 0b66a69c-5cba-473b-99e5-860f1058305c Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Mon, 14 Oct 2024 20:56:27 +0000 Received: from 6c7e67c6786f.amazon.com (10.106.101.44) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.35; Mon, 14 Oct 2024 20:56:25 +0000 From: Kuniyuki Iwashima To: Johannes Berg CC: Alexandre Ferrieux , Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 wl-next 2/3] wifi: wext: Convert wireless_nlevent_work to per-netns work. Date: Mon, 14 Oct 2024 13:55:42 -0700 Message-ID: <20241014205543.94787-3-kuniyu@amazon.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241014205543.94787-1-kuniyu@amazon.com> References: <20241014205543.94787-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D032UWB002.ant.amazon.com (10.13.139.190) To EX19D004ANA001.ant.amazon.com (10.37.240.138) The next patch will namespacify wireless_nlevent_flush(), which is called by wireless_nlevent_process() and two netdev notifiers. As a preparation, let's convert wireless_nlevent_work to per-netns work. Suggested-by: Johannes Berg Link: https://lore.kernel.org/netdev/cd8045c03573a012f71a1afdcfb5d9c108b6fefa.camel@sipsolutions.net/ Signed-off-by: Kuniyuki Iwashima --- net/wireless/wext-core.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index bfc13e0d9883..4d7699135f46 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c @@ -346,6 +346,7 @@ static const int compat_event_type_size[] = { struct wext_net { struct sk_buff_head nlevents; + struct work_struct nlevent_work; }; static int wext_net_id; @@ -391,11 +392,18 @@ static struct notifier_block wext_netdev_notifier = { .notifier_call = wext_netdev_notifier_call, }; +/* Process events generated by the wireless layer or the driver. */ +static void wireless_nlevent_process(struct work_struct *work) +{ + wireless_nlevent_flush(); +} + static int __net_init wext_pernet_init(struct net *net) { struct wext_net *wnet = wext_net(net); skb_queue_head_init(&wnet->nlevents); + INIT_WORK(&wnet->nlevent_work, wireless_nlevent_process); return 0; } @@ -405,6 +413,7 @@ static void __net_exit wext_pernet_exit(struct net *net) struct wext_net *wnet = wext_net(net); skb_queue_purge(&wnet->nlevents); + cancel_work_sync(&wnet->nlevent_work); } static struct pernet_operations wext_pernet_ops = { @@ -429,14 +438,6 @@ static int __init wireless_nlevent_init(void) subsys_initcall(wireless_nlevent_init); -/* Process events generated by the wireless layer or the driver. */ -static void wireless_nlevent_process(struct work_struct *work) -{ - wireless_nlevent_flush(); -} - -static DECLARE_WORK(wireless_nlevent_work, wireless_nlevent_process); - static struct nlmsghdr *rtnetlink_ifinfo_prep(struct net_device *dev, struct sk_buff *skb) { @@ -656,7 +657,7 @@ void wireless_send_event(struct net_device * dev, #endif wnet = wext_net(dev_net(dev)); skb_queue_tail(&wnet->nlevents, skb); - schedule_work(&wireless_nlevent_work); + schedule_work(&wnet->nlevent_work); } EXPORT_SYMBOL(wireless_send_event); From patchwork Mon Oct 14 20:55:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 835774 Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6961D1518 for ; Mon, 14 Oct 2024 20:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939410; cv=none; b=jqzPvnSUk8QE8y8UrBKkQBk9WBl0jM9z0GXEi82ZYYXzPX+Powr6HAGX4A1XGilFKtgHoR30ytvbQxBI1/O8LwNMDO3LgL1ddnCh1MQE0s10rATYs6dhuA4mi5tt9ZJwaq06u3ovQvIOL7zH4oOrta3nzTzskE/uNlqqRsEgZ/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728939410; c=relaxed/simple; bh=zoVxVHxBOoITHvYx/wds+4nlVcC3Cw40aNA88OH+CAs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gwy9zJT0KwraEqFVYEW1qtETonL4N4Qd49rLm2R/GZoLtLb3wZa0EFxp8z4cVvfcAZjz9d9jtCeJrYASi3ueDhYuW1cds7XH+nEic7gkKMLHBE9kj9YWL2kPF2aHflOxIn8K6mHLq3zDaahqIj+ZOugXsXmB2sOUtgIDWrWMNVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=t8V+pgkW; arc=none smtp.client-ip=99.78.197.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="t8V+pgkW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1728939409; x=1760475409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cIC71K1ngjjnOWz/tQ2pY1RF/NWPWwSpvGOAjVKxY74=; b=t8V+pgkWsSXYvn36WzvBwNaqxX9D/4iG+f2+xmb8+SKdAMYcLsY1285N gyKNECj5PhB/NxSXKYir3tz7I0X562sOPH9Z/7RgbPPsqPwynBXfvxF+E wmIakueGeN/ykVtxKs3ij1rrZHlhKK1c//jnZYJokZa7sfPTsWX9sdF3f s=; X-IronPort-AV: E=Sophos;i="6.11,203,1725321600"; d="scan'208";a="138018246" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 20:56:47 +0000 Received: from EX19MTAUWA002.ant.amazon.com [10.0.21.151:43461] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.59.23:2525] with esmtp (Farcaster) id a1983923-8adc-4ffd-b998-fc6d6b098004; Mon, 14 Oct 2024 20:56:47 +0000 (UTC) X-Farcaster-Flow-ID: a1983923-8adc-4ffd-b998-fc6d6b098004 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Mon, 14 Oct 2024 20:56:47 +0000 Received: from 6c7e67c6786f.amazon.com (10.106.101.44) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.35; Mon, 14 Oct 2024 20:56:44 +0000 From: Kuniyuki Iwashima To: Johannes Berg CC: Alexandre Ferrieux , Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 wl-next 3/3] wifi: wext: Don't iterate all netns in wireless_nlevent_flush(). Date: Mon, 14 Oct 2024 13:55:43 -0700 Message-ID: <20241014205543.94787-4-kuniyu@amazon.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241014205543.94787-1-kuniyu@amazon.com> References: <20241014205543.94787-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D045UWC001.ant.amazon.com (10.13.139.223) To EX19D004ANA001.ant.amazon.com (10.37.240.138) Commit 8bf862739a77 ("wext: fix message delay/ordering") introduced wext_netdev_notifier_call() to avoid message delay and out-of-order. The notifier calls wireless_nlevent_flush(), which iterates all netns. The problem is that this happens for any event and netdev, even if the host does not have a wext device. This is too noisy, especially on a host with thousands of netns as reported by Alexandre Ferrieux. Given that the wext event queue was implemented in struct net, wireless_nlevent_flush() does not need to iterate all netns. Let's avoid unnecessary netns iteration in wireless_nlevent_flush(). Reported-by: Alexandre Ferrieux Closes: https://lore.kernel.org/netdev/CAKYWH0Ti3=4GeeuVyWKJ9LyTuRnf3Wy9GKg4Jb7tdeaT39qADA@mail.gmail.com/ Signed-off-by: Kuniyuki Iwashima --- include/net/iw_handler.h | 4 ++-- net/wireless/core.c | 2 +- net/wireless/wext-core.c | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h index b80e474cb0aa..e6acff086d39 100644 --- a/include/net/iw_handler.h +++ b/include/net/iw_handler.h @@ -412,9 +412,9 @@ void wireless_send_event(struct net_device *dev, unsigned int cmd, union iwreq_data *wrqu, const char *extra); #ifdef CONFIG_WEXT_CORE /* flush all previous wext events - if work is done from netdev notifiers */ -void wireless_nlevent_flush(void); +void wireless_nlevent_flush(struct net *net); #else -static inline void wireless_nlevent_flush(void) {} +static inline void wireless_nlevent_flush(struct net *net) {} #endif /* We may need a function to send a stream of events to user space. diff --git a/net/wireless/core.c b/net/wireless/core.c index 4c8d8f167409..a864ec889de3 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -1629,7 +1629,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, return NOTIFY_DONE; } - wireless_nlevent_flush(); + wireless_nlevent_flush(dev_net(dev)); return NOTIFY_OK; } diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c index 4d7699135f46..28033211c9e3 100644 --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c @@ -345,6 +345,7 @@ static const int compat_event_type_size[] = { /* IW event code */ struct wext_net { + struct net *net; struct sk_buff_head nlevents; struct work_struct nlevent_work; }; @@ -356,26 +357,22 @@ static struct wext_net *wext_net(struct net *net) return net_generic(net, wext_net_id); } -void wireless_nlevent_flush(void) +void wireless_nlevent_flush(struct net *net) { + struct wext_net *wnet = wext_net(net); struct sk_buff *skb; - struct net *net; - down_read(&net_rwsem); - for_each_net(net) { - struct wext_net *wnet = wext_net(net); - while ((skb = skb_dequeue(&wnet->nlevents))) - rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, - GFP_KERNEL); - } - up_read(&net_rwsem); + while ((skb = skb_dequeue(&wnet->nlevents))) + rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_KERNEL); } 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 @@ -383,7 +380,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(dev_net(dev)); return NOTIFY_OK; } @@ -395,13 +392,17 @@ static struct notifier_block wext_netdev_notifier = { /* Process events generated by the wireless layer or the driver. */ static void wireless_nlevent_process(struct work_struct *work) { - wireless_nlevent_flush(); + struct wext_net *wnet; + + wnet = container_of(work, struct wext_net, nlevent_work); + wireless_nlevent_flush(wnet->net); } static int __net_init wext_pernet_init(struct net *net) { struct wext_net *wnet = wext_net(net); + wnet->net = net; skb_queue_head_init(&wnet->nlevents); INIT_WORK(&wnet->nlevent_work, wireless_nlevent_process);