Commit 63fc33ce authored by Daniel Drake's avatar Daniel Drake Committed by John W. Linville

[PATCH] mac80211: improved 802.11g CTS protection

Currently, CTS protection is partially implemented twice:
 1. via prism2 ioctls, only used by hostapd
 2. via STA beacon parsing, recorded in sta.use_protection but never used
    (other than printed in debugfs)

Protection control should be implemented on a per-subif basis. For example,
a single physical device may be running a soft AP on one channel, and a STA
on another. The AP interface should use protection based on what hostapd told
it, and the STA interface should use protection based on beacon parsing.
These should operate independantly: one subif using protection should not
influence the other.

To implement this, I moved the use_protection flag into ieee80211_sub_if_data
and removed the device-global cts_protect_erp_frames flag.

I also made the PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES write operation only
available for AP interfaces, to avoid any possibility of the user messing with
the behaviour of a STA.
Signed-off-by: default avatarDaniel Drake <dsd@gentoo.org>
Signed-off-by: default avatarJiri Benc <jbenc@suse.cz>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5628221c
...@@ -118,7 +118,7 @@ static ssize_t ieee80211_if_fmt_flags( ...@@ -118,7 +118,7 @@ static ssize_t ieee80211_if_fmt_flags(
sdata->u.sta.authenticated ? "AUTH\n" : "", sdata->u.sta.authenticated ? "AUTH\n" : "",
sdata->u.sta.associated ? "ASSOC\n" : "", sdata->u.sta.associated ? "ASSOC\n" : "",
sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "", sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
sdata->u.sta.use_protection ? "CTS prot\n" : ""); sdata->use_protection ? "CTS prot\n" : "");
} }
__IEEE80211_IF_FILE(flags); __IEEE80211_IF_FILE(flags);
......
...@@ -442,7 +442,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx) ...@@ -442,7 +442,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx)
if (!tx->u.tx.rate) if (!tx->u.tx.rate)
return TXRX_DROP; return TXRX_DROP;
if (tx->u.tx.mode->mode == MODE_IEEE80211G && if (tx->u.tx.mode->mode == MODE_IEEE80211G &&
tx->local->cts_protect_erp_frames && tx->fragmented && tx->sdata->use_protection && tx->fragmented &&
extra.nonerp) { extra.nonerp) {
tx->u.tx.last_frag_rate = tx->u.tx.rate; tx->u.tx.last_frag_rate = tx->u.tx.rate;
tx->u.tx.probe_last_frag = extra.probe ? 1 : 0; tx->u.tx.probe_last_frag = extra.probe ? 1 : 0;
...@@ -868,8 +868,7 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx) ...@@ -868,8 +868,7 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
* for the frame. */ * for the frame. */
if (mode->mode == MODE_IEEE80211G && if (mode->mode == MODE_IEEE80211G &&
(tx->u.tx.rate->flags & IEEE80211_RATE_ERP) && (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) &&
tx->u.tx.unicast && tx->u.tx.unicast && tx->sdata->use_protection &&
tx->local->cts_protect_erp_frames &&
!(control->flags & IEEE80211_TXCTL_USE_RTS_CTS)) !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS))
control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT; control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT;
......
...@@ -241,7 +241,6 @@ struct ieee80211_if_sta { ...@@ -241,7 +241,6 @@ struct ieee80211_if_sta {
unsigned int authenticated:1; unsigned int authenticated:1;
unsigned int associated:1; unsigned int associated:1;
unsigned int probereq_poll:1; unsigned int probereq_poll:1;
unsigned int use_protection:1;
unsigned int create_ibss:1; unsigned int create_ibss:1;
unsigned int mixed_cell:1; unsigned int mixed_cell:1;
unsigned int wmm_enabled:1; unsigned int wmm_enabled:1;
...@@ -284,6 +283,7 @@ struct ieee80211_sub_if_data { ...@@ -284,6 +283,7 @@ struct ieee80211_sub_if_data {
int mc_count; int mc_count;
unsigned int allmulti:1; unsigned int allmulti:1;
unsigned int promisc:1; unsigned int promisc:1;
unsigned int use_protection:1; /* CTS protect ERP frames */
struct net_device_stats stats; struct net_device_stats stats;
int drop_unencrypted; int drop_unencrypted;
...@@ -444,7 +444,6 @@ struct ieee80211_local { ...@@ -444,7 +444,6 @@ struct ieee80211_local {
int *basic_rates[NUM_IEEE80211_MODES]; int *basic_rates[NUM_IEEE80211_MODES];
int rts_threshold; int rts_threshold;
int cts_protect_erp_frames;
int fragmentation_threshold; int fragmentation_threshold;
int short_retry_limit; /* dot11ShortRetryLimit */ int short_retry_limit; /* dot11ShortRetryLimit */
int long_retry_limit; /* dot11LongRetryLimit */ int long_retry_limit; /* dot11LongRetryLimit */
......
...@@ -1180,7 +1180,10 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev, ...@@ -1180,7 +1180,10 @@ static int ieee80211_ioctl_prism2_param(struct net_device *dev,
break; break;
case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES: case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
local->cts_protect_erp_frames = value; if (sdata->type != IEEE80211_IF_TYPE_AP)
ret = -ENOENT;
else
sdata->use_protection = value;
break; break;
case PRISM2_PARAM_PREAMBLE: case PRISM2_PARAM_PREAMBLE:
...@@ -1303,7 +1306,7 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev, ...@@ -1303,7 +1306,7 @@ static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
break; break;
case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES: case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
*param = local->cts_protect_erp_frames; *param = sdata->use_protection;
break; break;
case PRISM2_PARAM_PREAMBLE: case PRISM2_PARAM_PREAMBLE:
......
...@@ -316,12 +316,11 @@ static void ieee80211_sta_wmm_params(struct net_device *dev, ...@@ -316,12 +316,11 @@ static void ieee80211_sta_wmm_params(struct net_device *dev,
static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value) static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value)
{ {
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_if_sta *ifsta = &sdata->u.sta; struct ieee80211_if_sta *ifsta = &sdata->u.sta;
int use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0; int use_protection = (erp_value & WLAN_ERP_USE_PROTECTION) != 0;
if (use_protection != !!ifsta->use_protection) { if (use_protection != sdata->use_protection) {
if (net_ratelimit()) { if (net_ratelimit()) {
printk(KERN_DEBUG "%s: CTS protection %s (BSSID=" printk(KERN_DEBUG "%s: CTS protection %s (BSSID="
MAC_FMT ")\n", MAC_FMT ")\n",
...@@ -329,8 +328,7 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value) ...@@ -329,8 +328,7 @@ static void ieee80211_handle_erp_ie(struct net_device *dev, u8 erp_value)
use_protection ? "enabled" : "disabled", use_protection ? "enabled" : "disabled",
MAC_ARG(ifsta->bssid)); MAC_ARG(ifsta->bssid));
} }
ifsta->use_protection = use_protection ? 1 : 0; sdata->use_protection = use_protection;
local->cts_protect_erp_frames = use_protection;
} }
} }
...@@ -390,6 +388,7 @@ static void ieee80211_set_associated(struct net_device *dev, ...@@ -390,6 +388,7 @@ static void ieee80211_set_associated(struct net_device *dev,
struct ieee80211_if_sta *ifsta, int assoc) struct ieee80211_if_sta *ifsta, int assoc)
{ {
union iwreq_data wrqu; union iwreq_data wrqu;
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (ifsta->associated == assoc) if (ifsta->associated == assoc)
return; return;
...@@ -417,6 +416,7 @@ static void ieee80211_set_associated(struct net_device *dev, ...@@ -417,6 +416,7 @@ static void ieee80211_set_associated(struct net_device *dev,
ieee80211_sta_send_associnfo(dev, ifsta); ieee80211_sta_send_associnfo(dev, ifsta);
} else { } else {
netif_carrier_off(dev); netif_carrier_off(dev);
sdata->use_protection = 0;
memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
} }
wrqu.ap_addr.sa_family = ARPHRD_ETHER; wrqu.ap_addr.sa_family = ARPHRD_ETHER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment