From owner-freebsd-net@FreeBSD.ORG Sun Dec 25 00:58:20 2011 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6734106564A; Sun, 25 Dec 2011 00:58:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8B4568FC19; Sun, 25 Dec 2011 00:58:20 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 2950146B32; Sat, 24 Dec 2011 19:58:20 -0500 (EST) Received: from John-Baldwins-MacBook-Air.local (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 98FEEB944; Sat, 24 Dec 2011 19:58:19 -0500 (EST) Message-ID: <4EF6752C.4040109@FreeBSD.org> Date: Sat, 24 Dec 2011 19:58:20 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Sergey Kandaurov References: <201112231446.38057.jhb@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Sat, 24 Dec 2011 19:58:19 -0500 (EST) Cc: Bjoern Zeeb , net@freebsd.org Subject: Re: [PATCH] Minor fixes to netinet6/icmp6.c 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: Sun, 25 Dec 2011 00:58:20 -0000 On 12/23/11 6:38 PM, Sergey Kandaurov wrote: > On 23 December 2011 23:46, John Baldwin wrote: >> I found these nits while working on the patches to convert if_addr_mtx to an >> rwlock. The first change is cosmetic, it just un-inlines a TAILQ_FOREACH(). >> The second change is an actual bug. The code is currently reading >> TAILQ_FIRST(&V_ifnet) without holding the appropriate lock. >> >> Index: icmp6.c >> =================================================================== >> --- icmp6.c (revision 228777) >> +++ icmp6.c (working copy) >> @@ -1780,7 +1780,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf >> } >> >> IFNET_RLOCK_NOSLEEP(); >> - for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { >> + TAILQ_FOREACH(ifp,&V_ifnet, if_list) { >> addrsofif = 0; >> IF_ADDR_LOCK(ifp); >> TAILQ_FOREACH(ifa,&ifp->if_addrhead, ifa_link) { > > FWIW, there are much more of them in netinet6. > Some time ago I started to un-expand them to queue(3). > [not unfinished yet..] I went ahead and did a sweep for queue(3) changes in netinet6. I went a bit further and removed things like the ndpr_next hack, etc. This only includes queue(3) changes though, not your other fixes like moving common code out of blocks. I also fixed a few places to use *_EMPTY() instead of checking *_FIRST() against NULL. There should be no functional change. http://www.FreeBSD.org/~jhb/patches/inet6_queue.patch -- John Baldwin