From owner-freebsd-net@FreeBSD.ORG Tue Jan 3 21:22:20 2012 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 D4DBC106568A; Tue, 3 Jan 2012 21:22:20 +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 622828FC12; Tue, 3 Jan 2012 21:22:20 +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 6CA3E25D38FF; Tue, 3 Jan 2012 21:22:19 +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 9B223BD8691; Tue, 3 Jan 2012 21:22:18 +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 khae+xitpQct; Tue, 3 Jan 2012 21:22:17 +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 53B6DBD8690; Tue, 3 Jan 2012 21:22:17 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: "Bjoern A. Zeeb" In-Reply-To: <20111229225539.GD12721@FreeBSD.org> Date: Tue, 3 Jan 2012 21:22:16 +0000 Content-Transfer-Encoding: 7bit Message-Id: <1AA3AF93-E622-4B3F-B882-9F0439364A91@FreeBSD.org> References: <201112221130.01823.jhb@freebsd.org> <201112291527.26763.jhb@freebsd.org> <20111229225539.GD12721@FreeBSD.org> To: Gleb Smirnoff X-Mailer: Apple Mail (2.1084) Cc: freebsd-net@FreeBSD.org, Robert Watson , John Baldwin Subject: Re: Transitioning if_addr_lock to an rwlock 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, 03 Jan 2012 21:22:20 -0000 On 29. Dec 2011, at 22:55 , Gleb Smirnoff wrote: > 3) I've found that in6_ifawithifp() doesn't do what it is supposed > to, as well as uses incorrect locking during this. As last resort > it should run through global list of addresses, not run throgh the > ifp one again. Patch attached. the first half of the patch is simple style which either goes on its own or not at all please. I think the second half of the patch is wrong. Mislead by either the KAME rev 1.1 comment or the locking. The locking sneaked in at http://svnweb.freebsd.org/base?view=revision&revision=194971 and I am not sure why reading it now. I guess an oversight by both Robert and I. The difference between the first and 2nd loop is the scope check and it's an "withifp" function, meaning we want an address of that interface and if you look at the highly expensive part in ip6_output() where we call it we expect the address to be on the given interface or to not be returned. So I'd say fix the locking and be done (and don't do the besta -> ia) change. If we want to optimize all this we might ponder to cache the first non-scope matching address and the 1st non-scope matching deprecated address and return that saving the 2nd loop. However not sure if the 2nd loop or the ifa_ref()s would be more expensive... Also wonder that for Apple... http://fxr.watson.org/fxr/source/bsd/netinet6/in6.c?v=xnu-1699.24.8#L3042 /bz -- Bjoern A. Zeeb You have to have visions! It does not matter how good you are. It matters what good you do!