aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-06-15 11:52:47 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-07-09 08:51:46 -0400
commit72fb2abcf5f985a72e0a30c214b7ed49afa6571b (patch)
treec61b78456e80fd7081710c933289de72ed67cde4 /net/wireless/nl80211.c
parent1bf614ef7946436246de3c6a6593ba4799f7bac8 (diff)
nl80211: retrieve interface data by wdev
Since soon there will be virtual interfaces that don't have a netdev, use the wdev identifier for the API to retrieve interface data. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 27cd18e256c5..5800c49d6942 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1731,21 +1731,25 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
1731 1731
1732static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags, 1732static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags,
1733 struct cfg80211_registered_device *rdev, 1733 struct cfg80211_registered_device *rdev,
1734 struct net_device *dev) 1734 struct wireless_dev *wdev)
1735{ 1735{
1736 struct net_device *dev = wdev->netdev;
1736 void *hdr; 1737 void *hdr;
1737 u64 wdev_id = (u64)dev->ieee80211_ptr->identifier | 1738 u64 wdev_id = (u64)wdev->identifier |
1738 ((u64)rdev->wiphy_idx << 32); 1739 ((u64)rdev->wiphy_idx << 32);
1739 1740
1740 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE); 1741 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE);
1741 if (!hdr) 1742 if (!hdr)
1742 return -1; 1743 return -1;
1743 1744
1744 if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || 1745 if (dev &&
1745 nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 1746 (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
1746 nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) || 1747 nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name) ||
1747 nla_put_u32(msg, NL80211_ATTR_IFTYPE, 1748 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dev->dev_addr)))
1748 dev->ieee80211_ptr->iftype) || 1749 goto nla_put_failure;
1750
1751 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
1752 nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) ||
1749 nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id) || 1753 nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id) ||
1750 nla_put_u32(msg, NL80211_ATTR_GENERATION, 1754 nla_put_u32(msg, NL80211_ATTR_GENERATION,
1751 rdev->devlist_generation ^ 1755 rdev->devlist_generation ^
@@ -1794,7 +1798,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
1794 } 1798 }
1795 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, 1799 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid,
1796 cb->nlh->nlmsg_seq, NLM_F_MULTI, 1800 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1797 rdev, wdev->netdev) < 0) { 1801 rdev, wdev) < 0) {
1798 mutex_unlock(&rdev->devlist_mtx); 1802 mutex_unlock(&rdev->devlist_mtx);
1799 goto out; 1803 goto out;
1800 } 1804 }
@@ -1817,14 +1821,14 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
1817{ 1821{
1818 struct sk_buff *msg; 1822 struct sk_buff *msg;
1819 struct cfg80211_registered_device *dev = info->user_ptr[0]; 1823 struct cfg80211_registered_device *dev = info->user_ptr[0];
1820 struct net_device *netdev = info->user_ptr[1]; 1824 struct wireless_dev *wdev = info->user_ptr[1];
1821 1825
1822 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 1826 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1823 if (!msg) 1827 if (!msg)
1824 return -ENOMEM; 1828 return -ENOMEM;
1825 1829
1826 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, 1830 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0,
1827 dev, netdev) < 0) { 1831 dev, wdev) < 0) {
1828 nlmsg_free(msg); 1832 nlmsg_free(msg);
1829 return -ENOBUFS; 1833 return -ENOBUFS;
1830 } 1834 }
@@ -6833,7 +6837,7 @@ static struct genl_ops nl80211_ops[] = {
6833 .dumpit = nl80211_dump_interface, 6837 .dumpit = nl80211_dump_interface,
6834 .policy = nl80211_policy, 6838 .policy = nl80211_policy,
6835 /* can be retrieved by unprivileged users */ 6839 /* can be retrieved by unprivileged users */
6836 .internal_flags = NL80211_FLAG_NEED_NETDEV, 6840 .internal_flags = NL80211_FLAG_NEED_WDEV,
6837 }, 6841 },
6838 { 6842 {
6839 .cmd = NL80211_CMD_SET_INTERFACE, 6843 .cmd = NL80211_CMD_SET_INTERFACE,