[SRU][M:meta-laptop][PATCH] UBUNTU: Set persistent wifi MAC address

Juerg Haefliger juerg.haefliger at canonical.com
Fri Oct 27 18:27:29 UTC 2023


BugLink: https://bugs.launchpad.net/2039144

The X13s comes up with a random wifi MAC address, because it's hidden
probably in secret storage that the kernel can't get to (yet). This can
be problematic for some environments and MAC address randomization should
really be handled by NetworkManager. So set a unique and persistent
MAC based on /etc/machine-id.

Signed-off-by: Juerg Haefliger <juerg.haefliger at canonical.com>
---
 rules.d/60-laptop-persistent-wifi-mac.rules |  2 ++
 share/set-wifi-mac-addr                     | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 rules.d/60-laptop-persistent-wifi-mac.rules
 create mode 100755 share/set-wifi-mac-addr

diff --git a/rules.d/60-laptop-persistent-wifi-mac.rules b/rules.d/60-laptop-persistent-wifi-mac.rules
new file mode 100644
index 000000000000..e667f9d13f3a
--- /dev/null
+++ b/rules.d/60-laptop-persistent-wifi-mac.rules
@@ -0,0 +1,2 @@
+# Set wifi MAC on X13s
+SUBSYSTEM=="net", ACTION=="add", ATTRS{vendor}=="0x17cb", ATTRS{device}=="0x1103", PROGRAM="/usr/share/linux-laptop/set-wifi-mac-addr %k"
diff --git a/share/set-wifi-mac-addr b/share/set-wifi-mac-addr
new file mode 100755
index 000000000000..1b56e22e5638
--- /dev/null
+++ b/share/set-wifi-mac-addr
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Set X13s wifi MAC address
+#
+
+intf=${1}
+
+# Bytes 2-4 from /etc/machine-id
+nic=$(sed 's/\(..\)/\1:/g' /etc/machine-id | cut -c 4-11)
+
+# Qualcomm OUI
+oui="8c:fd:f0"
+
+mac="${oui}:${nic}"
+echo "Set MAC addr of ${intf} to ${mac}"
+/bin/ip link set "${intf}" address "${mac}"
-- 
2.39.2




More information about the kernel-team mailing list