From owner-freebsd-wireless@freebsd.org Tue Sep 5 22:00:10 2017 Return-Path: Delivered-To: freebsd-wireless@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A53CE2178A for ; Tue, 5 Sep 2017 22:00:10 +0000 (UTC) (envelope-from Kamil.Choudhury@anserinae.net) Received: from mxe.anserinae.net (mxe.anserinae.net [45.32.7.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B300E74B3D for ; Tue, 5 Sep 2017 22:00:09 +0000 (UTC) (envelope-from Kamil.Choudhury@anserinae.net) From: Kamil Choudhury To: "freebsd-wireless@freebsd.org" Subject: Configure hostapd(8) to manage multiple interfaces Thread-Topic: Configure hostapd(8) to manage multiple interfaces Thread-Index: AdMmkBugDej4lsYIROuP/D4wWl+Maw== Date: Tue, 5 Sep 2017 21:53:35 +0000 Accept-Language: en-US Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 22:00:10 -0000 I've had this change floating around for a while to allow hostapd(8)=20 to manage multiple wireless interfaces using rc.conf...=20 In rc.conf, we specify our wireless interfaces:=20 > hostapd_ifaces=3D"wlan0 wlan1" ...and enable our hostapd as before:=20 > hostapd_enable=3D"YES" Behind the scene, we need to create /etc/hostapd-wlan0.conf and=20 /etc/hostapd-wlan1.conf Here are the diffs:=20 diff --git a/etc/rc.d/hostapd b/etc/rc.d/hostapd index d0c2d88f2ff..43c6cf4e480 100755 --- a/etc/rc.d/hostapd +++ b/etc/rc.d/hostapd @@ -13,15 +13,27 @@ name=3D"hostapd" desc=3D"Authenticator for IEEE 802.11 networks" command=3D"/usr/sbin/${name}" -ifn=3D"$2" -if [ -z "$ifn" ]; then - rcvar=3D"hostapd_enable" - conf_file=3D"/etc/${name}.conf" - pidfile=3D"/var/run/${name}.pid" +load_rc_config ${name} + + +if [ -n "$hostapd_ifaces" ]; then + nl_hostapd_ifaces=3D`(echo $hostapd_ifaces | tr '\s+' '\n')` + for iface in $nl_hostapd_ifaces + do + conf_file=3D"/etc/${name}-${iface}.conf $conf_file" + done + pidfile=3D"/var/run/${name}.pid" else - rcvar=3D - conf_file=3D"/etc/${name}-${ifn}.conf" - pidfile=3D"/var/run/${name}-${ifn}.pid" + ifn=3D"$2" + if [ -z "$ifn" ]; then + rcvar=3D"hostapd_enable" + conf_file=3D"/etc/${name}.conf" + pidfile=3D"/var/run/${name}.pid" + else + rcvar=3D + conf_file=3D"/etc/${name}-${ifn}.conf" + pidfile=3D"/var/run/${name}-${ifn}.pid" + fi fi command_args=3D"-P ${pidfile} -B ${conf_file}" @@ -29,5 +41,4 @@ required_files=3D"${conf_file}" required_modules=3D"wlan_xauth wlan_wep wlan_tkip wlan_ccmp" extra_commands=3D"reload" -load_rc_config ${name} run_rc_command "$1" diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index a03f4de5cb9..7217cbc1f16 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -409,6 +409,10 @@ Set to to start .Xr hostapd 8 at system boot time. +.It Va hostapd_ifaces +.Pq Vt str +Space separated list of interfaces managed by +.Xr hostapd 8 .It Va hostname .Pq Vt str The fully qualified domain name (FQDN) of this host on the network. My shell isn't great, but the above changes do seem to work. Let me know if there is interest in merging this, and if so, what I can do to move=20 the process ahead.=20 Thanks!=20 Kamil