From owner-svn-src-all@FreeBSD.ORG Wed May 27 09:31:50 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 77966106566B; Wed, 27 May 2009 09:31:50 +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 657438FC13; Wed, 27 May 2009 09:31:50 +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 n4R9Vo4S089804; Wed, 27 May 2009 09:31:50 GMT (envelope-from vanhu@svn.freebsd.org) Received: (from vanhu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4R9VoG2089803; Wed, 27 May 2009 09:31:50 GMT (envelope-from vanhu@svn.freebsd.org) Message-Id: <200905270931.n4R9VoG2089803@svn.freebsd.org> From: VANHULLEBUS Yvan Date: Wed, 27 May 2009 09:31:50 +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: r192880 - head/sys/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: Wed, 27 May 2009 09:31:50 -0000 Author: vanhu Date: Wed May 27 09:31:50 2009 New Revision: 192880 URL: http://svn.freebsd.org/changeset/base/192880 Log: Only decrease refcnt once when flushing SPD entries, to avoid flushing entries which are still used. Approved by: gnn(mentor) Obtained from: NETASQ MFC after: 1 month Modified: head/sys/netipsec/key.c Modified: head/sys/netipsec/key.c ============================================================================== --- head/sys/netipsec/key.c Wed May 27 07:30:32 2009 (r192879) +++ head/sys/netipsec/key.c Wed May 27 09:31:50 2009 (r192880) @@ -4103,10 +4103,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) @@ -4116,7 +4127,6 @@ restart: sp->state = IPSEC_SPSTATE_DEAD; SPTREE_UNLOCK(); key_spdexpire(sp); - KEY_FREESP(&sp); goto restart; } }