From owner-freebsd-arch@FreeBSD.ORG Tue Nov 12 19:54:57 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E17AF462; Tue, 12 Nov 2013 19:54:57 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1682F213F; Tue, 12 Nov 2013 19:54:57 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 11F4BB918; Tue, 12 Nov 2013 14:54:56 -0500 (EST) From: John Baldwin To: Hiroki Sato Subject: Re: service netif restart [iface] runs a wpa_supplicant twice Date: Tue, 12 Nov 2013 13:54:03 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20130906; KDE/4.5.5; amd64; ; ) References: <1383419596.3253.42.camel@eva02.mbsd> <201311051154.18872.jhb@freebsd.org> <20131112.134742.1669584178551946391.hrs@allbsd.org> In-Reply-To: <20131112.134742.1669584178551946391.hrs@allbsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201311121354.03923.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 12 Nov 2013 14:54:56 -0500 (EST) Cc: clutton@zoho.com, adrian@freebsd.org, freebsd-wireless@freebsd.org, freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2013 19:54:58 -0000 On Monday, November 11, 2013 11:47:42 pm Hiroki Sato wrote: > John Baldwin wrote > in <201311051154.18872.jhb@freebsd.org>: > > jh> I also tested vlans created via vlans_ and they should use the same fix as > jh> well. Note that this model is more consistent with how cloned_interfaces > jh> works where ifn_start is not explicitly run when each interface is created. > jh> Instead, we rely on devd kicking off pccard_ether for those as well. > > No, for cloned_interfaces, the ifn_start will be kicked even when > devd is unavailable because rc.d/netif calls clone_up() and then > ifn_start() sequentially. Since an IFNET ATTACH event is generated > upon clone_up(), so actually the ifn_start() runs twice on every boot > time (or rc.d/netif restart ifn). Yes, I missed this earlier. > Since childif_*() is invoked at the end of ifn_*(), configuration of > the child interfaces does not happen. This is the reason why there > was ifn_start() in childif_create(). Well, the child interfaces are not listed in list_network_interfaces. That explicitly adds cloned_interfaces to the list. > It is not efficient and it is reasonable to leave ifn_start() to devd > if available, but it is difficult to detect it correctly because the > IFNET ATTACH handler may be disabled in devd.conf. "pgrep devd" is > not reliable enough. Agreed that it is not perfect, and I don't really like it. However, I assumed that people who leave devd enabled but disable the IFNET ATTACH handler must already know enough about what they are doing to fix this on their own. :) I think there are two common use cases that we should make work out of the box: 1) People who use devd with a stock devd.conf. 2) People who don't use devd at all. I'm not sure we need to support the case of people hacking up a custom devd.conf directly in the base system. > As pointed out, this duplication can be a problem when configuration > is performed by a program because multiple instances of the program > are invoked. In the other cases, there is no problem because > ifn_start() is idempotent, though. Yes. One thought I had was to just fix /etc/rc.d/wpa_supplicant so that it was idempotent. If wpa_supplicant is the only one that really needs fixing I would favor that fix as the simplest one. > For inconsistency childif_*(), what do you think about integrating > vlans_IF and wlans_IF into cloned_interfaces and removing the > childif_*() stage in ifn_*()? We can keep vlans_IF and wlans_IF as > well as introduce a new syntax into cloned_interfaces like > > cloned_interfaces="em0.100 em0.110 em0.myvlan ath0.wlan0" > > which is equivalent to > > vlans_em0="100 110 myvlan" > wlans_ath0="wlan0" > > The rc.d/netif does clone_up() for the child interfaces first and > then does ifn_start() for them, so > > # service netif restart wlan0 > > works as expected (tear down, recreate, and reconfigure the > interface). cloned_interfaces already supports vlans (em0.100, etc.). The problems I had when we used that were: 1) if_vlan was not implicitly loaded, so we always cloned a vlan999 dummy device to load it 2) If we stopped an interface (typically on kldunload of the base driver), the vlan interfaces were orphaned. They stayed around, but with no parent. If a newer version of the driver was loaded via kldload, the vlan interfaces were not recreated. With vlans_IF, the right thing happens if you do 'stop foo0' and 'start foo0'. In particular if you do a 'stop foo0' before you kldunload foo, then all of foo0's subinterfaces are created and configured when you kldload foo. > Of course, this does not solve the duplicate invocation of the netif > script. To solve it, I think we need a knob to disable IFNET events > in a per-interface basis temporarily. Eh, I thought about doing some hackish thing to do that, but it seemed even more fragile and gross than the 'pgrep devd' hack. In particular, you could do this in /etc/rc.d/devd: devd_precmd() { touch /tmp/disable_netif } devd_postcmd() { rm /tmp/disable_netif } rc.conf: devd_flags="-n" And have /etc/pccard_ether bail if /tmp/disable_netif exists. This would let devd drain through all the queued up events at boot ignoring any IFNET ATTACH events by having pccard_ether bail. -- John Baldwin