diff mbox series

[OpenWrt-Devel] hotplug: Allow renaming phy devices.

Message ID mailman.9019.1544743474.2376.openwrt-devel@lists.openwrt.org
State Changes Requested
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] hotplug: Allow renaming phy devices. | expand

Commit Message

Thomas Richard via openwrt-devel Dec. 13, 2018, 11:24 p.m. UTC
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
From: Ben Greear <greearb@candelatech.com>

uci set wireless.@wifi-device[0].phyname=wiphy0

Then reboot and/or re-plug that device, and this will
name the phy wiphy0 instead of phy0, phy1, etc.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 .../kernel/mac80211/files/mac80211.hotplug    | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

John Crispin Dec. 17, 2018, 7:14 a.m. UTC | #1
I'd like to review your patch but it hits the ML as an attachment making 
it impossible. regardless, the subject is misleading, there are lots of 
phy types and i fail to understand why this is required.

     John
Ben Greear Dec. 17, 2018, 3:02 p.m. UTC | #2
On 12/16/2018 11:14 PM, John Crispin wrote:
>
> I'd like to review your patch but it hits the ML as an attachment making it impossible. regardless, the subject is misleading, there are lots of phy types and i fail to understand why this is required.
>
>     John

The attachment was due to us enabling DMARC support on our email system to help decrease spam, but
we can disable that.  I'll resend the patch later today.

The phy type in question is wireless phy devices.  Is just putting 'wireless' in front of it
sufficient to make it more understandable?

The patch is helpful to me because if I remove and replace a USB wireless NIC, or reload another wifi driver,
then by default it will change name, from /kernel/debug/ieee80211/phy1 to phy2, for instance.  My software wants
the names to stay the same to make it easier to have a persistent representation of a 'radio'.

Thanks,
Ben
diff mbox series

Patch

diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug
index b865552661..a394e3195e 100644
--- a/package/kernel/mac80211/files/mac80211.hotplug
+++ b/package/kernel/mac80211/files/mac80211.hotplug
@@ -3,3 +3,35 @@ 
 [ "${ACTION}" = "add" ] && {
 	/sbin/wifi config
 }
+
+
+OPATH=${DEVPATH##/devices/platform/}
+OPATH=${OPATH%%/ieee*}
+
+# For USB, OPATH looks like this at this point in this script:
+# soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
+# But, the uci path has a platform/ prefix on that:
+# platform/soc/soc:usb30@0/11000000.dwc3/xhci-hcd.0.auto/usb1/1-1/1-1:1.0
+OPATH_USB="platform/$OPATH";
+
+# 10 radios is enough for anyone!
+#echo "fix-wifi-mac, OPATH: $OPATH" >> /tmp/foo.txt
+for i in `seq 0 9`;
+  do
+  BUS=`uci get wireless.@wifi-device[$i].path`
+  #echo "fix-wifi-mac, BUS[$i]: $BUS" >> /tmp/foo.txt
+  if [ "$BUS " == "$OPATH " ] || [ "$BUS " == "$OPATH_USB " ]
+      then
+      PHYNAME=${DEVPATH##*ieee80211/}
+      NPHYNAME=`uci get wireless.@wifi-device[$i].phyname`
+      #echo "fix-wifi-mac, PHYNAME[$i]: $PHYNAME  NPHYNAME: $NPHYNAME" >> /tmp/foo.txt;
+      if [ "$NPHYNAME " != " " ]
+          then
+          if [ "$PHYNAME " != "$NPHYNAME " ]
+              then
+	      #echo "fix-wifi-mac, renaming..." >> /tmp/foo.txt;
+              iw $PHYNAME set name $NPHYNAME
+          fi
+      fi
+  fi
+done