From patchwork Fri Mar 17 09:24:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 9630071 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0559860132 for ; Fri, 17 Mar 2017 09:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18D1F28697 for ; Fri, 17 Mar 2017 09:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D7A628699; Fri, 17 Mar 2017 09:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DCEE28697 for ; Fri, 17 Mar 2017 09:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751066AbdCQJZw (ORCPT ); Fri, 17 Mar 2017 05:25:52 -0400 Received: from s3.sipsolutions.net ([5.9.151.49]:54284 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980AbdCQJZu (ORCPT ); Fri, 17 Mar 2017 05:25:50 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89_RC7) (envelope-from ) id 1coo7M-00074s-Ce; Fri, 17 Mar 2017 10:24:16 +0100 Message-ID: <1489742655.2544.4.camel@sipsolutions.net> Subject: Re: [RFT] brcmfmac: add support to move wiphy instance into network namespace From: Johannes Berg To: Arend Van Spriel , Mark Asselstine Cc: linux-wireless Date: Fri, 17 Mar 2017 10:24:15 +0100 In-Reply-To: <0343e3c9-baf8-f3b1-8c37-c8b0864bd7e5@broadcom.com> (sfid-20170317_100704_414025_FE4CF8A1) References: <1489528312-28304-1-git-send-email-arend.vanspriel@broadcom.com> <124157392.J1GrpqVLd5@yow-masselst-lx1> <0343e3c9-baf8-f3b1-8c37-c8b0864bd7e5@broadcom.com> (sfid-20170317_100704_414025_FE4CF8A1) X-Mailer: Evolution 3.22.4-1 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 > > > Signed-off-by: Arend van Spriel > > > --- > > > 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 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 */