From owner-freebsd-net@FreeBSD.ORG Tue Apr 8 07:40:08 2008 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 07F031065679 for ; Tue, 8 Apr 2008 07:40:08 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mail.cksoft.de (mail.cksoft.de [62.111.66.27]) by mx1.freebsd.org (Postfix) with ESMTP id B6D9A8FC1A for ; Tue, 8 Apr 2008 07:40:07 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from localhost (amavis.str.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id 22B1141C7A3; Tue, 8 Apr 2008 09:40:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([62.111.66.27]) by localhost (amavis.str.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id evxRHCslE2Yl; Tue, 8 Apr 2008 09:40:05 +0200 (CEST) Received: by mail.cksoft.de (Postfix, from userid 66) id C4BDE41C799; Tue, 8 Apr 2008 09:40:05 +0200 (CEST) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id 5F2394448DD; Tue, 8 Apr 2008 07:38:51 +0000 (UTC) Date: Tue, 8 Apr 2008 07:38:51 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: blue In-Reply-To: <47FAECE5.1070008@zyxel.com.tw> Message-ID: <20080408073822.Q66744@maildrop.int.zabbadoz.net> References: <47FAECE5.1070008@zyxel.com.tw> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org Subject: Re: [ipsec] KEY_FREESAV() in FreeBSD-Release7.0 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, 08 Apr 2008 07:40:08 -0000 On Tue, 8 Apr 2008, blue wrote: Hi, > Dear all: > > About the KEY_FREESAV() in key_checkrequest() in key.c: > > line 806: > if (isr->sav != NULL) { > KEY_FREESAV(&isr->sav); > isr->sav = NULL; > } > > The codes are only going to free the sav used LAST TIME. For outgoing SA > entries, the reference count will be always 2, instead of 1 like incoming SA. > I thought the proper place to call KEY_FREESAV() should be > ipsec6_output_trans() and ipsec6_output_tunnel() after invoking each > transform's output function. Then the SA will be freed after its usage rather > than being freed if there's next IPsec packet. > > If the above condition is accpeted, then key_delsp() in key.c should not call > KEY_FREESAV() in case SA reference count underflow! Can you please file a PR for this as well? Thanks -- Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT Software is harder than hardware so better get it right the first time.