Bug#427724: should add interface to bridge when launching via /etc/network/interfaces

2007-06-05 Thread Elmar Hoffmann
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-base3.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.netagainst HTML email   X
  `-& vCards  / \
--- /etc/hostapd/ifupdown.sh.dpkg-dist	2007-06-06 00:34:48.0 +0200
+++ /etc/hostapd/ifupdown.sh	2007-06-06 03:37:16.0 +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\""


signature.asc
Description: Digital signature


Bug#427713: Bug#427724: should add interface to bridge when launching via /etc/network/interfaces

2007-07-24 Thread Faidon Liambotis

package hostapd
retitle 427713 hook script should get moved to 000madwifi
reassign 427713 madwifi-tools
thanks


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.

Dynamic interfaces are a problem since they're generated *after* the
bridge is created, so the above won't work.

There is currently an issue that some madwifi interfaces don't exist
before the execution of their hook script and other hook scripts
(bridge-utils, hostapd) are executed before madwifi's hook script.

You're suggesting on #427713 that we should move hostapd to zz-hostapd,
as a sysvinit-style workaround for the lack of dependencies in ifupdown
hooks.

The same should apply to bridge-utils, which would solve #427724, don't
you think?

FWIW, I don't.
I think that the proper workaround would be to rename madwifi to
000madwifi, since that's where the problem lies.

Best regards,
Faidon



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]