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

Commit 4b433570 authored by Johannes Berg's avatar Johannes Berg Committed by Connor O'Brien
Browse files

UPSTREAM: cfg80211: fix and clean up cfg80211_gen_new_bssid()



Fix cfg80211_gen_new_bssid() to not rely on u64 modulo arithmetic,
which isn't needed since we really just want to mask there. Also,
clean it up to calculate the mask only once and use GENMASK_ULL()
instead of open-coding the mask calculation.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
(cherry picked from commit 5d4071abd9a1e2b417beef31aaf7d45999e4882e)
Bug: 154523213
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
Change-Id: Ia7f3782f7831b7994fde3cfae85308c6b73602d4
parent 1cb2737c
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -5137,22 +5137,20 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy,
 * @bssid: transmitter BSSID
 * @max_bssid: max BSSID indicator, taken from Multiple BSSID element
 * @mbssid_index: BSSID index, taken from Multiple BSSID index element
 * @new_bssid_addr: address of the resulting BSSID
 * @new_bssid: calculated nontransmitted BSSID
 */
static inline void cfg80211_gen_new_bssid(const u8 *bssid, u8 max_bssid,
					  u8 mbssid_index, u8 *new_bssid_addr)
					  u8 mbssid_index, u8 *new_bssid)
{
	u64 bssid_tmp, new_bssid;
	u64 lsb_n;
	u64 bssid_u64 = ether_addr_to_u64(bssid);
	u64 mask = GENMASK_ULL(max_bssid - 1, 0);
	u64 new_bssid_u64;

	bssid_tmp = ether_addr_to_u64(bssid);
	new_bssid_u64 = bssid_u64 & ~mask;

	lsb_n = bssid_tmp & ((1 << max_bssid) - 1);
	new_bssid = bssid_tmp;
	new_bssid &= ~((1 << max_bssid) - 1);
	new_bssid |= (lsb_n + mbssid_index) % (1 << max_bssid);
	new_bssid_u64 |= ((bssid_u64 & mask) + mbssid_index) & mask;

	u64_to_ether_addr(new_bssid, new_bssid_addr);
	u64_to_ether_addr(new_bssid_u64, new_bssid);
}

/**