Re: [PATCH] wiphy: non-LAA mac randomization
Denis Kenzior <[email protected]>
| Newsgroups | dev.linux.lists.iwd |
|---|---|
| Message-ID | <[email protected]> |
Hi On 3/10/25 5:55 PM, [email protected] wrote: > From: rushiiMachine <[email protected]> > I need a real name / author information in order to accept patches. > Add a secondary option to `AddressRandomizationRange` to not set the > locally-administered bit of `full` randomized MAC addresses. This > allows randomizing MAC addresses to not appear as Locally > Administered Addresses (LAA). Currently, there is no way to avoid > having this bit set other than setting `AddressRandomizationRange` > to `nic`, which undesirably copies the entire OUI and only randomizes > the last 3 octets. > --- > src/iwd.config.rst | 8 ++++++-- > src/wiphy.c | 17 +++++++++++++---- > 2 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/src/iwd.config.rst b/src/iwd.config.rst > index 895a1012..55b95db9 100644 > --- a/src/iwd.config.rst > +++ b/src/iwd.config.rst > @@ -107,7 +107,7 @@ The group ``[General]`` contains general settings. > the permanent address. > > * - AddressRandomizationRange > - - Values: **full**, nic > + - Values: **full**, full-uaa, nic What does uaa mean here? user-administered-address? > > One can control which part of the address is randomized using this > setting. > @@ -119,7 +119,11 @@ The group ``[General]`` contains general settings. > > When using ``AddressRandomizationRange`` set to ``full``, all 6 octets > of the address are randomized. The locally-administered bit will be > - set. > + set, and multicast bit will be cleared. > + > + When using ``AddressRandomizationRange`` set to ``full-uaa``, all 6 > + octets of the address are randomized. The locally-administered and > + multicast bits will be cleared. > > * - RoamThreshold > - Value: rssi dBm value, from -100 to 1, default: **-70** > diff --git a/src/wiphy.c b/src/wiphy.c > index fb544fe6..ccdc7645 100644 > --- a/src/wiphy.c > +++ b/src/wiphy.c > @@ -64,6 +64,7 @@ static struct l_hwdb *hwdb; > static char **whitelist_filter; > static char **blacklist_filter; > static int mac_randomize_bytes = 6; > +static bool mac_set_laa = true; > static char regdom_country[2]; > static uint32_t work_ids; > static unsigned int wiphy_dump_id; > @@ -778,8 +779,11 @@ static void wiphy_address_constrain(struct wiphy *wiphy, uint8_t addr[static 6]) > { > switch (mac_randomize_bytes) { > case 6: > - /* Set the locally administered bit */ > - addr[0] |= 0x2; > + /* Set or clear the locally administered bit */ > + if (mac_set_laa) > + addr[0] |= 0x2; > + else > + addr[0] &= 0xfd; Nit: Prefer L_BIT_SET / L_BIT_CLEAR > > /* Reset multicast bit */ > addr[0] &= 0xfe; > @@ -2854,9 +2858,13 @@ static int wiphy_init(void) > if (s) { > if (!strcmp(s, "nic")) > mac_randomize_bytes = 3; > - else if (!strcmp(s, "full")) > + else if (!strcmp(s, "full")) { > mac_randomize_bytes = 6; > - else > + mac_set_laa = true; > + } else if (!strcmp(s, "full-uaa")) { > + mac_randomize_bytes = 6; > + mac_set_laa = false; > + } else > l_warn("Invalid [General].AddressRandomizationRange" > " value: %s", s); > } > @@ -2884,6 +2892,7 @@ static void wiphy_exit(void) > l_genl_family_free(nl80211); > nl80211 = NULL; > mac_randomize_bytes = 6; > + mac_set_laa = true; > > l_dbus_unregister_interface(dbus_get_bus(), IWD_WIPHY_INTERFACE); > Looks good otherwise. Regards, -Denis