From owner-svn-src-all@FreeBSD.ORG Thu Nov 12 14:48:36 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEA6A106568F; Thu, 12 Nov 2009 14:48:36 +0000 (UTC) (envelope-from ume@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DDAC88FC0A; Thu, 12 Nov 2009 14:48:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nACEmact033444; Thu, 12 Nov 2009 14:48:36 GMT (envelope-from ume@svn.freebsd.org) Received: (from ume@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nACEma08033442; Thu, 12 Nov 2009 14:48:36 GMT (envelope-from ume@svn.freebsd.org) Message-Id: <200911121448.nACEma08033442@svn.freebsd.org> From: Hajimu UMEMOTO Date: Thu, 12 Nov 2009 14:48:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199225 - head/sys/netinet6 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2009 14:48:37 -0000 Author: ume Date: Thu Nov 12 14:48:36 2009 New Revision: 199225 URL: http://svn.freebsd.org/changeset/base/199225 Log: - We are not guaranteed that we're not dropping a reference that we did not add. Call LLE_REMREF() only when callout_stop() actually canceled a pending callout. - callout_reset() may cancel a pending callout. When callout_reset() canceled a pending callout, call LLE_REMREF() to drop a reference for the canceled callout. MFC after: 1 week Modified: head/sys/netinet6/nd6.c Modified: head/sys/netinet6/nd6.c ============================================================================== --- head/sys/netinet6/nd6.c Thu Nov 12 14:27:09 2009 (r199224) +++ head/sys/netinet6/nd6.c Thu Nov 12 14:48:36 2009 (r199225) @@ -439,31 +439,27 @@ skip1: void nd6_llinfo_settimer_locked(struct llentry *ln, long tick) { + int canceled; + if (tick < 0) { ln->la_expire = 0; ln->ln_ntick = 0; - callout_stop(&ln->ln_timer_ch); - /* - * XXX - do we know that there is - * callout installed? i.e. are we - * guaranteed that we're not dropping - * a reference that we did not add? - * KMM - */ - LLE_REMREF(ln); + canceled = callout_stop(&ln->ln_timer_ch); } else { ln->la_expire = time_second + tick / hz; LLE_ADDREF(ln); if (tick > INT_MAX) { ln->ln_ntick = tick - INT_MAX; - callout_reset(&ln->ln_timer_ch, INT_MAX, + canceled = callout_reset(&ln->ln_timer_ch, INT_MAX, nd6_llinfo_timer, ln); } else { ln->ln_ntick = 0; - callout_reset(&ln->ln_timer_ch, tick, + canceled = callout_reset(&ln->ln_timer_ch, tick, nd6_llinfo_timer, ln); } } + if (canceled) + LLE_REMREF(ln); } void @@ -1048,6 +1044,9 @@ nd6_free(struct llentry *ln, int gc) else nd6_llinfo_settimer(ln, (long)V_nd6_gctimer * hz); splx(s); + LLE_WLOCK(ln); + LLE_REMREF(ln); + LLE_WUNLOCK(ln); return (LIST_NEXT(ln, lle_next)); }