On Sat, Feb 09, 2019 at 09:08:20AM +0100, Johannes Berg wrote:
> but maybe the whole thing is more readable as
>
> static inline void cfg80211_gen_new_bssid(const u8 *bssid_addr, u8 max_bssid,
> u8 mbssid_index, u8 *new_bssid_addr)
> {
> u64 bssid = ether_addr_to_u64(bssid_addr);
> u64 mask = GENMASK_ULL(max_bssid - 1, 0);
> u64 new_bssid;
>
> new_bssid &= bssid & ~mask;
That should be "=" not "&="..
> new_bssid |= ((bssid & mask) + mbssid_index) & mask;
>
> u64_to_ether_addr(new_bssid, new_bssid_addr);
> }
but other than that, this version looks much nicer than the other
alternatives.
> However, isn't it true that 0 <= mbssid_index < max_bssid? Then the
> whole masking isn't really needed at all?
0 <= mbssid_index < 2^max_bssid. The transmitted BSSID (i.e., that
bssid_addr argument) is not required to be the first BSSID in the range,
so the masking is needed to cover wraparound for addition modulo
2^mbssid_index when max_bssid LSBs of bssid are not zeros.
--
Jouni Malinen PGP id EFC895FA