diff mbox

[2/4] mac80211: set NET_NAME_USER for user-space created ifs

Message ID 1393512434-1325-3-git-send-email-dh.herrmann@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

David Herrmann Feb. 27, 2014, 2:47 p.m. UTC
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.

This allows udev to not rename dynamically created wifi devices (like wifi
P2P devices).

Cc: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 net/mac80211/iface.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Johannes Berg Feb. 27, 2014, 2:53 p.m. UTC | #1
Given the premise of your patches,

> +++ b/net/mac80211/iface.c
> @@ -1620,6 +1620,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 = NET_NAME_USER;

this is wrong because we call this in main.c with a "wlan%d" argument
for the name, which gets expanded.

johannes

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Herrmann Feb. 27, 2014, 2:56 p.m. UTC | #2
Hi

On Thu, Feb 27, 2014 at 3:53 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> Given the premise of your patches,
>
>> +++ b/net/mac80211/iface.c
>> @@ -1620,6 +1620,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 = NET_NAME_USER;
>
> this is wrong because we call this in main.c with a "wlan%d" argument
> for the name, which gets expanded.

Whoops, yeah, same issue as with ath6kl where I fixed it with a
separate "name_assign_type" argument. I will do the same here for v2.

Thanks
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Feb. 27, 2014, 4:18 p.m. UTC | #3
On Thu, 2014-02-27 at 15:56 +0100, David Herrmann wrote:

> >> +++ b/net/mac80211/iface.c
> >> @@ -1620,6 +1620,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 = NET_NAME_USER;
> >
> > this is wrong because we call this in main.c with a "wlan%d" argument
> > for the name, which gets expanded.
> 
> Whoops, yeah, same issue as with ath6kl where I fixed it with a
> separate "name_assign_type" argument. I will do the same here for v2.

I'm not sure that helps - the user could potentially pass "foobar%d" as
the interface name and get a number assigned by the kernel. In that case
you probably *don't* want to set it to "name assigned by user"?

Maybe this whole thing can just be handled in __dev_alloc_name() since
no kernel user should pass just a string without "%d" in it.

johannes

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Herrmann Feb. 27, 2014, 5:14 p.m. UTC | #4
Hi

On Thu, Feb 27, 2014 at 5:18 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Thu, 2014-02-27 at 15:56 +0100, David Herrmann wrote:
>
>> >> +++ b/net/mac80211/iface.c
>> >> @@ -1620,6 +1620,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 = NET_NAME_USER;
>> >
>> > this is wrong because we call this in main.c with a "wlan%d" argument
>> > for the name, which gets expanded.
>>
>> Whoops, yeah, same issue as with ath6kl where I fixed it with a
>> separate "name_assign_type" argument. I will do the same here for v2.
>
> I'm not sure that helps - the user could potentially pass "foobar%d" as
> the interface name and get a number assigned by the kernel. In that case
> you probably *don't* want to set it to "name assigned by user"?
>
> Maybe this whole thing can just be handled in __dev_alloc_name() since
> no kernel user should pass just a string without "%d" in it.

Nope, I still want to set NET_NAME_USER in that case. It's not about
the %d suffix, it's about who chooses the suffix. If wpas decides to
use p2p-wlanX-%d, this is fine, as it's a virtual device where stable
IDs are not required at all.

Thanks
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index ce1c443..35561bd 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1620,6 +1620,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 = NET_NAME_USER;
 		ret = dev_alloc_name(ndev, ndev->name);
 		if (ret < 0) {
 			free_netdev(ndev);