aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-03-20 15:21:18 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-27 20:13:05 -0400
commit35a8efe1a67ba5d7bb7492f67f52ed2aa4925892 (patch)
tree7783b27bebbc3f113a15ba0b884c24fb627c37a2
parent255e737eab645ec6037baeca04a5e0a7c3b1f459 (diff)
nl80211: Check that netif_runnin is true in cfg80211 code
We do not want to require all the drivers using cfg80211 to need to do this or to be prepared to handle these commands when the interface is down. Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/cfg.c25
-rw-r--r--net/wireless/nl80211.c40
2 files changed, 40 insertions, 25 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index f5c15c9a00c..b5810b4c79a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -728,10 +728,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
728 int err; 728 int err;
729 int layer2_update; 729 int layer2_update;
730 730
731 /* Prevent a race with changing the rate control algorithm */
732 if (!netif_running(dev))
733 return -ENETDOWN;
734
735 if (params->vlan) { 731 if (params->vlan) {
736 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 732 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
737 733
@@ -860,9 +856,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
860 struct sta_info *sta; 856 struct sta_info *sta;
861 int err; 857 int err;
862 858
863 if (!netif_running(dev))
864 return -ENETDOWN;
865
866 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 859 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
867 860
868 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT) 861 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
@@ -913,9 +906,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
913 struct mesh_path *mpath; 906 struct mesh_path *mpath;
914 struct sta_info *sta; 907 struct sta_info *sta;
915 908
916 if (!netif_running(dev))
917 return -ENETDOWN;
918
919 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 909 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
920 910
921 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT) 911 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
@@ -1202,9 +1192,6 @@ static int ieee80211_scan(struct wiphy *wiphy,
1202{ 1192{
1203 struct ieee80211_sub_if_data *sdata; 1193 struct ieee80211_sub_if_data *sdata;
1204 1194
1205 if (!netif_running(dev))
1206 return -ENETDOWN;
1207
1208 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1195 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1209 1196
1210 if (sdata->vif.type != NL80211_IFTYPE_STATION && 1197 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
@@ -1220,9 +1207,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1220{ 1207{
1221 struct ieee80211_sub_if_data *sdata; 1208 struct ieee80211_sub_if_data *sdata;
1222 1209
1223 if (!netif_running(dev))
1224 return -ENETDOWN;
1225
1226 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1210 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1227 1211
1228 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1212 if (sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -1282,9 +1266,6 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1282 struct ieee80211_sub_if_data *sdata; 1266 struct ieee80211_sub_if_data *sdata;
1283 int ret; 1267 int ret;
1284 1268
1285 if (!netif_running(dev))
1286 return -ENETDOWN;
1287
1288 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1269 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1289 1270
1290 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1271 if (sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -1323,9 +1304,6 @@ static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1323{ 1304{
1324 struct ieee80211_sub_if_data *sdata; 1305 struct ieee80211_sub_if_data *sdata;
1325 1306
1326 if (!netif_running(dev))
1327 return -ENETDOWN;
1328
1329 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1307 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1330 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1308 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1331 return -EOPNOTSUPP; 1309 return -EOPNOTSUPP;
@@ -1339,9 +1317,6 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1339{ 1317{
1340 struct ieee80211_sub_if_data *sdata; 1318 struct ieee80211_sub_if_data *sdata;
1341 1319
1342 if (!netif_running(dev))
1343 return -ENETDOWN;
1344
1345 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1320 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1346 1321
1347 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1322 if (sdata->vif.type != NL80211_IFTYPE_STATION)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6f38ee7a3c9..6bb73a3a339 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1556,6 +1556,11 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1556 goto out; 1556 goto out;
1557 } 1557 }
1558 1558
1559 if (!netif_running(dev)) {
1560 err = -ENETDOWN;
1561 goto out;
1562 }
1563
1559 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, &params); 1564 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, &params);
1560 1565
1561 out: 1566 out:
@@ -1808,6 +1813,11 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1808 goto out; 1813 goto out;
1809 } 1814 }
1810 1815
1816 if (!netif_running(dev)) {
1817 err = -ENETDOWN;
1818 goto out;
1819 }
1820
1811 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop); 1821 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
1812 1822
1813 out: 1823 out:
@@ -1846,6 +1856,11 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1846 goto out; 1856 goto out;
1847 } 1857 }
1848 1858
1859 if (!netif_running(dev)) {
1860 err = -ENETDOWN;
1861 goto out;
1862 }
1863
1849 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop); 1864 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
1850 1865
1851 out: 1866 out:
@@ -2380,6 +2395,11 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
2380 goto out; 2395 goto out;
2381 } 2396 }
2382 2397
2398 if (!netif_running(dev)) {
2399 err = -ENETDOWN;
2400 goto out;
2401 }
2402
2383 if (drv->scan_req) { 2403 if (drv->scan_req) {
2384 err = -EBUSY; 2404 err = -EBUSY;
2385 goto out; 2405 goto out;
@@ -2641,6 +2661,11 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
2641 goto out; 2661 goto out;
2642 } 2662 }
2643 2663
2664 if (!netif_running(dev)) {
2665 err = -ENETDOWN;
2666 goto out;
2667 }
2668
2644 if (!info->attrs[NL80211_ATTR_MAC]) { 2669 if (!info->attrs[NL80211_ATTR_MAC]) {
2645 err = -EINVAL; 2670 err = -EINVAL;
2646 goto out; 2671 goto out;
@@ -2709,6 +2734,11 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
2709 goto out; 2734 goto out;
2710 } 2735 }
2711 2736
2737 if (!netif_running(dev)) {
2738 err = -ENETDOWN;
2739 goto out;
2740 }
2741
2712 if (!info->attrs[NL80211_ATTR_MAC] || 2742 if (!info->attrs[NL80211_ATTR_MAC] ||
2713 !info->attrs[NL80211_ATTR_SSID]) { 2743 !info->attrs[NL80211_ATTR_SSID]) {
2714 err = -EINVAL; 2744 err = -EINVAL;
@@ -2767,6 +2797,11 @@ static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
2767 goto out; 2797 goto out;
2768 } 2798 }
2769 2799
2800 if (!netif_running(dev)) {
2801 err = -ENETDOWN;
2802 goto out;
2803 }
2804
2770 if (!info->attrs[NL80211_ATTR_MAC]) { 2805 if (!info->attrs[NL80211_ATTR_MAC]) {
2771 err = -EINVAL; 2806 err = -EINVAL;
2772 goto out; 2807 goto out;
@@ -2821,6 +2856,11 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
2821 goto out; 2856 goto out;
2822 } 2857 }
2823 2858
2859 if (!netif_running(dev)) {
2860 err = -ENETDOWN;
2861 goto out;
2862 }
2863
2824 if (!info->attrs[NL80211_ATTR_MAC]) { 2864 if (!info->attrs[NL80211_ATTR_MAC]) {
2825 err = -EINVAL; 2865 err = -EINVAL;
2826 goto out; 2866 goto out;