linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Arend Van Spriel <arend.vanspriel@broadcom.com>,
	Mark Asselstine <mark.asselstine@windriver.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [RFT] brcmfmac: add support to move wiphy instance into network namespace
Date: Fri, 17 Mar 2017 10:24:15 +0100	[thread overview]
Message-ID: <1489742655.2544.4.camel@sipsolutions.net> (raw)
In-Reply-To: <0343e3c9-baf8-f3b1-8c37-c8b0864bd7e5@broadcom.com> (sfid-20170317_100704_414025_FE4CF8A1)

On Fri, 2017-03-17 at 10:06 +0100, Arend Van Spriel wrote:
> On 16-3-2017 22:51, Mark Asselstine wrote:
> > On Tuesday, March 14, 2017 9:51:52 PM EDT Arend van Spriel wrote:
> > > To support network namespace the driver must assure all created
> > > network interfaces are in the same namespace as the wiphy
> > > instance.
> > > 
> > > Reported-by: Mark Asselstine <mark.asselstine@windriver.com>
> > > Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> > > ---
> > > Hi Mark,
> > > 
> > > Please check this patch. I can not say I am an expert when it
> > > comes
> > > to using namespaces. So let me know if it works and I can change
> > > Reported-by into Tested-by.
> > 
> > Seems to pass the tests I threw at it. Seems happy with namespaces.
> 
> I tested it myself and noticed something unexpected. Upon changing
> from &init_net to brcm-wifi the wdev id has changed from 0x1 to 0x2
> (see below) and upon going from brcm-wifi to &init_net both interface
> change their wdev id.

Interesting. That's clearly a cfg80211 bug, does this help?

diff --git a/net/wireless/core.c b/net/wireless/core.c
index 2e1740c7a8bf..d71d5e90229f 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -1183,7 +1183,15 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
 		INIT_LIST_HEAD(&wdev->mgmt_registrations);
 		spin_lock_init(&wdev->mgmt_registrations_lock);
 
-		wdev->identifier = ++rdev->wdev_id;
+		/*
+		 * We get here also when the interface changes network namespaces,
+		 * as it's registered into the new one, but we don't want it to
+		 * change ID in that case. Checking if the ID is already assigned
+		 * works, because 0 isn't considered a valid ID and the memory is
+		 * 0-initialized.
+		 */
+		if (!wdev->identifier)
+			wdev->identifier = ++rdev->wdev_id;
 		list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
 		rdev->devlist_generation++;
 		/* can only change netns with wiphy */

johannes

  reply	other threads:[~2017-03-17  9:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14 21:51 [RFT] brcmfmac: add support to move wiphy instance into network namespace Arend van Spriel
2017-03-14 22:19 ` Johannes Berg
2017-03-15  8:54   ` Arend Van Spriel
2017-03-16 21:51 ` Mark Asselstine
2017-03-17  8:21   ` Arend Van Spriel
2017-03-17  9:06   ` Arend Van Spriel
2017-03-17  9:24     ` Johannes Berg [this message]
2017-03-17  9:33       ` Arend Van Spriel
2017-03-17  9:36       ` Arend Van Spriel
2017-03-17  9:30     ` Arend Van Spriel
2017-03-17 12:43       ` Mark Asselstine
2017-03-17 12:58         ` Johannes Berg
2017-03-17 13:05           ` Mark Asselstine

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=1489742655.2544.4.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=arend.vanspriel@broadcom.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mark.asselstine@windriver.com \
    /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).