History

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.

Johannes Berg committed 13 years ago

Commit f8bacc21 parent c0f3a314 files · +54 −24Browse files

Unified · Split

4 files
  1. include/net/cfg80211.h +2 −13
  2. include/uapi/linux/nl80211.h +19 −1
  3. net/mac80211/cfg.c +11 −3
  4. net/wireless/nl80211.c +22 −7
include/net/cfg80211.h+2−13
@@ -610,23 +610,11 @@ struct cfg80211_ap_settings { · 609 unmodified lines
610610 bool radar_required;
611611 };
612612
613−/**
614− * enum plink_action - actions to perform in mesh peers
615− *
616− * @PLINK_ACTION_INVALID: action 0 is reserved
617− * @PLINK_ACTION_OPEN: start mesh peer link establishment
618− * @PLINK_ACTION_BLOCK: block traffic from this mesh peer
619− */
620−enum plink_actions {
621− PLINK_ACTION_INVALID,
622− PLINK_ACTION_OPEN,
623− PLINK_ACTION_BLOCK,
624−};
625−
626613 /**
627614 * enum station_parameters_apply_mask - station parameter values to apply
628615 * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
629616 * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
617+ * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
630618 *
631619 * Not all station parameters have in-band "no change" signalling,
632620 * for those that don't these flags will are used.
@@ -634,6 +622,7 @@ enum plink_actions { · 1 unmodified line
634622 enum station_parameters_apply_mask {
635623 STATION_PARAM_APPLY_UAPSD = BIT(0),
636624 STATION_PARAM_APPLY_CAPABILITY = BIT(1),
625+ STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
637626 };
638627
639628 /**
include/uapi/linux/nl80211.h+19−1
@@ -884,7 +884,8 @@ enum nl80211_commands { · 883 unmodified lines
884884 * consisting of a nested array.
885885 *
886886 * @NL80211_ATTR_MESH_ID: mesh id (1-32 bytes).
887− * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link.
887+ * @NL80211_ATTR_STA_PLINK_ACTION: action to perform on the mesh peer link
888+ * (see &enum nl80211_plink_action).
888889 * @NL80211_ATTR_MPATH_NEXT_HOP: MAC address of the next hop for a mesh path.
889890 * @NL80211_ATTR_MPATH_INFO: information about a mesh_path, part of mesh path
890891 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
@@ -3307,6 +3308,23 @@ enum nl80211_plink_state { · 2416 unmodified lines
33073308 MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
33083309 };
33093310
3311+/**
3312+ * enum nl80211_plink_action - actions to perform in mesh peers
3313+ *
3314+ * @NL80211_PLINK_ACTION_NO_ACTION: perform no action
3315+ * @NL80211_PLINK_ACTION_OPEN: start mesh peer link establishment
3316+ * @NL80211_PLINK_ACTION_BLOCK: block traffic from this mesh peer
3317+ * @NUM_NL80211_PLINK_ACTIONS: number of possible actions
3318+ */
3319+enum plink_actions {
3320+ NL80211_PLINK_ACTION_NO_ACTION,
3321+ NL80211_PLINK_ACTION_OPEN,
3322+ NL80211_PLINK_ACTION_BLOCK,
3323+
3324+ NUM_NL80211_PLINK_ACTIONS,
3325+};
3326+
3327+
33103328 #define NL80211_KCK_LEN 16
33113329 #define NL80211_KEK_LEN 16
33123330 #define NL80211_REPLAY_CTR_LEN 8
net/mac80211/cfg.c+11−3
@@ -1261,7 +1261,9 @@ static int sta_apply_parameters(struct ieee80211_local *local, · 1260 unmodified lines
12611261 if (ieee80211_vif_is_mesh(&sdata->vif)) {
12621262 #ifdef CONFIG_MAC80211_MESH
12631263 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)) {
12651267 switch (params->plink_state) {
12661268 case NL80211_PLINK_ESTAB:
12671269 if (sta->plink_state != NL80211_PLINK_ESTAB)
@@ -1292,12 +1294,18 @@ static int sta_apply_parameters(struct ieee80211_local *local, · 24 unmodified lines
12921294 /* nothing */
12931295 break;
12941296 }
1297+ } else if (params->sta_modify_mask &
1298+ STATION_PARAM_APPLY_PLINK_STATE) {
1299+ return -EINVAL;
12951300 } else {
12961301 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:
12981306 changed |= mesh_plink_open(sta);
12991307 break;
1300− case PLINK_ACTION_BLOCK:
1308+ case NL80211_PLINK_ACTION_BLOCK:
13011309 changed |= mesh_plink_block(sta);
13021310 break;
13031311 }
net/wireless/nl80211.c+22−7
@@ -3412,7 +3412,6 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) · 3411 unmodified lines
34123412 memset(&params, 0, sizeof(params));
34133413
34143414 params.listen_interval = -1;
3415− params.plink_state = -1;
34163415
34173416 if (info->attrs[NL80211_ATTR_STA_AID])
34183417 return -EINVAL;
@@ -3451,13 +3450,20 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) · 32 unmodified lines
34513450 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
34523451 return -EINVAL;
34533452
3454− if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
3453+ if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
34553454 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+ }
34573459
3458− if (info->attrs[NL80211_ATTR_STA_PLINK_STATE])
3460+ if (info->attrs[NL80211_ATTR_STA_PLINK_STATE]) {
34593461 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+ }
34613467
34623468 if (info->attrs[NL80211_ATTR_LOCAL_MESH_POWER_MODE]) {
34633469 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) · 15 unmodified lines
34793485 return -EINVAL;
34803486 if (params.local_pm)
34813487 return -EINVAL;
3488+ if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3489+ return -EINVAL;
34823490
34833491 /* TDLS can't be set, ... */
34843492 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) · 57 unmodified lines
35423550 return -EINVAL;
35433551 if (params.local_pm)
35443552 return -EINVAL;
3553+ if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3554+ return -EINVAL;
35453555 /* reject any changes other than AUTHORIZED or WME (for TDLS) */
35463556 if (params.sta_flags_mask & ~(BIT(NL80211_STA_FLAG_AUTHORIZED) |
35473557 BIT(NL80211_STA_FLAG_WME)))
@@ -3553,6 +3563,8 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) · 5 unmodified lines
35533563 return -EINVAL;
35543564 if (params.local_pm)
35553565 return -EINVAL;
3566+ if (params.sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE)
3567+ return -EINVAL;
35563568 if (info->attrs[NL80211_ATTR_HT_CAPABILITY] ||
35573569 info->attrs[NL80211_ATTR_VHT_CAPABILITY])
35583570 return -EINVAL;
@@ -3652,9 +3664,12 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) · 93 unmodified lines
36523664 params.vht_capa =
36533665 nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
36543666
3655− if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
3667+ if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) {
36563668 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+ }
36583673
36593674 if (!rdev->ops->add_station)
36603675 return -EOPNOTSUPP;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t