mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
cfg802154: pass name_assign_type to rdev_add_virtual_intf()
This code is based on commit 6bab2e19c5
("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@cdac.in>
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
4748e86ecf
commit
5b4a103904
@ -30,11 +30,13 @@ struct wpan_phy_cca;
|
|||||||
struct cfg802154_ops {
|
struct cfg802154_ops {
|
||||||
struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
|
struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
unsigned char name_assign_type,
|
||||||
int type);
|
int type);
|
||||||
void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
|
void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
|
||||||
struct net_device *dev);
|
struct net_device *dev);
|
||||||
int (*add_virtual_intf)(struct wpan_phy *wpan_phy,
|
int (*add_virtual_intf)(struct wpan_phy *wpan_phy,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
unsigned char name_assign_type,
|
||||||
enum nl802154_iftype type,
|
enum nl802154_iftype type,
|
||||||
__le64 extended_addr);
|
__le64 extended_addr);
|
||||||
int (*del_virtual_intf)(struct wpan_phy *wpan_phy,
|
int (*del_virtual_intf)(struct wpan_phy *wpan_phy,
|
||||||
|
@ -175,6 +175,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
|
|||||||
int rc = -ENOBUFS;
|
int rc = -ENOBUFS;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
int type = __IEEE802154_DEV_INVALID;
|
int type = __IEEE802154_DEV_INVALID;
|
||||||
|
unsigned char name_assign_type;
|
||||||
|
|
||||||
pr_debug("%s\n", __func__);
|
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]
|
if (devname[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1]
|
||||||
!= '\0')
|
!= '\0')
|
||||||
return -EINVAL; /* phy name should be null-terminated */
|
return -EINVAL; /* phy name should be null-terminated */
|
||||||
|
name_assign_type = NET_NAME_USER;
|
||||||
} else {
|
} else {
|
||||||
devname = "wpan%d";
|
devname = "wpan%d";
|
||||||
|
name_assign_type = NET_NAME_ENUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(devname) >= IFNAMSIZ)
|
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,
|
dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
|
||||||
type);
|
name_assign_type, type);
|
||||||
if (IS_ERR(dev)) {
|
if (IS_ERR(dev)) {
|
||||||
rc = PTR_ERR(dev);
|
rc = PTR_ERR(dev);
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
@ -589,7 +589,7 @@ static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info)
|
|||||||
|
|
||||||
return rdev_add_virtual_intf(rdev,
|
return rdev_add_virtual_intf(rdev,
|
||||||
nla_data(info->attrs[NL802154_ATTR_IFNAME]),
|
nla_data(info->attrs[NL802154_ATTR_IFNAME]),
|
||||||
type, extended_addr);
|
NET_NAME_USER, type, extended_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
|
static int nl802154_del_interface(struct sk_buff *skb, struct genl_info *info)
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
|
|
||||||
static inline struct net_device *
|
static inline struct net_device *
|
||||||
rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
|
rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
|
||||||
const char *name, int type)
|
const char *name,
|
||||||
|
unsigned char name_assign_type,
|
||||||
|
int type)
|
||||||
{
|
{
|
||||||
return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
|
return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
|
||||||
type);
|
name_assign_type, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -23,13 +25,15 @@ rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
|
|||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
|
rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
|
||||||
|
unsigned char name_assign_type,
|
||||||
enum nl802154_iftype type, __le64 extended_addr)
|
enum nl802154_iftype type, __le64 extended_addr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
|
trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
|
||||||
extended_addr);
|
extended_addr);
|
||||||
ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type,
|
ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
|
||||||
|
name_assign_type, type,
|
||||||
extended_addr);
|
extended_addr);
|
||||||
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
|
trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -22,13 +22,14 @@
|
|||||||
|
|
||||||
static struct net_device *
|
static struct net_device *
|
||||||
ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
|
ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
|
||||||
const char *name, int type)
|
const char *name,
|
||||||
|
unsigned char name_assign_type, int type)
|
||||||
{
|
{
|
||||||
struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
|
struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
dev = ieee802154_if_add(local, name, type,
|
dev = ieee802154_if_add(local, name, name_assign_type, type,
|
||||||
cpu_to_le64(0x0000000000000000ULL));
|
cpu_to_le64(0x0000000000000000ULL));
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
|
|
||||||
@ -45,12 +46,14 @@ static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
ieee802154_add_iface(struct wpan_phy *phy, const char *name,
|
ieee802154_add_iface(struct wpan_phy *phy, const char *name,
|
||||||
|
unsigned char name_assign_type,
|
||||||
enum nl802154_iftype type, __le64 extended_addr)
|
enum nl802154_iftype type, __le64 extended_addr)
|
||||||
{
|
{
|
||||||
struct ieee802154_local *local = wpan_phy_priv(phy);
|
struct ieee802154_local *local = wpan_phy_priv(phy);
|
||||||
struct net_device *err;
|
struct net_device *err;
|
||||||
|
|
||||||
err = ieee802154_if_add(local, name, type, extended_addr);
|
err = ieee802154_if_add(local, name, name_assign_type, type,
|
||||||
|
extended_addr);
|
||||||
return PTR_ERR_OR_ZERO(err);
|
return PTR_ERR_OR_ZERO(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ void ieee802154_iface_exit(void);
|
|||||||
void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
|
void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
|
||||||
struct net_device *
|
struct net_device *
|
||||||
ieee802154_if_add(struct ieee802154_local *local, const char *name,
|
ieee802154_if_add(struct ieee802154_local *local, const char *name,
|
||||||
enum nl802154_iftype type, __le64 extended_addr);
|
unsigned char name_assign_type, enum nl802154_iftype type,
|
||||||
|
__le64 extended_addr);
|
||||||
void ieee802154_remove_interfaces(struct ieee802154_local *local);
|
void ieee802154_remove_interfaces(struct ieee802154_local *local);
|
||||||
|
|
||||||
#endif /* __IEEE802154_I_H */
|
#endif /* __IEEE802154_I_H */
|
||||||
|
@ -522,7 +522,8 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
|
|||||||
|
|
||||||
struct net_device *
|
struct net_device *
|
||||||
ieee802154_if_add(struct ieee802154_local *local, const char *name,
|
ieee802154_if_add(struct ieee802154_local *local, const char *name,
|
||||||
enum nl802154_iftype type, __le64 extended_addr)
|
unsigned char name_assign_type, enum nl802154_iftype type,
|
||||||
|
__le64 extended_addr)
|
||||||
{
|
{
|
||||||
struct net_device *ndev = NULL;
|
struct net_device *ndev = NULL;
|
||||||
struct ieee802154_sub_if_data *sdata = NULL;
|
struct ieee802154_sub_if_data *sdata = NULL;
|
||||||
@ -531,7 +532,7 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
|
|||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name,
|
ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size, name,
|
||||||
NET_NAME_UNKNOWN, ieee802154_if_setup);
|
name_assign_type, ieee802154_if_setup);
|
||||||
if (!ndev)
|
if (!ndev)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
@ -161,7 +161,8 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
|
|||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
|
|
||||||
dev = ieee802154_if_add(local, "wpan%d", NL802154_IFTYPE_NODE,
|
dev = ieee802154_if_add(local, "wpan%d", NET_NAME_ENUM,
|
||||||
|
NL802154_IFTYPE_NODE,
|
||||||
cpu_to_le64(0x0000000000000000ULL));
|
cpu_to_le64(0x0000000000000000ULL));
|
||||||
if (IS_ERR(dev)) {
|
if (IS_ERR(dev)) {
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
|
Loading…
Reference in New Issue
Block a user