Package: hostapd
Version: 1:0.5.7-1
Severity: normal
Tags: patch

When launching hostapd via /etc/network/interfaces using the hostapd
statement in an interface definiton and using bridging with the
madwifi driver of hostapd, ifupdown.sh should add the wireless
interface to the bridge interface.

In case you are not familiar with using hostapd with madwifi, quoting
hostapd.conf:

--8<---

# In case of madwifi driver, an additional configuration parameter, bridge,
# must be used to notify hostapd if the interface is included in a bridge. This
# parameter is not used with Host AP driver.
#bridge=br0

--8<---

Obviously, the whole setup only works, if the wireless interface is
part of the bridge.
In a static configuration where hostapd is launched from
/etc/init.d/hostapd, one can arrange for the bridge to be configured
in /etc/network/interfaces after the wireless interfaces.

In a dynamic setup that launches hostapd via /etc/network/interfaces
and wireless interfaces can be brought up and down any time,
statically configuring the bridge via /etc/network/interfaces is
obviously not possible.

The attached patch fixes this issue.

Removing of the interface from the bridge in post-down is unnecessary,
as the interface is removed automatically when it goes down (which
leads to the situation that it has to be added again each time it is
brought up).

elmar

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i586)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-486
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages hostapd depends on:
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libssl0.9.8                 0.9.8c-4     SSL shared libraries
ii  lsb-base                    3.1-23.1     Linux Standard Base 3.1
init scrip

hostapd recommends no packages.

-- no debconf information

-- 

 .'"`.                                                            /"\
| :' :   Elmar Hoffmann <[EMAIL PROTECTED]>    ASCII Ribbon Campaign  \ /
`. `'    GPG key available via pgp.net        against HTML email   X
  `-                                                    & vCards  / \
--- /etc/hostapd/ifupdown.sh.dpkg-dist	2007-06-06 00:34:48.000000000 +0200
+++ /etc/hostapd/ifupdown.sh	2007-06-06 03:37:16.000000000 +0200
@@ -94,11 +94,25 @@
 	fi
 }
 
+setup_bridge () {
+	if grep -q '^driver=madwifi' "$HOSTAPD_CONF"; then
+		local BRIDGE
+		BRIDGE=$(sed -n -e 's/^bridge=\(br[0-9]\+\).*$/\1/p' "$HOSTAPD_CONF")
+		if [ -n "$BRIDGE" ]; then
+			hostapd_msg verbose "brctl addif $BRIDGE $IFACE"
+			brctl addif $BRIDGE "$IFACE"
+			return "$?"
+		fi
+	fi
+	return 0
+}
+
 case "$MODE" in 
 	start)
 		case "$PHASE" in
 			pre-up)
 				init_hostapd || exit 1
+				setup_bridge || exit 1
 				;;
 			*)
 				hostapd_msg stderr "unknown phase: \"$PHASE\""

Attachment: signature.asc
Description: Digital signature

Reply via email to