aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
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')
-rw-r--r--net/mac80211/cfg.c40
-rw-r--r--net/wireless/nl80211.c58
2 files changed, 56 insertions, 42 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index b5810b4c79ac..e677b751d468 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -540,9 +540,6 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
540 540
541 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 541 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
542 542
543 if (sdata->vif.type != NL80211_IFTYPE_AP)
544 return -EINVAL;
545
546 old = sdata->u.ap.beacon; 543 old = sdata->u.ap.beacon;
547 544
548 if (old) 545 if (old)
@@ -559,9 +556,6 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
559 556
560 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 557 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
561 558
562 if (sdata->vif.type != NL80211_IFTYPE_AP)
563 return -EINVAL;
564
565 old = sdata->u.ap.beacon; 559 old = sdata->u.ap.beacon;
566 560
567 if (!old) 561 if (!old)
@@ -577,9 +571,6 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
577 571
578 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 572 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
579 573
580 if (sdata->vif.type != NL80211_IFTYPE_AP)
581 return -EINVAL;
582
583 old = sdata->u.ap.beacon; 574 old = sdata->u.ap.beacon;
584 575
585 if (!old) 576 if (!old)
@@ -858,9 +849,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
858 849
859 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 850 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
860 851
861 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
862 return -ENOTSUPP;
863
864 rcu_read_lock(); 852 rcu_read_lock();
865 sta = sta_info_get(local, next_hop); 853 sta = sta_info_get(local, next_hop);
866 if (!sta) { 854 if (!sta) {
@@ -908,9 +896,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
908 896
909 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 897 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
910 898
911 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
912 return -ENOTSUPP;
913
914 rcu_read_lock(); 899 rcu_read_lock();
915 900
916 sta = sta_info_get(local, next_hop); 901 sta = sta_info_get(local, next_hop);
@@ -979,9 +964,6 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
979 964
980 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 965 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
981 966
982 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
983 return -ENOTSUPP;
984
985 rcu_read_lock(); 967 rcu_read_lock();
986 mpath = mesh_path_lookup(dst, sdata); 968 mpath = mesh_path_lookup(dst, sdata);
987 if (!mpath) { 969 if (!mpath) {
@@ -1003,9 +985,6 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1003 985
1004 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 986 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1005 987
1006 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1007 return -ENOTSUPP;
1008
1009 rcu_read_lock(); 988 rcu_read_lock();
1010 mpath = mesh_path_lookup_by_idx(idx, sdata); 989 mpath = mesh_path_lookup_by_idx(idx, sdata);
1011 if (!mpath) { 990 if (!mpath) {
@@ -1025,8 +1004,6 @@ static int ieee80211_get_mesh_params(struct wiphy *wiphy,
1025 struct ieee80211_sub_if_data *sdata; 1004 struct ieee80211_sub_if_data *sdata;
1026 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1005 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1027 1006
1028 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1029 return -ENOTSUPP;
1030 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); 1007 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1031 return 0; 1008 return 0;
1032} 1009}
@@ -1044,9 +1021,6 @@ static int ieee80211_set_mesh_params(struct wiphy *wiphy,
1044 struct ieee80211_sub_if_data *sdata; 1021 struct ieee80211_sub_if_data *sdata;
1045 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1022 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1046 1023
1047 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1048 return -ENOTSUPP;
1049
1050 /* Set the config options which we are interested in setting */ 1024 /* Set the config options which we are interested in setting */
1051 conf = &(sdata->u.mesh.mshcfg); 1025 conf = &(sdata->u.mesh.mshcfg);
1052 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) 1026 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
@@ -1094,9 +1068,6 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1094 1068
1095 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1069 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1096 1070
1097 if (sdata->vif.type != NL80211_IFTYPE_AP)
1098 return -EINVAL;
1099
1100 if (params->use_cts_prot >= 0) { 1071 if (params->use_cts_prot >= 0) {
1101 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; 1072 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1102 changed |= BSS_CHANGED_ERP_CTS_PROT; 1073 changed |= BSS_CHANGED_ERP_CTS_PROT;
@@ -1209,9 +1180,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1209 1180
1210 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1181 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1211 1182
1212 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1213 return -EOPNOTSUPP;
1214
1215 switch (req->auth_type) { 1183 switch (req->auth_type) {
1216 case NL80211_AUTHTYPE_OPEN_SYSTEM: 1184 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1217 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN; 1185 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN;
@@ -1268,9 +1236,6 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1268 1236
1269 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1237 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1270 1238
1271 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1272 return -EOPNOTSUPP;
1273
1274 if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 || 1239 if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 ||
1275 !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED)) 1240 !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED))
1276 return -ENOLINK; /* not authenticated */ 1241 return -ENOLINK; /* not authenticated */
@@ -1305,8 +1270,6 @@ static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1305 struct ieee80211_sub_if_data *sdata; 1270 struct ieee80211_sub_if_data *sdata;
1306 1271
1307 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1272 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1308 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1309 return -EOPNOTSUPP;
1310 1273
1311 /* TODO: req->ie */ 1274 /* TODO: req->ie */
1312 return ieee80211_sta_deauthenticate(sdata, req->reason_code); 1275 return ieee80211_sta_deauthenticate(sdata, req->reason_code);
@@ -1319,9 +1282,6 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1319 1282
1320 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1283 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1321 1284
1322 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1323 return -EOPNOTSUPP;
1324
1325 /* TODO: req->ie */ 1285 /* TODO: req->ie */
1326 return ieee80211_sta_disassociate(sdata, req->reason_code); 1286 return ieee80211_sta_disassociate(sdata, req->reason_code);
1327} 1287}
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;