Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 298824 - sys-apps/openrc: bridged network setup using wireless (hostapd) not working with recent kernel versions (>=2.6.33)
Summary: sys-apps/openrc: bridged network setup using wireless (hostapd) not working w...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Bjarke Istrup Pedersen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 295613
  Show dependency tree
 
Reported: 2009-12-29 04:46 UTC by Dominik D. Geyer
Modified: 2010-05-11 16:02 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik D. Geyer 2009-12-29 04:46:58 UTC
With newer kernels (>=2.6.33) there seems to be a problem with the stable baselayout regarding setting up a bridged network (e.g. eth0 + wlan0) using the nl80211 driver + hostapd.

The recent kernel commit ad4bb6f8883a13bb0f65b194dae36c62a02ac779 disallows adding unsupported devices to a bridge (which is perfectly fine from the kernel POV). So the wlan0 interface first needs to be setup by hostapd - which itself depends on an already setup bridge. So the current situation is that I'm not able to add the "uninitialized" wlan0 to the bridge and at the same time I'm not able to "initialize" wlan0 with hostapd _before_ the bridge is created.

chicken or the egg:
- hostapd needs br0 to work properly  (note: it doesn't complain if br0 doesn't exist)
- br0 needs _properly setup_ wlan0 (by hostapd)

Reproducible: Always

Steps to Reproduce:
1. Use kernel >= 2.6.33 and have a proper /etc/conf.d/net setup for bridged network with a wireless interface (using nl80211 driver and hostapd as the AP) which worked fine with at least vanilla kernel 2.6.32-rc8.
2. Start the system and follow the init-messages. When bridge init-script /etc/init.d/net.br0 wants to add the wlan0 interface, it says "Operation not supported" (which comes from kernel commit ad4bb6f8883a13bb0f65b194dae36c62a02ac779).

Actual Results:  
The bridge isn't setup and network not working.

Note: Starting hostapd _before_ the bridge is setup isn't a solution, as the hostapd relies on br0 and won't work properly (here).

Expected Results:  
Add support for bridged hostapd setups in baselayout so that
1) the bridge is just created (no interfaces/ports added)
2) services which rely on the bridge are started (hostapd)
3) Ports/Interfaces are added to the bridge finally

This is an example procedure to "manually" get it working again:
1) ifconfig eth0 up
2) ifconfig wlan0 up     # not needed, because hostapd sets it up anyway
3) brctl addbr br0
4) /etc/init.d/hostapd start
5) brctl addif eth0
6) brctl addif wlan0
7) /etc/init.d/dnsmasq start     # and other services...

# uname -a
Linux homeserver 2.6.33-rc2-homeserver #1 Mon Dec 28 07:04:59 CET 2009 i686 VIA Nehemiah CentaurHauls GNU/Linux

##########################################################################

# lspci -v -s 0:14.0
00:14.0 Network controller: Atheros Communications Inc. Device 0029 (rev 01)
	Subsystem: D-Link System Inc Device 3a78
	Flags: bus master, 66MHz, medium devsel, latency 168, IRQ 17
	Memory at f6000000 (32-bit, non-prefetchable) [size=64K]
	Capabilities: [44] Power Management version 2
	Kernel driver in use: ath9k
	Kernel modules: ath9k

##########################################################################

# emerge --info
Portage 2.1.7.16 (unavailable, gcc-4.3.4, glibc-2.9_p20081201-r2, 2.6.33-rc2-homeserver i686)
=================================================================
System uname: Linux-2.6.33-rc2-homeserver-i686-VIA_Nehemiah-with-gentoo-1.12.13
Timestamp of tree: Unknown
dev-lang/python:     2.6.4
sys-devel/autoconf:  2.63-r1
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.27-r2
ACCEPT_LICENSE="* -@EULA"
CFLAGS="-O2 -march=c3-2 -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -march=c3-2 -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo.ynet.sk/pub http://mirror.switch.ch/ftp/mirror/gentoo/ http://files.gentoo.org http://ftp.romnet.org/gentoo/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/ http://mirror.switch.ch/ftp/mirror/gentoo/"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acpi alsa bash-completion" 
Unset:  ACCEPT_KEYWORDS, EMERGE_DEFAULT_OPTS

##########################################################################

# brctl --version
bridge-utils, 1.2

##########################################################################

# hostapd -v    
hostapd v0.6.9

##########################################################################

# rc-update show | grep net          # eth0, wlan0 and hostapd are started by deps
             net.br0 |      default                  
            net.eth1 |      default                  
              net.lo | boot                          
            net.ppp0 |      default                  
            netmount |      default

##########################################################################

Snippet of my /etc/hostapd/hostapd.conf:
  ...
  interface=wlan0
  bridge=br0
  driver=nl80211
  ...

##########################################################################

To work around this problem, I manually created the desired bridge (with no ports added) before starting
hostapd, but in /lib/rcscripts/net/bridge.sh:135 in function bridge_pre_start() destroys the bridge if it exists. So I commented this line out. It's a very dirty hack... but works for the moment.


The following is my "work-around" /etc/conf.d/net:

config_eth0=( "null" )     # is my LAN
config_eth1=( "null" )     # is the pppoe NIC

RC_NEED_ppp0="net.eth1"
config_ppp0=( "ppp" )
link_ppp0="eth1"
plugins_ppp0=( "pppoe" )
username_ppp0="********@augustakom.net"
pppd_ppp0=(
        "persist"
        "defaultroute"
        "usepeerdns"
        "mru 1492"
        "mtu 1492"
        "holdoff 60"
)

# ugly: dummy config... will be setup by hostapd correctly later
config_wlan0=( "null" )
channel_wlan0="5"
essid_wlan0="dominik"
mode_wlan0="master"


bridge_br0="eth0 wlan0"
config_br0=( "192.168.0.1/24" )

depend_br0() {
       need net.eth0 hostapd
}

# dirty hack: create bridge before starting wlan0/hostapd
preup() {
        if [ "${IFACE}" == "wlan0" ] ; then
                einfo "hack: create bridge before starting wlan0/hostapd"
                /sbin/brctl addbr br0
                /sbin/brctl show >>/tmp/debug

                # IMPORTANT:
                # hacked /lib/rcscripts/net/bridge.sh:135:
                # do not remove the freshly created bridge
        fi
}
Comment 1 William Hubbs gentoo-dev 2010-02-03 22:20:05 UTC
Our focus is on stabilizing baselayout-2/openrc, so I do not see us fixing this in baselayout-1.

Please upgrade  to baselayout-2 and openrc and let us know if this is still an issue.  If it is, we will address it there.

Thanks,

William
Comment 2 Ben Schweikert 2010-02-25 17:16:29 UTC
(In reply to comment #1)
> Our focus is on stabilizing baselayout-2/openrc, so I do not see us fixing this
> in baselayout-1.
> 
> Please upgrade  to baselayout-2 and openrc and let us know if this is still an
> issue.  If it is, we will address it there.
> 
> Thanks,
> 
> William
> 

same here with baselayout 2 and openrc..
Comment 3 William Hubbs gentoo-dev 2010-02-25 17:52:03 UTC
Roy,

can you take a look at fixing this in openrc?

Thanks,

William
Comment 4 Roy Marples 2010-02-25 19:23:49 UTC
As the OP said, it's a bit chicken and egg. I don't see an easy way of fixing it. Patches welcome :)
Comment 5 Ben Schweikert 2010-02-26 08:09:40 UTC
(In reply to comment #4)
> As the OP said, it's a bit chicken and egg. I don't see an easy way of fixing
> it. Patches welcome :)
> 

My workaround is to remove the mentioned commit with patch -p0 -R < "commit"
not good, but it is working..
Comment 6 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2010-02-27 00:19:54 UTC
Has this been reported to the linux wireless mailinglist?

They made the patch, so they must have some ideas on how to fix it.
Comment 7 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2010-03-01 23:05:45 UTC
Well, I have some info.

The problem is, that from now on, it is no longer possible to add a wireless interface that hasen't been configured to a bridge (which is what that patch does).

Upstream says, that the correct way to do it, is in exclude the wireless interface from the bridge, use >=hostapd-0.7.1, and let hostapd add the wireless interface to the bridge after it has configured it.

So, to recap, the procedure for fixing is:

1: Remove the wlanX interface from the bridge in /etc/conf.d/net
2: Use hostapd-0.7.1 or above.
3: Make sure you are using the nl80211 driver in hostapd.conf
4: Make sure you have set the bridge=br0 setting in hostapd.conf (might not be needed, since it has autodetecting, but it doesn't hurt).

Could somebody else please try this too, and see if it works for them too? (It does in my setup).

Use the "brctl show" command to verify the wireless interface is missing before hostapd is started, and use it again after hostapd is started to verify it has been added.

I'm taking over this bug for how, since it seems the solution is to be found in hostapd, not openrc.
Comment 8 Marek Bartosiewicz 2010-04-22 19:23:56 UTC
(In reply to comment #7)

> So, to recap, the procedure for fixing is:
> 
> 1: Remove the wlanX interface from the bridge in /etc/conf.d/net
> 2: Use hostapd-0.7.1 or above.
> 3: Make sure you are using the nl80211 driver in hostapd.conf
> 4: Make sure you have set the bridge=br0 setting in hostapd.conf (might not be
> needed, since it has autodetecting, but it doesn't hurt).
> 
> Could somebody else please try this too, and see if it works for them too? (It
> does in my setup).

It also works-for-me :) .33 kernel, hostapd 0.7.1 and ath9k wifi card.
Comment 9 Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2010-04-22 19:41:01 UTC
Okay, I'm closing the bug as fixed then.

If people want to use the bleeding edge kernel, they also have to use the bleeding edge hostapd :-)