From owner-svn-src-all@FreeBSD.ORG Fri Jun 26 13:37:54 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 8795A1065672; Fri, 26 Jun 2009 13:37:54 +0000 (UTC) (envelope-from vanhu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1A4E8FC1A; Fri, 26 Jun 2009 13:37:53 +0000 (UTC) (envelope-from vanhu@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5QDbrJH088087; Fri, 26 Jun 2009 13:37:53 GMT (envelope-from vanhu@svn.freebsd.org) Received: (from vanhu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5QDbr7k088085; Fri, 26 Jun 2009 13:37:53 GMT (envelope-from vanhu@svn.freebsd.org) Message-Id: <200906261337.n5QDbr7k088085@svn.freebsd.org> From: VANHULLEBUS Yvan Date: Fri, 26 Jun 2009 13:37:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195053 - in stable/7/sys: . contrib/pf netipsec 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: Fri, 26 Jun 2009 13:37:55 -0000 Author: vanhu Date: Fri Jun 26 13:37:53 2009 New Revision: 195053 URL: http://svn.freebsd.org/changeset/base/195053 Log: MFC: Only decrease refcnt once when flushing SPD entries, to avoid flushing entries which are still used. Obtained from: NETASQ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netipsec/key.c Modified: stable/7/sys/netipsec/key.c ============================================================================== --- stable/7/sys/netipsec/key.c Fri Jun 26 11:58:15 2009 (r195052) +++ stable/7/sys/netipsec/key.c Fri Jun 26 13:37:53 2009 (r195053) @@ -4057,10 +4057,21 @@ restart: if (sp->scangen == gen) /* previously handled */ continue; sp->scangen = gen; - if (sp->state == IPSEC_SPSTATE_DEAD) { - /* NB: clean entries created by key_spdflush */ + if (sp->state == IPSEC_SPSTATE_DEAD && + sp->refcnt == 1) { + /* + * Ensure that we only decrease refcnt once, + * when we're the last consumer. + * Directly call SP_DELREF/key_delsp instead + * of KEY_FREESP to avoid unlocking/relocking + * SPTREE_LOCK before key_delsp: may refcnt + * be increased again during that time ? + * NB: also clean entries created by + * key_spdflush + */ + SP_DELREF(sp); + key_delsp(sp); SPTREE_UNLOCK(); - KEY_FREESP(&sp); goto restart; } if (sp->lifetime == 0 && sp->validtime == 0) @@ -4070,7 +4081,6 @@ restart: sp->state = IPSEC_SPSTATE_DEAD; SPTREE_UNLOCK(); key_spdexpire(sp); - KEY_FREESP(&sp); goto restart; } }