Add support for bridging iwn(4) based wlan(4)

Documented in iwn(4), "Only one virtual interface may be configured at any
time." However, netgraph with a cloned MAC address is able to communicate
over an ng_eiface attached to an ng_bridge linked to the wlan(4) interface.
While here, introduce syntax to specify the MAC address is to be cloned if
the named interface begins with equals [=].
This commit is contained in:
Devin Teske 2016-02-11 22:10:54 +00:00
parent 5e4bc63b7c
commit b35d45aadf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295548

View File

@ -265,7 +265,7 @@ mustberoot_to_continue()
fi
}
jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME interface0 [interface1 ...]"
jng_bridge_usage="bridge [-b BRIDGE_NAME] NAME [=]iface0 [[=]iface1 ...]"
jng_bridge_descr="Create ng0_NAME [ng1_NAME ...]"
jng_bridge()
{
@ -286,10 +286,15 @@ jng_bridge()
mustberoot_to_continue
local iface eiface eiface_devid
local new num quad i=0
local iface parent eiface eiface_devid
local new clone_mac num quad i=0
for iface in $*; do
clone_mac=
case "$iface" in
=*) iface=${iface#=} clone_mac=1 ;;
esac
# 0. Make sure the interface doesn't exist already
eiface=ng${i}_$name
ngctl msg "$eiface:" getifname > /dev/null 2>&1 && continue
@ -347,7 +352,23 @@ jng_bridge()
# 6. Set the MAC address of the new interface using a sensible
# algorithm to prevent conflicts on the network.
#
derive_mac $iface "$name" eiface_devid
case "$iface" in
wlan[0-9]*)
parent=$( sysctl -n net.wlan.${iface#wlan}.%parent )
case "$parent" in
iwn[0-9]*)
# iwn(4) supports only 1 virtual net at a time
# NB: Cloning MAC allows new interface to work
clone_mac=1 ;;
esac
esac
if [ "$clone_mac" ]; then
eiface_devid=$(
ifconfig $iface ether | awk '/ether/,$0=$2'
)
else
derive_mac $iface "$name" eiface_devid
fi
ifconfig $eiface ether $eiface_devid
i=$(( $i + 1 )) # on to next ng{i}_name