aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-03-20 15:21:19 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-27 20:13:05 -0400
commiteec60b037a875513d9715dcdb90b13ed81fc5f26 (patch)
treeb031d92f7613f2c043c151f102307ec3351843c1 /net/wireless
parent35a8efe1a67ba5d7bb7492f67f52ed2aa4925892 (diff)
nl80211: Check iftype in cfg80211 code
We do not want to require all the drivers using cfg80211 to need to do this. In addition, make the error values consistent by using EOPNOTSUPP instead of semi-random assortment of errno values. Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6bb73a3a3391..a7d0b94f6b5e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1049,6 +1049,11 @@ static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
1049 if (err) 1049 if (err)
1050 goto unlock_rtnl; 1050 goto unlock_rtnl;
1051 1051
1052 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP) {
1053 err = -EOPNOTSUPP;
1054 goto out;
1055 }
1056
1052 switch (info->genlhdr->cmd) { 1057 switch (info->genlhdr->cmd) {
1053 case NL80211_CMD_NEW_BEACON: 1058 case NL80211_CMD_NEW_BEACON:
1054 /* these are required for NEW_BEACON */ 1059 /* these are required for NEW_BEACON */
@@ -1136,6 +1141,10 @@ static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
1136 goto out; 1141 goto out;
1137 } 1142 }
1138 1143
1144 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP) {
1145 err = -EOPNOTSUPP;
1146 goto out;
1147 }
1139 err = drv->ops->del_beacon(&drv->wiphy, dev); 1148 err = drv->ops->del_beacon(&drv->wiphy, dev);
1140 1149
1141 out: 1150 out:
@@ -1324,7 +1333,7 @@ static int nl80211_dump_station(struct sk_buff *skb,
1324 } 1333 }
1325 1334
1326 if (!dev->ops->dump_station) { 1335 if (!dev->ops->dump_station) {
1327 err = -ENOSYS; 1336 err = -EOPNOTSUPP;
1328 goto out_err; 1337 goto out_err;
1329 } 1338 }
1330 1339
@@ -1698,10 +1707,15 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
1698 } 1707 }
1699 1708
1700 if (!dev->ops->dump_mpath) { 1709 if (!dev->ops->dump_mpath) {
1701 err = -ENOSYS; 1710 err = -EOPNOTSUPP;
1702 goto out_err; 1711 goto out_err;
1703 } 1712 }
1704 1713
1714 if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
1715 err = -EOPNOTSUPP;
1716 goto out;
1717 }
1718
1705 while (1) { 1719 while (1) {
1706 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, 1720 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
1707 dst, next_hop, &pinfo); 1721 dst, next_hop, &pinfo);
@@ -1759,6 +1773,11 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1759 goto out; 1773 goto out;
1760 } 1774 }
1761 1775
1776 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
1777 err = -EOPNOTSUPP;
1778 goto out;
1779 }
1780
1762 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo); 1781 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo);
1763 if (err) 1782 if (err)
1764 goto out; 1783 goto out;
@@ -1813,6 +1832,11 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1813 goto out; 1832 goto out;
1814 } 1833 }
1815 1834
1835 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
1836 err = -EOPNOTSUPP;
1837 goto out;
1838 }
1839
1816 if (!netif_running(dev)) { 1840 if (!netif_running(dev)) {
1817 err = -ENETDOWN; 1841 err = -ENETDOWN;
1818 goto out; 1842 goto out;
@@ -1856,6 +1880,11 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1856 goto out; 1880 goto out;
1857 } 1881 }
1858 1882
1883 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
1884 err = -EOPNOTSUPP;
1885 goto out;
1886 }
1887
1859 if (!netif_running(dev)) { 1888 if (!netif_running(dev)) {
1860 err = -ENETDOWN; 1889 err = -ENETDOWN;
1861 goto out; 1890 goto out;
@@ -1944,6 +1973,11 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1944 goto out; 1973 goto out;
1945 } 1974 }
1946 1975
1976 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP) {
1977 err = -EOPNOTSUPP;
1978 goto out;
1979 }
1980
1947 err = drv->ops->change_bss(&drv->wiphy, dev, &params); 1981 err = drv->ops->change_bss(&drv->wiphy, dev, &params);
1948 1982
1949 out: 1983 out:
@@ -2661,6 +2695,11 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
2661 goto out; 2695 goto out;
2662 } 2696 }
2663 2697
2698 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) {
2699 err = -EOPNOTSUPP;
2700 goto out;
2701 }
2702
2664 if (!netif_running(dev)) { 2703 if (!netif_running(dev)) {
2665 err = -ENETDOWN; 2704 err = -ENETDOWN;
2666 goto out; 2705 goto out;
@@ -2734,6 +2773,11 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
2734 goto out; 2773 goto out;
2735 } 2774 }
2736 2775
2776 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) {
2777 err = -EOPNOTSUPP;
2778 goto out;
2779 }
2780
2737 if (!netif_running(dev)) { 2781 if (!netif_running(dev)) {
2738 err = -ENETDOWN; 2782 err = -ENETDOWN;
2739 goto out; 2783 goto out;
@@ -2797,6 +2841,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
2797 goto out; 2841 goto out;
2798 } 2842 }
2799 2843
2844 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) {
2845 err = -EOPNOTSUPP;
2846 goto out;
2847 }
2848
2800 if (!netif_running(dev)) { 2849 if (!netif_running(dev)) {
2801 err = -ENETDOWN; 2850 err = -ENETDOWN;
2802 goto out; 2851 goto out;
@@ -2856,6 +2905,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
2856 goto out; 2905 goto out;
2857 } 2906 }
2858 2907
2908 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) {
2909 err = -EOPNOTSUPP;
2910 goto out;
2911 }
2912
2859 if (!netif_running(dev)) { 2913 if (!netif_running(dev)) {
2860 err = -ENETDOWN; 2914 err = -ENETDOWN;
2861 goto out; 2915 goto out;