From owner-freebsd-net@FreeBSD.ORG Sat Feb 3 00:06:59 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 205B516A402 for ; Sat, 3 Feb 2007 00:06:59 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by mx1.freebsd.org (Postfix) with ESMTP id 9F97C13C47E for ; Sat, 3 Feb 2007 00:05:17 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 7A3A89E6CC for ; Fri, 2 Feb 2007 18:35:52 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by out1.internal (MEProxy); Fri, 02 Feb 2007 18:35:52 -0500 X-Sasl-enc: ps5MBianexi468ilEBVpgVvzzwKDBssFcT/6iifl9U2i 1170459352 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id 1C9252676B for ; Fri, 2 Feb 2007 18:35:52 -0500 (EST) Message-ID: <45C3CAD7.8040704@incunabulum.net> Date: Fri, 02 Feb 2007 23:35:51 +0000 From: Bruce M Simpson User-Agent: Thunderbird 1.5.0.9 (X11/20070125) MIME-Version: 1.0 To: freebsd-net@freebsd.org Content-Type: multipart/mixed; boundary="------------030709000202000402000806" Subject: [PATCH] tun(4) does not clean up after itself 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: Sat, 03 Feb 2007 00:06:59 -0000 This is a multi-part message in MIME format. --------------030709000202000402000806 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I just saw this PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/100080 This patch appears to fix the problem. Any obvious glaring errors? Testers please? Regards, BMS --------------030709000202000402000806 Content-Type: text/x-patch; name="tun-cleanup.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tun-cleanup.diff" Index: if_tun.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_tun.c,v retrieving revision 1.161 diff -u -p -r1.161 if_tun.c --- if_tun.c 6 Nov 2006 13:42:02 -0000 1.161 +++ if_tun.c 2 Feb 2007 23:30:04 -0000 @@ -388,16 +388,21 @@ tunclose(struct cdev *dev, int foo, int splx(s); } + /* Delete all addresses and routes which reference this interface. */ if (ifp->if_drv_flags & IFF_DRV_RUNNING) { struct ifaddr *ifa; s = splimp(); - /* find internet addresses and delete routes */ - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) - if (ifa->ifa_addr->sa_family == AF_INET) - /* Unlocked read. */ + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + /* deal w/IPv4 PtP destination; unlocked read */ + if (ifa->ifa_addr->sa_family == AF_INET) { rtinit(ifa, (int)RTM_DELETE, tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0); + } else { + rtinit(ifa, (int)RTM_DELETE, 0); + } + } + if_purgeaddrs(ifp); ifp->if_drv_flags &= ~IFF_DRV_RUNNING; splx(s); } --------------030709000202000402000806--