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

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

mac80211: clean up set_key callback



The set_key callback now seems rather odd, passing a MAC address
instead of a station struct, and a local address instead of a
vif struct. Change that.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Acked-by: Bob Copeland <me@bobcopeland.com> [ath5k]
Acked-by: Ivo van Doorn <ivdoorn@gmail.com> [rt2x00]
Acked-by: Christian Lamparter <chunkeey@web.de> [p54]
Tested-by: Kalle Valo <kalle.valo@nokia.com> [iwl3945]
Tested-by: Samuel Ortiz <samuel@sortiz.org> [iwl3945]
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b3093664
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -232,7 +232,7 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
		int mc_count, struct dev_mc_list *mclist);
static int ath5k_set_key(struct ieee80211_hw *hw,
		enum set_key_cmd cmd,
		const u8 *local_addr, const u8 *addr,
		struct ieee80211_vif *vif, struct ieee80211_sta *sta,
		struct ieee80211_key_conf *key);
static int ath5k_get_stats(struct ieee80211_hw *hw,
		struct ieee80211_low_level_stats *stats);
@@ -2991,7 +2991,7 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,

static int
ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		const u8 *local_addr, const u8 *addr,
	      struct ieee80211_vif *vif, struct ieee80211_sta *sta,
	      struct ieee80211_key_conf *key)
{
	struct ath5k_softc *sc = hw->priv;
@@ -3015,7 +3015,8 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,

	switch (cmd) {
	case SET_KEY:
		ret = ath5k_hw_set_key(sc->ah, key->keyidx, key, addr);
		ret = ath5k_hw_set_key(sc->ah, key->keyidx, key,
				       sta ? sta->addr : NULL);
		if (ret) {
			ATH5K_ERR(sc, "can't set the key\n");
			goto unlock;
+1 −1
Original line number Diff line number Diff line
@@ -1139,7 +1139,7 @@ int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac)

	/* MAC may be NULL if it's a broadcast key. In this case no need to
	 * to compute AR5K_LOW_ID and AR5K_HIGH_ID as we already know it. */
	if (unlikely(mac == NULL)) {
	if (!mac) {
		low_id = 0xffffffff;
		high_id = 0xffff | AR5K_KEYTABLE_VALID;
	} else {
+12 −6
Original line number Diff line number Diff line
@@ -794,7 +794,7 @@ static int ath_reserve_key_cache_slot(struct ath_softc *sc)
}

static int ath_key_config(struct ath_softc *sc,
			  const u8 *addr,
			  struct ieee80211_sta *sta,
			  struct ieee80211_key_conf *key)
{
	struct ath9k_keyval hk;
@@ -828,7 +828,10 @@ static int ath_key_config(struct ath_softc *sc,
	} else if (key->keyidx) {
		struct ieee80211_vif *vif;

		mac = addr;
		if (WARN_ON(!sta))
			return -EOPNOTSUPP;
		mac = sta->addr;

		vif = sc->sc_vaps[0];
		if (vif->type != NL80211_IFTYPE_AP) {
			/* Only keyidx 0 should be used with unicast key, but
@@ -837,7 +840,10 @@ static int ath_key_config(struct ath_softc *sc,
		} else
			return -EIO;
	} else {
		mac = addr;
		if (WARN_ON(!sta))
			return -EOPNOTSUPP;
		mac = sta->addr;

		if (key->alg == ALG_TKIP)
			idx = ath_reserve_key_cache_slot_tkip(sc);
		else
@@ -2320,8 +2326,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw,

static int ath9k_set_key(struct ieee80211_hw *hw,
			 enum set_key_cmd cmd,
			 const u8 *local_addr,
			 const u8 *addr,
			 struct ieee80211_vif *vif,
			 struct ieee80211_sta *sta,
			 struct ieee80211_key_conf *key)
{
	struct ath_softc *sc = hw->priv;
@@ -2331,7 +2337,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,

	switch (cmd) {
	case SET_KEY:
		ret = ath_key_config(sc, addr, key);
		ret = ath_key_config(sc, sta, key);
		if (ret >= 0) {
			key->hw_key_idx = ret;
			/* push IV and Michael MIC generation to stack */
+9 −4
Original line number Diff line number Diff line
@@ -3476,7 +3476,7 @@ static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
}

static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
			   const u8 *local_addr, const u8 *addr,
			  struct ieee80211_vif *vif, struct ieee80211_sta *sta,
			  struct ieee80211_key_conf *key)
{
	struct b43_wl *wl = hw_to_b43_wl(hw);
@@ -3542,9 +3542,14 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		}

		if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
			if (WARN_ON(!sta)) {
				err = -EOPNOTSUPP;
				goto out_unlock;
			}
			/* Pairwise key with an assigned MAC address. */
			err = b43_key_write(dev, -1, algorithm,
					    key->key, key->keylen, addr, key);
					    key->key, key->keylen,
					    sta->addr, key);
		} else {
			/* Group key */
			err = b43_key_write(dev, index, algorithm,
@@ -3577,7 +3582,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
		       "mac: %pM\n",
		       cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
		       addr);
		       sta ? sta->addr : "<group key>");
		b43_dump_keymemory(dev);
	}
	write_unlock(&wl->tx_lock);
+6 −4
Original line number Diff line number Diff line
@@ -3021,13 +3021,17 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
}

static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
			   const u8 *local_addr, const u8 *addr,
			   struct ieee80211_vif *vif,
			   struct ieee80211_sta *sta,
			   struct ieee80211_key_conf *key)
{
	struct iwl_priv *priv = hw->priv;
	int ret = 0;
	u8 sta_id = IWL_INVALID_STATION;
	u8 is_default_wep_key = 0;
	static const u8 bcast_addr[ETH_ALEN] =
		{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
	static const u8 *addr;

	IWL_DEBUG_MAC80211("enter\n");

@@ -3036,9 +3040,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		return -EOPNOTSUPP;
	}

	if (is_zero_ether_addr(addr))
		/* only support pairwise keys */
		return -EOPNOTSUPP;
	addr = sta ? sta->addr : bcast_addr;

	sta_id = iwl_find_station(priv, addr);
	if (sta_id == IWL_INVALID_STATION) {
Loading