aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-02-14 17:27:01 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-03-06 10:35:37 -0500
commitf8bacc210408f7a2a182f184a9fa1475b8a67440 (patch)
tree714bcf6b0240c622f9affb6ff7df61b4f9dc87a9 /net
parentc0f3a317f2f0e51ad2f8809c83b137958b385c7f (diff)
cfg80211: clean up mesh plink station change API
Make the ability to leave the plink_state unchanged not use a magic -1 variable that isn't in the enum, but an explicit change flag; reject invalid plink states or actions and move the needed constants for plink actions to the right header file. Also reject plink_state changes for non-mesh interfaces. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/cfg.c14
-rw-r--r--net/wireless/nl80211.c29
2 files changed, 33 insertions, 10 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index fb306814576a..ca28405d5f65 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1261,7 +1261,9 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1261 if (ieee80211_vif_is_mesh(&sdata->vif)) { 1261 if (ieee80211_vif_is_mesh(&sdata->vif)) {
1262#ifdef CONFIG_MAC80211_MESH 1262#ifdef CONFIG_MAC80211_MESH
1263 u32 changed = 0; 1263 u32 changed = 0;
1264 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) { 1264 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED &&
1265 (params->sta_modify_mask &
1266 STATION_PARAM_APPLY_PLINK_STATE)) {
1265 switch (params->plink_state) { 1267 switch (params->plink_state) {
1266 case NL80211_PLINK_ESTAB: 1268 case NL80211_PLINK_ESTAB:
1267 if (sta->plink_state != NL80211_PLINK_ESTAB) 1269 if (sta->plink_state != NL80211_PLINK_ESTAB)
@@ -1292,12 +1294,18 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1292 /* nothing */ 1294 /* nothing */
1293 break; 1295 break;
1294 } 1296 }
1297 } else if (params->sta_modify_mask &
1298 STATION_PARAM_APPLY_PLINK_STATE) {
1299 return -EINVAL;
1295 } else { 1300 } else {
1296 switch (params->plink_action) { 1301 switch (params->plink_action) {
1297 case PLINK_ACTION_OPEN: 1302 case NL80211_PLINK_ACTION_NO_ACTION:
1303 /* nothing */
1304 break;
1305 case NL80211_PLINK_ACTION_OPEN:
1298 changed |= mesh_plink_open(sta); 1306 changed |= mesh_plink_open(sta);
1299 break; 1307 break;
1300 case PLINK_ACTION_BLOCK: 1308 case NL80211_PLINK_ACTION_BLOCK:
1301 changed |= mesh_plink_block(sta); 1309 changed |= mesh_plink_block(sta);
1302 break; 1310 break;
1303 } 1311 }
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d44ab216c0ec..9e7ece0e5e5e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3412,7 +3412,6 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3412 memset(&params, 0, sizeof(params)); 3412 memset(&params, 0, sizeof(params));
3413 3413
3414 params.listen_interval = -1; 3414 params.listen_interval = -1;
3415 params.plink_state = -1;
3416 3415
3417 if (info->attrs[NL80211_ATTR_STA_AID]) 3416 if (info->attrs[NL80211_ATTR_STA_AID])
3418 return -EINVAL; 3417 return -EINVAL;
@@ -3451,13 +3450,20 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3451 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) 3450 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
3452 return -EINVAL; 3451 return -EINVAL;
3453 3452
3454 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 3453 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
3455 params.plink_action = 3454 params.plink_action =
3456 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3455 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
3456 if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS)
3457 return -EINVAL;
3458 }
3457 3459
3458 if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) 3460 if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) {
3459 params.plink_state = 3461 params.plink_state =
3460 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]); 3462 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]);
3463 if (params.plink_state >= NUM_NL80211_PLINK_STATES)
3464 return -EINVAL;
3465 params.sta_modify_mask |= STATION_PARAM_APPLY_PLINK_STATE;
3466 }
3461 3467
3462 if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) { 3468 if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) {
3463 enum nl80211_mesh_power_mode pm = nla_get_u32( 3469 enum nl80211_mesh_power_mode pm = nla_get_u32(
@@ -3479,6 +3485,8 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3479 return -EINVAL; 3485 return -EINVAL;
3480 if (params.local_pm) 3486 if (params.local_pm)
3481 return -EINVAL; 3487 return -EINVAL;
3488 if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3489 return -EINVAL;
3482 3490
3483 /* TDLS can't be set, ... */ 3491 /* TDLS can't be set, ... */
3484 if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) 3492 if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
@@ -3542,6 +3550,8 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3542 return -EINVAL; 3550 return -EINVAL;
3543 if (params.local_pm) 3551 if (params.local_pm)
3544 return -EINVAL; 3552 return -EINVAL;
3553 if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3554 return -EINVAL;
3545 /* reject any changes other than AUTHORIZED or WME (for TDLS) */ 3555 /* reject any changes other than AUTHORIZED or WME (for TDLS) */
3546 if (params.sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) | 3556 if (params.sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) |
3547 BIT(NL80211_STA_FLAG_WME))) 3557 BIT(NL80211_STA_FLAG_WME)))
@@ -3553,6 +3563,8 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
3553 return -EINVAL; 3563 return -EINVAL;
3554 if (params.local_pm) 3564 if (params.local_pm)
3555 return -EINVAL; 3565 return -EINVAL;
3566 if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3567 return -EINVAL;
3556 if (info->attrs[NL80211_ATTR_HT_CAPABILITY] || 3568 if (info->attrs[NL80211_ATTR_HT_CAPABILITY] ||
3557 info->attrs[NL80211_ATTR_VHT_CAPABILITY]) 3569 info->attrs[NL80211_ATTR_VHT_CAPABILITY])
3558 return -EINVAL; 3570 return -EINVAL;
@@ -3652,9 +3664,12 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
3652 params.vht_capa = 3664 params.vht_capa =
3653 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); 3665 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
3654 3666
3655 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 3667 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
3656 params.plink_action = 3668 params.plink_action =
3657 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 3669 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
3670 if (params.plink_action >= NUM_NL80211_PLINK_ACTIONS)
3671 return -EINVAL;
3672 }
3658 3673
3659 if (!rdev->ops->add_station) 3674 if (!rdev->ops->add_station)
3660 return -EOPNOTSUPP; 3675 return -EOPNOTSUPP;