From fdef8b73c4208d97c2d799bde3dd837a871e9666 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 29 Nov 2010 17:15:27 -0800 Subject: Automatically configure physical device for wireless interfaces When system is booted with newly detected wireless device, both the hw-id and physical-device need to be setup. --- scripts/system/vyatta_interface_rescan | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'scripts') diff --git a/scripts/system/vyatta_interface_rescan b/scripts/system/vyatta_interface_rescan index a33f8ee9..e93bbdfc 100755 --- a/scripts/system/vyatta_interface_rescan +++ b/scripts/system/vyatta_interface_rescan @@ -84,6 +84,18 @@ sub get_hwid { return $hwaddr; } +# Determine phy for wlan device +# (This is ugly) +sub get_phy { + my $wlan = shift; + my $phypath = "/sys/class/net/$wlan/phy80211"; + + # link should be: ../../ieee80211/phy0 + return unless (readlink($phypath) =~ m!../../ieee80211/(phy[0-9]+)$!); + + return $1; +} + # vyatta_net_name leaves files in /dev/.udev/vyatta # the filename is the interface and the contents are the hardware id sub interface_rescan { @@ -112,6 +124,13 @@ sub interface_rescan { syslog(LOG_INFO, "add config for %s hw-id %s", $ifname, $hwaddr); $xcp->create_node(['interfaces',$ifpath,"hw-id $hwaddr"]); + + # Add existing phy entry for wireless + if ($ifname =~ /^wlan/) { + my $phy = get_phy($ifname); + $xcp->create_node(['interfaces',$ifpath,"physical-device $phy"]) if $phy; + } + } # Rewrite new config file -- cgit v1.2.3