* [PATCH] wiphy: non-LAA mac randomization
@ 2025-03-10 22:55 rushiimachine
2025-03-11 18:39 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: rushiimachine @ 2025-03-10 22:55 UTC (permalink / raw)
To: iwd; +Cc: rushiiMachine
From: rushiiMachine <rushiimachine@proton.me>
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
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;
/* 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);
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] wiphy: non-LAA mac randomization
2025-03-10 22:55 [PATCH] wiphy: non-LAA mac randomization rushiimachine
@ 2025-03-11 18:39 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2025-03-11 18:39 UTC (permalink / raw)
To: rushiimachine, iwd
Hi
On 3/10/25 5:55 PM, rushiimachine@proton.me wrote:
> From: rushiiMachine <rushiimachine@proton.me>
>
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-11 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 22:55 [PATCH] wiphy: non-LAA mac randomization rushiimachine
2025-03-11 18:39 ` Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox