RFC: supporting multiple hostap instances in /etc/rc.conf

Maciej Milewski milu at dat.pl
Tue Apr 19 10:44:33 UTC 2011


Dnia niedziela, 17 kwietnia 2011 o 16:05:58 Bernhard Schmidt napisał(a):
> On Sunday 17 April 2011 15:25:55 Adrian Chadd wrote:
> > On 17 April 2011 15:09, Bernhard Schmidt <bschmidt at freebsd.org> wrote:
> > > Given that hostapd needs to be started with a configuration file as an
> > > argument and not an interface like wpa_supplicant you need to add a way
> > > to add multiple configuration files. The conf_file variable is
> > > currently hard-coded to /etc/hostapd.conf, if you add another one like
> > > hostapd_conf_files="" and iterate over it, that should do the trick.
> > > 
> > > But I'm not sure how to handle the pidfile, or how to name it..
> > 
> > > I was thinking of say:
> > hostapd_instances="a b c"
> > hostapd_a_conf="/etc/hostapd.wlan0.conf"
> > hostapd_a_flags="-B -p /var/run/hostapd.wlan0.pid"
> > hostapd_a_cmd="/usr/sbin/hostapd"
> > 
> > hostapd_b_conf="/etc/hostapd.wlan1.conf"
> > hostapd_b_flags="-B -p /var/run/hostapd.wlan1.pid"
> > hostapd_b_cmd="/usr/sbin/hostapd"
> > 
> > It's not terribly automagic, but it'll work well enough to run multiple
> > hostapds.
> > 
> > How's that sound?
> 
> Way to complex for my taste :)
> 
> How about
> 
> hostapd_enable="YES"
> hostapd_interfaces="wlan0 wlan1 .." # defaults to empty
> 
> and then
> 
> if [ -n $hostapd_interfaces ]; then
> 	for interface in $interface; do
> 		pidfile=/var/run/hostapd/$interface.pid
> 		conffile=/etc/hostapd-$interface.conf
> 		..
> 	done
> else
> 	pidfile=/var/run/hostapd.pid
> 	conffile=/etc/hostapd.conf
> fi

One simpler thing for quick running multiple instaces is giving multiple 
configs to the hostapd. Hostapd supports it from around 2005. This would run 
one instance of hostapd listening on all interfaces given in config files.

Manual way:
/usr/sbin/hostapd -P /var/run/hostapd.pid -B /etc/hostapd.conf 
/etc/hostapd2.conf /etc/hostapd3.conf

Attached patch doesn't change default behaviour and adding multiple configs 
into rc.conf:
hostapd_conf="/etc/hostapd.conf /etc/hostapd2.conf /etc/hostapd3.conf"
makes it work with more interfaces.

More elegant would be one instance for every interface but restarting only one 
interface would be done by hand or by additional logic in the rc-script.

Maciej Milewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hostapd-one-instance-multi-config.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-wireless/attachments/20110419/db93ebf2/hostapd-one-instance-multi-config.bin


More information about the freebsd-wireless mailing list