From owner-freebsd-net@FreeBSD.ORG Tue Jan 4 09:09:24 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38D5B1065670; Tue, 4 Jan 2011 09:09:24 +0000 (UTC) (envelope-from egrosbein@rdtc.ru) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [62.231.161.221]) by mx1.freebsd.org (Postfix) with ESMTP id 952AF8FC08; Tue, 4 Jan 2011 09:09:23 +0000 (UTC) Received: from eg.sd.rdtc.ru (localhost [127.0.0.1]) by eg.sd.rdtc.ru (8.14.4/8.14.4) with ESMTP id p0499KUq085544; Tue, 4 Jan 2011 15:09:20 +0600 (NOVT) (envelope-from egrosbein@rdtc.ru) Message-ID: <4D22E3BB.4050703@rdtc.ru> Date: Tue, 04 Jan 2011 15:09:15 +0600 From: Eugene Grosbein User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; ru-RU; rv:1.9.1.10) Gecko/20100712 Thunderbird/3.0.5 MIME-Version: 1.0 To: bschmidt@freebsd.org References: <4D22D578.8080903@rdtc.ru> <201101041006.06065.bschmidt@freebsd.org> In-Reply-To: <201101041006.06065.bschmidt@freebsd.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org, bug-followup@freebsd.org Subject: Re: kern/153594: [iwn] Network keeps disconnecting when /etc/rc.d/netif restart is run X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2011 09:09:24 -0000 On 04.01.2011 15:06, Bernhard Schmidt wrote: >> Perhaps, wrapping wpa_supplicant invocation into "lockf -t0" would help >> to eliminate race? > > Possibly, but I don't think this is the way to go. > > Currently wpa_supplicant has this code: > /* > * Mark the interface as down to ensure wpa_supplicant has exclusive > * access to the net80211 state machine, do this before opening the > * route socket to avoid a false event that the interface disappeared. > */ > if (getifflags(drv, &flags) == 0) > (void) setifflags(drv, flags &~ IFF_UP); > > This code works such that it will send an event to already running > wpa_supplicant instances which will then terminate. This does indeed work if > there's enough delay between invocations, though, if there is just a small > delay (~100ms or something), that event doesn't get passed probably. I think > we should start looking into possible solution at that point, trying to figure > out why the the event doesn't get passed (probably because the interface is > not yet up at that point) will get us closer to proper solution. Proper fine-grained locking was always good solution for race problem :-) How about using flock(2) in wpa_supplicant source code? Eugene Grosbein