From patchwork Wed Mar 26 13:05:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 333875 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 93CE614003E for ; Thu, 27 Mar 2014 00:06:48 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754834AbaCZNGW (ORCPT ); Wed, 26 Mar 2014 09:06:22 -0400 Received: from mail-bk0-f44.google.com ([209.85.214.44]:41388 "EHLO mail-bk0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754533AbaCZNFp (ORCPT ); Wed, 26 Mar 2014 09:05:45 -0400 Received: by mail-bk0-f44.google.com with SMTP id mz13so530392bkb.31 for ; Wed, 26 Mar 2014 06:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GZQ0EGE7PUUXAt0TpvlGDAsTQcyT8p3Y4S35AVtEaNg=; b=XCwDxUyDDWHS6ltEiR6pQ3RQw8jefKplzMIy8T8StDoXN3k8sEJrmdHBzr9+VkqTqD boX5+HXqf1XPh3tJ87NzQ3tYsj5P9DzxeKUHy3sdtFInnQOobhhLNunwcMuQQuRZ5F1I 1EnjX8um1pHLXRgT0BoUQrr7NaQ7OrFXr5LP2qVWCaApmajkpgifk2u+KDjjOjLJbNqL WUHZa6PJcZPk+VA7i//0ijY+3gXpNUEBCGD1OuNc5rb3DqhdB31pMmRpFVoe4dhRSnwR Ykbt7IX3+fBqG0bLXuFPDrzj5xvtnV3q7i5TnHtdqtY/P15CoggXOx6ZNtV7miGiTXPu P1Lg== X-Received: by 10.204.243.137 with SMTP id lm9mr5115642bkb.33.1395839143396; Wed, 26 Mar 2014 06:05:43 -0700 (PDT) Received: from david-tp.localdomain (stgt-5f7280a1.pool.mediaWays.net. [95.114.128.161]) by mx.google.com with ESMTPSA id xj2sm23082710bkb.15.2014.03.26.06.05.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Mar 2014 06:05:42 -0700 (PDT) From: David Herrmann To: netdev@vger.kernel.org Cc: "David S. Miller" , Tom Gundersen , Johannes berg , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, David Herrmann , Johannes Berg Subject: [PATCH v5 2/4] mac80211: set NET_NAME_USER for user-space created ifs Date: Wed, 26 Mar 2014 14:05:15 +0100 Message-Id: <1395839117-20090-3-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1395839117-20090-1-git-send-email-dh.herrmann@gmail.com> References: <1395839117-20090-1-git-send-email-dh.herrmann@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The nl80211 interface allows creating new netdevs from user-space. The name is *always* provided by user-space, so we should set NET_NAME_USER to provide that information via sysfs. But we must not set it for the default wlan%d names as these are kernel-provided names. This allows udev to not rename dynamically created wifi devices (like wifi P2P devices). Cc: Johannes Berg Signed-off-by: David Herrmann Acked-by: Tom Gundersen --- net/mac80211/cfg.c | 2 +- net/mac80211/ieee80211_i.h | 1 + net/mac80211/iface.c | 2 ++ net/mac80211/main.c | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index aaa59d7..804cf0a 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -31,7 +31,7 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, struct ieee80211_sub_if_data *sdata; int err; - err = ieee80211_if_add(local, name, &wdev, type, params); + err = ieee80211_if_add(local, name, NET_NAME_USER, &wdev, type, params); if (err) return ERR_PTR(err); diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 222c28b..1a938c3 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1470,6 +1470,7 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, int ieee80211_iface_init(void); void ieee80211_iface_exit(void); int ieee80211_if_add(struct ieee80211_local *local, const char *name, + unsigned char name_assign_type, struct wireless_dev **new_wdev, enum nl80211_iftype type, struct vif_params *params); int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index b8d331e..fe84853 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1574,6 +1574,7 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local, } int ieee80211_if_add(struct ieee80211_local *local, const char *name, + unsigned char name_assign_type, struct wireless_dev **new_wdev, enum nl80211_iftype type, struct vif_params *params) { @@ -1617,6 +1618,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, + IEEE80211_ENCRYPT_HEADROOM; ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM; + ndev->name_assign_type = name_assign_type; ret = dev_alloc_name(ndev, ndev->name); if (ret < 0) { free_netdev(ndev); diff --git a/net/mac80211/main.c b/net/mac80211/main.c index b055f6a5..ee32a83 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1012,7 +1012,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) /* add one default STA interface if supported */ if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) { - result = ieee80211_if_add(local, "wlan%d", NULL, + result = ieee80211_if_add(local, "wlan%d", NET_NAME_ENUM, NULL, NL80211_IFTYPE_STATION, NULL); if (result) wiphy_warn(local->hw.wiphy,