From owner-freebsd-net@FreeBSD.ORG Fri Dec 23 20:51:35 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 184AC106567F; Fri, 23 Dec 2011 20:51:35 +0000 (UTC) (envelope-from bz@freebsd.org) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) by mx1.freebsd.org (Postfix) with ESMTP id 9F9318FC1A; Fri, 23 Dec 2011 20:51:34 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id A726C25D3A00; Fri, 23 Dec 2011 20:51:33 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id E4781BD7A2F; Fri, 23 Dec 2011 20:51:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id Y6vj0Xgo5l6b; Fri, 23 Dec 2011 20:51:31 +0000 (UTC) Received: from orange-en1.sbone.de (orange-en1.sbone.de [IPv6:fde9:577b:c1a9:31:cabc:c8ff:fecf:e8e3]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id AD0BFBD7A2D; Fri, 23 Dec 2011 20:51:31 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <201112231446.38057.jhb@freebsd.org> Date: Fri, 23 Dec 2011 20:51:30 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <80A26A17-4524-4CAE-9672-0B760E55908F@freebsd.org> References: <201112231446.38057.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1084) Cc: 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: Fri, 23 Dec 2011 20:51:35 -0000 On 23. Dec 2011, at 19:46 , John Baldwin wrote: > I found these nits while working on the patches to convert if_addr_mtx = to an=20 > rwlock. The first change is cosmetic, it just un-inlines a = TAILQ_FOREACH(). =20 > The second change is an actual bug. The code is currently reading=20 > TAILQ_FIRST(&V_ifnet) without holding the appropriate lock. I think they should be good; may I ask you to fix the locking in one = commit and the "style" foreach one in another? /bz > Index: icmp6.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- icmp6.c (revision 228777) > +++ icmp6.c (working copy) > @@ -1780,7 +1780,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct = mbuf > } >=20 > IFNET_RLOCK_NOSLEEP(); > - for (ifp =3D TAILQ_FIRST(&V_ifnet); ifp; ifp =3D TAILQ_NEXT(ifp, = if_list)) { > + TAILQ_FOREACH(ifp, &V_ifnet, if_list) { > addrsofif =3D 0; > IF_ADDR_LOCK(ifp); > TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { > @@ -1851,7 +1851,7 @@ static int > ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo = *nni6, > struct ifnet *ifp0, int resid) > { > - struct ifnet *ifp =3D ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet); > + struct ifnet *ifp; > struct in6_ifaddr *ifa6; > struct ifaddr *ifa; > struct ifnet *ifp_dep =3D NULL; > @@ -1864,6 +1864,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, = struct > return (0); /* needless to copy */ >=20 > IFNET_RLOCK_NOSLEEP(); > + ifp =3D ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet); > again: >=20 > for (; ifp; ifp =3D TAILQ_NEXT(ifp, if_list)) { >=20 > --=20 > John Baldwin --=20 Bjoern A. Zeeb You have to have visions! Stop bit received. Insert coin for new address family.