Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83d5cc01 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

mac80211: station state transition error handling



In the future, when we start notifying drivers,
state transitions could potentially fail. To make
it easier to distinguish between programming bugs
and driver failures:
 * rename sta_info_move_state() to
   sta_info_pre_move_state() which can only be
   called before the station is inserted (and
   check this with a new station flag).
 * rename sta_info_move_state_checked() to just
   plain sta_info_move_state(), as it will be
   the regular function that can fail for more
   than just one reason (bad transition or an
   error from the driver)

This makes the programming model easier -- one of
the functions can only be called before insertion
and can't fail, the other can fail.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c037b836
Loading
Loading
Loading
Loading
+8 −14
Original line number Diff line number Diff line
@@ -776,12 +776,10 @@ static int sta_apply_parameters(struct ieee80211_local *local,

		if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
		    !test_sta_flag(sta, WLAN_STA_AUTH)) {
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_AUTH);
			ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
			if (ret)
				return ret;
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_ASSOC);
			ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
			if (ret)
				return ret;
		}
@@ -789,11 +787,9 @@ static int sta_apply_parameters(struct ieee80211_local *local,

	if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
		if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_AUTHORIZED);
			ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
		else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_ASSOC);
			ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
		if (ret)
			return ret;
	}
@@ -805,12 +801,10 @@ static int sta_apply_parameters(struct ieee80211_local *local,

		if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
		    test_sta_flag(sta, WLAN_STA_AUTH)) {
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_AUTH);
			ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
			if (ret)
				return ret;
			ret = sta_info_move_state_checked(sta,
					IEEE80211_STA_NONE);
			ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
			if (ret)
				return ret;
		}
@@ -944,8 +938,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
	if (!sta)
		return -ENOMEM;

	sta_info_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_move_state(sta, IEEE80211_STA_ASSOC);
	sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);

	err = sta_apply_parameters(local, sta, params);
	if (err) {
+3 −2
Original line number Diff line number Diff line
@@ -63,14 +63,15 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
	test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""

	int res = scnprintf(buf, sizeof(buf),
			    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
			    "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
			    TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
			    TEST(PS_DRIVER), TEST(AUTHORIZED),
			    TEST(SHORT_PREAMBLE),
			    TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
			    TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
			    TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
			    TEST(TDLS_PEER_AUTH));
			    TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
			    TEST(INSERTED));
#undef TEST
	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
+3 −3
Original line number Diff line number Diff line
@@ -265,9 +265,9 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta,
		    addr, sdata->name);
#endif

	sta_info_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_move_state(sta, IEEE80211_STA_ASSOC);
	sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
	sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
	sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);

	rate_control_rate_init(sta);

+3 −3
Original line number Diff line number Diff line
@@ -318,9 +318,9 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
			goto err_del_interface;
		}

		sta_info_move_state(sta, IEEE80211_STA_AUTH);
		sta_info_move_state(sta, IEEE80211_STA_ASSOC);
		sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
		sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
		sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
		sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);

		res = sta_info_insert(sta);
		if (res) {
+3 −3
Original line number Diff line number Diff line
@@ -96,9 +96,9 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
	if (!sta)
		return NULL;

	sta_info_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_move_state(sta, IEEE80211_STA_ASSOC);
	sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
	sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
	sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
	sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);

	set_sta_flag(sta, WLAN_STA_WME);

Loading