Page MenuHomeFreeBSD

D45516.diff
No OneTemporary

D45516.diff

diff --git a/sys/dev/ath/if_ath_keycache.c b/sys/dev/ath/if_ath_keycache.c
--- a/sys/dev/ath/if_ath_keycache.c
+++ b/sys/dev/ath/if_ath_keycache.c
@@ -434,8 +434,7 @@
/*
* Only global keys should have key index assigned.
*/
- if (!(&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
+ if (!ieee80211_is_key_global(vap, k)) {
/* should not happen */
DPRINTF(sc, ATH_DEBUG_KEYCACHE,
"%s: bogus group key\n", __func__);
diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c
--- a/sys/dev/mwl/if_mwl.c
+++ b/sys/dev/mwl/if_mwl.c
@@ -1519,8 +1519,7 @@
if (k->wk_keyix != IEEE80211_KEYIX_NONE ||
(k->wk_flags & IEEE80211_KEY_GROUP)) {
- if (!(&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
+ if (!ieee80211_is_key_global(vap, k)) {
/* should not happen */
DPRINTF(sc, MWL_DEBUG_KEYCACHE,
"%s: bogus group key\n", __func__);
diff --git a/sys/dev/rtwn/if_rtwn_cam.c b/sys/dev/rtwn/if_rtwn_cam.c
--- a/sys/dev/rtwn/if_rtwn_cam.c
+++ b/sys/dev/rtwn/if_rtwn_cam.c
@@ -113,8 +113,7 @@
struct rtwn_softc *sc = vap->iv_ic->ic_softc;
int i, start;
- if (&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (ieee80211_is_key_global(vap, k)) {
*keyix = ieee80211_crypto_get_key_wepidx(vap, k);
if (sc->sc_hwcrypto != RTWN_CRYPTO_FULL)
k->wk_flags |= IEEE80211_KEY_SWCRYPT;
@@ -308,8 +307,7 @@
return (1);
}
- if (&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (ieee80211_is_key_global(vap, k)) {
if (sc->sc_hwcrypto == RTWN_CRYPTO_FULL) {
struct rtwn_vap *rvp = RTWN_VAP(vap);
diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c
--- a/sys/dev/usb/wlan/if_rsu.c
+++ b/sys/dev/usb/wlan/if_rsu.c
@@ -1526,10 +1526,10 @@
struct rsu_softc *sc = vap->iv_ic->ic_softc;
int is_checked = 0;
- if (&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (ieee80211_is_key_global(vap, k)) {
*keyix = ieee80211_crypto_get_key_wepidx(vap, k);
} else {
+ /* Note: assumes this is a pairwise key */
if (vap->iv_opmode != IEEE80211_M_STA) {
*keyix = 0;
/* TODO: obtain keyix from node id */
@@ -1570,8 +1570,7 @@
}
/* Handle group keys. */
- if (&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (ieee80211_is_key_global(vap, k)) {
KASSERT(k->wk_keyix < nitems(sc->group_keys),
("keyix %u > %zu\n", k->wk_keyix, nitems(sc->group_keys)));
diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c
--- a/sys/dev/usb/wlan/if_rum.c
+++ b/sys/dev/usb/wlan/if_rum.c
@@ -1468,8 +1468,7 @@
flags |= RT2573_TX_CIP_MODE(mode);
/* Do not trust GROUP flag */
- if (!(k >= &vap->iv_nw_keys[0] &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]))
+ if (ieee80211_is_key_unicast(vap, k))
flags |= RT2573_TX_KEY_PAIR;
else
pos += 0 * RT2573_SKEY_MAX; /* vap id */
@@ -3006,8 +3005,7 @@
struct rum_softc *sc = vap->iv_ic->ic_softc;
uint8_t i;
- if (!(&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
+ if (ieee80211_is_key_unicast(vap, k)) {
if (!(k->wk_flags & IEEE80211_KEY_SWCRYPT)) {
RUM_LOCK(sc);
for (i = 0; i < RT2573_ADDR_MAX; i++) {
@@ -3044,7 +3042,7 @@
return 1;
}
- group = k >= &vap->iv_nw_keys[0] && k < &vap->iv_nw_keys[IEEE80211_WEP_NKID];
+ group = ieee80211_is_key_global(vap, k);
return !rum_cmd_sleepable(sc, k, sizeof(*k), 0,
group ? rum_group_key_set_cb : rum_pair_key_set_cb);
@@ -3061,7 +3059,7 @@
return 1;
}
- group = k >= &vap->iv_nw_keys[0] && k < &vap->iv_nw_keys[IEEE80211_WEP_NKID];
+ group = ieee80211_is_key_global(vap, k);
return !rum_cmd_sleepable(sc, k, sizeof(*k), 0,
group ? rum_group_key_del_cb : rum_pair_key_del_cb);
diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c
--- a/sys/dev/wpi/if_wpi.c
+++ b/sys/dev/wpi/if_wpi.c
@@ -4641,8 +4641,8 @@
return !error;
}
- if (!(kflags & WPI_KFLAG_MULTICAST) && &vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (!(kflags & WPI_KFLAG_MULTICAST) &&
+ ieee80211_is_key_global(vap, k)) {
kflags |= WPI_KFLAG_MULTICAST;
node.kflags = htole16(kflags);
@@ -4726,8 +4726,8 @@
return !error;
}
- if (!(kflags & WPI_KFLAG_MULTICAST) && &vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (!(kflags & WPI_KFLAG_MULTICAST) &&
+ ieee80211_is_key_global(vap, k)) {
kflags |= WPI_KFLAG_MULTICAST;
node.kflags = htole16(kflags);
@@ -4782,8 +4782,7 @@
}
/* Handle group keys. */
- if (&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
+ if (ieee80211_is_key_global(vap, k)) {
WPI_NT_LOCK(sc);
if (set)
wvp->wv_gtk |= WPI_VAP_KEY(k->wk_keyix);
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -2679,3 +2679,34 @@
return 'b';
return 'f';
}
+
+/*
+ * Determine whether the given key in the given VAP is a global key.
+ * (key index 0..3, shared between all stations on a VAP.)
+ *
+ * This is either a WEP key or a GROUP key.
+ *
+ * Note this will NOT return true if it is a IGTK key.
+ */
+bool
+ieee80211_is_key_global(const struct ieee80211vap *vap,
+ const struct ieee80211_key *key)
+{
+ return (&vap->iv_nw_keys[0] <= key &&
+ key < &vap->iv_nw_keys[IEEE80211_WEP_NKID]);
+}
+
+/*
+ * Determine whether the given key in the given VAP is a unicast key.
+ */
+bool
+ieee80211_is_key_unicast(const struct ieee80211vap *vap,
+ const struct ieee80211_key *key)
+{
+ /*
+ * This is a short-cut for now; eventually we will need
+ * to support multiple unicast keys, IGTK, etc) so we
+ * will absolutely need to fix the key flags.
+ */
+ return (!ieee80211_is_key_global(vap, key));
+}
diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c
--- a/sys/net80211/ieee80211_crypto.c
+++ b/sys/net80211/ieee80211_crypto.c
@@ -62,8 +62,8 @@
null_key_alloc(struct ieee80211vap *vap, struct ieee80211_key *k,
ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
{
- if (!(&vap->iv_nw_keys[0] <= k &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
+
+ if (!ieee80211_is_key_global(vap, k)) {
/*
* Not in the global key table, the driver should handle this
* by allocating a slot in the h/w key table/cache. In
@@ -606,9 +606,9 @@
const struct ieee80211_key *k)
{
- if (k >= &vap->iv_nw_keys[0] &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])
+ if (ieee80211_is_key_global(vap, k)) {
return (k - vap->iv_nw_keys);
+ }
return (-1);
}
@@ -618,11 +618,11 @@
uint8_t
ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k)
{
- if (k >= &vap->iv_nw_keys[0] &&
- k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])
+ if (ieee80211_is_key_global(vap, k)) {
return (k - vap->iv_nw_keys);
- else
- return (0);
+ }
+
+ return (0);
}
struct ieee80211_key *
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -824,6 +824,11 @@
#define ieee80211_get_home_channel(_ic) ((_ic)->ic_bsschan)
#define ieee80211_get_vap_desired_channel(_iv) ((_iv)->iv_des_chan)
+bool ieee80211_is_key_global(const struct ieee80211vap *vap,
+ const struct ieee80211_key *key);
+bool ieee80211_is_key_unicast(const struct ieee80211vap *vap,
+ const struct ieee80211_key *key);
+
void ieee80211_radiotap_attach(struct ieee80211com *,
struct ieee80211_radiotap_header *th, int tlen,
uint32_t tx_radiotap,

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 14, 9:34 PM (7 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14634003
Default Alt Text
D45516.diff (7 KB)

Event Timeline