Re: [RFC bluetooth-next] cfg802154: pass name_assign_type to rdev_add_virtual_intf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

On 04/28/2015 01:07 PM, Alexander Aring wrote:

> Hi Varka,
>
> On Wed, Apr 22, 2015 at 02:07:16PM +0530, Varka Bhadram wrote:
>> This code is based on commit 6bab2e19c5ffd
>> ("cfg80211: pass name_assign_type to rdev_add_virtual_intf()")
>>
>> This will expose in sysfs whether the ifname of a IEEE-802.15.4
>> device is set by userspace or generated by the kernel.
>> We are using two types of name_assign_types
>>  o NET_NAME_ENUM: Default interface name provided by kernel
>>  o NET_NAME_USER: Interface name provided by user.
>>
>> Signed-off-by: Varka Bhadram <varkab@xxxxxxx>
>> ---
>>  include/net/cfg802154.h      |    2 ++
>>  net/ieee802154/nl-phy.c      |    1 +
>>  net/ieee802154/nl802154.c    |    1 +
>>  net/ieee802154/rdev-ops.h    |   10 +++++++---
>>  net/mac802154/cfg.c          |    9 ++++++---
>>  net/mac802154/ieee802154_i.h |    1 +
>>  net/mac802154/iface.c        |    5 +++--
>>  net/mac802154/main.c         |    3 ++-
>>  8 files changed, 23 insertions(+), 9 deletions(-)
>>
>> diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
>> index eeda676..6ea16c8 100644
>> --- a/include/net/cfg802154.h
>> +++ b/include/net/cfg802154.h
>> @@ -30,11 +30,13 @@ struct wpan_phy_cca;
>>  struct cfg802154_ops {
>>  	struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
>>  							   const char *name,
>> +							   unsigned char name_assign_type,
>>  							   int type);
>>  	void	(*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
>>  					       struct net_device *dev);
>>  	int	(*add_virtual_intf)(struct wpan_phy *wpan_phy,
>>  				    const char *name,
>> +				    unsigned char name_assign_type,
>>  				    enum nl802154_iftype type,
>>  				    __le64 extended_addr);
>>  	int	(*del_virtual_intf)(struct wpan_phy *wpan_phy,
>> diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
>> index 1b9d25f6..ac3462a 100644
>> --- a/net/ieee802154/nl-phy.c
>> +++ b/net/ieee802154/nl-phy.c
>> @@ -221,6 +221,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
>>  	}
>>  
>>  	dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
>> +					       NET_NAME_ENUM,
>>  					       type);
> This isn't always given by kernel.
>
> See [0]. If info->attrs[IEEE802154_ATTR_DEV_TYPE] is given the name
> came from user. You need to put some variable on stack and then decide
> this in the if else branch.

What about the following change..?

diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index ac3462a..248490c 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
        int rc = -ENOBUFS;
        struct net_device *dev;
        int type = __IEEE802154_DEV_INVALID;
+       unsigned char name_assign_type;

        pr_debug("%s\n", __func__);

@@ -190,8 +191,10 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
                if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
                                != '\0')
                        return -EINVAL; /* phy name should be null-terminated */
+               name_assign_type = NET_NAME_USER;
        } else  {
                devname = "wpan%d";
+               name_assign_type = NET_NAME_ENUM;
        }

        if (strlen(devname) >= IFNAMSIZ)
@@ -221,7 +224,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
        }

        dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
-                                              NET_NAME_ENUM,
+                                              name_assign_type,
                                               type);
        if (IS_ERR(dev)) {
                rc = PTR_ERR(dev);
-- 
1.7.9.5

>
>>  	if (IS_ERR(dev)) {
>>  		rc = PTR_ERR(dev);
>> diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
>> index a4daf91..a7eb16d 100644
>> --- a/net/ieee802154/nl802154.c
>> +++ b/net/ieee802154/nl802154.c
>> @@ -589,6 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
>>  
>>  	return rdev_add_virtual_intf(rdev,
>>  				     nla_data(info->attrs[NL802154_ATTR_IFNAME]),
>> +				     NET_NAME_USER,
>>  				     type, extended_addr);
> put what you can of these parameters in the previous line. I think
> "type" fits sure in this line.
>
Ok will do.

>
> Otherwise this patch looks good. Thanks.
>
> - Alex
>
> [0] http://lxr.free-electrons.com/source/net/ieee802154/nl-phy.c#L188
>
Thanks.

-- 
Varka Bhadram

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux