diff mbox

[RFT] brcmfmac: add support to move wiphy instance into network namespace

Message ID 1489742655.2544.4.camel@sipsolutions.net (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show

Commit Message

Johannes Berg March 17, 2017, 9:24 a.m. UTC
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?


johannes

Comments

Arend Van Spriel March 17, 2017, 9:33 a.m. UTC | #1
On 17-3-2017 10:24, Johannes Berg wrote:
> 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;

Given my debug session just a minute ago I would say yes ;-) as this is
where I put wiphy_err() statement. Will give it a quick spin.

Regards,
Arend

>  		list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
>  		rdev->devlist_generation++;
>  		/* can only change netns with wiphy */
> 
> johannes
>
Arend Van Spriel March 17, 2017, 9:36 a.m. UTC | #2
On 17-3-2017 10:24, Johannes Berg wrote:
> 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?

Yep. Tested and verified.

Regards,
Arend

> 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
>
diff mbox

Patch

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 */