bridgeifupdown: fix script to create a bridge with a wireless interface
The supplicant support for a bridge was not being managed,
then the bridge was failing when the softap was configured
with an encryption. With this change we launch a supplicant
instance with the bridge support after checking that the
/etc/network/interfaces contains the required parameters.
https://jira.digi.com/browse/DEL-4454
Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
(cherry picked from commit 9c5774ed62)
This commit is contained in:
parent
20afd0ab6f
commit
5b252350f1
|
|
@ -1,4 +1,43 @@
|
|||
#!/bin/sh
|
||||
|
||||
VERBOSITY=0
|
||||
|
||||
start_stop_wpa_supplicant() {
|
||||
BRIDGE_WPA_IFACE="${1}"
|
||||
WPA_SUP_BIN="/usr/sbin/wpa_supplicant"
|
||||
WPA_SUP_PNAME="wpa_supplicant"
|
||||
WPA_SUP_PIDFILE="/var/run/wpa_supplicant.${BRIDGE_WPA_IFACE}.pid"
|
||||
WPA_SUP_OPTIONS="-B -P ${WPA_SUP_PIDFILE} -i ${BRIDGE_WPA_IFACE}"
|
||||
|
||||
if [ -z "${IF_BRIDGE_WPA_DRIVER}" ]; then
|
||||
echo "${WPA_SUP_PNAME}: missing bridge_wpa_driver property for bridge interface ${IFACE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${MODE}" in
|
||||
start)
|
||||
if [ "${VERBOSITY}" = "1" ]; then
|
||||
echo "${WPA_SUP_PNAME}: ${WPA_SUP_BIN} ${WPA_SUP_OPTIONS} -c ${IF_BRIDGE_WPA_CONF} -D ${IF_BRIDGE_WPA_DRIVER}"
|
||||
fi
|
||||
|
||||
start-stop-daemon --start --quiet \
|
||||
--name ${WPA_SUP_PNAME} --startas ${WPA_SUP_BIN} --pidfile ${WPA_SUP_PIDFILE} \
|
||||
-- ${WPA_SUP_OPTIONS} -c ${IF_BRIDGE_WPA_CONF} -D ${IF_BRIDGE_WPA_DRIVER} -b ${IFACE}
|
||||
|
||||
# Wait for wireless to be ready
|
||||
sleep 0.5
|
||||
;;
|
||||
stop)
|
||||
if [ "${VERBOSITY}" = "1" ]; then
|
||||
echo "${WPA_SUP_PNAME}: terminating ${WPA_SUP_PNAME} daemon"
|
||||
fi
|
||||
|
||||
start-stop-daemon --stop --quiet \
|
||||
--name ${WPA_SUP_PNAME} --pidfile ${WPA_SUP_PIDFILE}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Execute only if the interface has a bridge_ports property (this characterizes bridge interfaces)
|
||||
case "$IF_BRIDGE_PORTS" in
|
||||
"")
|
||||
|
|
@ -16,16 +55,19 @@ if [ "$MODE" = "start" ] && [ ! -d /sys/class/net/$IFACE ]; then
|
|||
# Create the bridge interface using brctl
|
||||
brctl addbr $IFACE || exit 1
|
||||
|
||||
# Wait for wlan0 to be ready
|
||||
sleep 0.5
|
||||
|
||||
# For all the interfaces in bridge ports, attach to the bridge and remove ip
|
||||
for port in $INTERFACES; do
|
||||
if [ -d "/sys/class/net/${port}/wireless" ] && [ -n "${IF_BRIDGE_WPA_CONF}" ]; then
|
||||
# Launch wpa_supplicant with bridge support
|
||||
start_stop_wpa_supplicant ${port}
|
||||
fi
|
||||
|
||||
# Turn up the interface and include in the bridge
|
||||
brctl addif $IFACE $port && ifconfig $port 0.0.0.0 up
|
||||
done
|
||||
|
||||
# Setup the bridge (only options supported by busybox)
|
||||
[ -n "$IF_BRIDEG_AGEING" ] && brctl setageing $IFACE $IF_BRIDGE_AGEING
|
||||
[ -n "$IF_BRIDGE_AGEING" ] && brctl setageing $IFACE $IF_BRIDGE_AGEING
|
||||
[ -n "$IF_BRIDGE_BRIDGEPRIO" ] && brctl setbridgeprio $IFACE $IF_BRIDGE_BRIDGEPRIO
|
||||
[ -n "$IF_BRIDGE_FD" ] && brctl setfd $IFACE $IF_BRIDGE_FD
|
||||
[ -n "$IF_BRIDGE_HELLO" ] && brctl sethello $IFACE $IF_BRIDGE_HELLO
|
||||
|
|
@ -43,10 +85,14 @@ elif [ "$MODE" = "stop" ]; then
|
|||
|
||||
# Remove port interfaces from the bridge
|
||||
for port in $INTERFACES; do
|
||||
if [ -d "/sys/class/net/${port}/wireless" ] && [ -n "${IF_BRIDGE_WPA_CONF}" ]; then
|
||||
# Stop the wpa_supplicant instance for the bridge
|
||||
start_stop_wpa_supplicant ${port}
|
||||
fi
|
||||
|
||||
ifconfig $port down && brctl delif $IFACE $port
|
||||
done
|
||||
|
||||
# Destroy the interface
|
||||
brctl delbr $IFACE
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
## Example bridge between eth0 and wlan0
|
||||
#auto br0
|
||||
#iface br0 inet static
|
||||
# bridge_ports eth0 wlan0
|
||||
# address 192.168.42.50
|
||||
# netmask 255.255.255.0
|
||||
# bridge_wpa_driver nl80211
|
||||
# bridge_wpa_conf /etc/wpa_supplicant.conf
|
||||
Loading…
Reference in New Issue