From owner-freebsd-net Tue Jun 5 10:41:58 2001 Delivered-To: freebsd-net@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 530DC37B437 for ; Tue, 5 Jun 2001 10:41:48 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f55HfLj49388; Tue, 5 Jun 2001 20:41:21 +0300 (EEST) (envelope-from ru) Date: Tue, 5 Jun 2001 20:41:21 +0300 From: Ruslan Ermilov To: Garrett Wollman Cc: Jesper Skriver , freebsd-net@FreeBSD.ORG Subject: Re: leaking route structures, please review Message-ID: <20010605204121.A49067@sunbay.com> Mail-Followup-To: Garrett Wollman , Jesper Skriver , freebsd-net@FreeBSD.ORG References: <20010605145104.A68594@skriver.dk> <200106051513.LAA87829@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200106051513.LAA87829@khavrinen.lcs.mit.edu>; from wollman@khavrinen.lcs.mit.edu on Tue, Jun 05, 2001 at 11:13:27AM -0400 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Tue, Jun 05, 2001 at 11:13:27AM -0400, Garrett Wollman wrote: > < said: > > > Since rt was the cached route of the pcb, the ref count is >= 1 > > since the pcb will have a ref count on it. In the case of a dynamic > > route, in_losing calls rtrequest to delete the route but not rtfree. > > rtrequest() only deletes the route from the routing table. It does > > not free the route structure unless rt_refcnt is 0. > > This is correct. We can't have it rip the route out from under any > number of PCBs and other routes which may have it referenced. > > > We know it won't be zero because the pcb has a ref count. As a > > result it appears that we leak a route structure since it will never > > be freed. > > No, the next time that route structure is used, the lack of an RTF_UP > flag on the route will be noted, and the reference will be dropped > before rtalloc() is called to find the new correct route. If you want > the references to be dropped sooner, either send more traffic or close > your connections more frequently. > Hmm, and what happens if the PCB is the only holder of this route? The refcnt will be 1 in this case, and the code drops the reference by setting inp->inp_route.ro_rt = 0. How this route can be reused (and deleted) later? Also, while I was playing with this, I noticed some strange things I don't understand, and would like a tip on. Why, when I add the `default' route, the rttrash variable increases? Who calls the rtfree() in this case? And why this is different from where I add the route to say `-net 10'? Note the difference: Script started on Tue Jun 5 20:38:47 2001 perl# netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 127.0.0.1 127.0.0.1 UH 1 6 lo0 192.168.4 link#1 UC 2 0 rl0 => perl# route add -net 10 192.168.4.65 add net 10: gateway 192.168.4.65 perl# netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 10 192.168.4.65 UGSc 0 0 rl0 127.0.0.1 127.0.0.1 UH 1 6 lo0 192.168.4 link#1 UC 3 0 rl0 => 192.168.4.65 link#1 UHLW 1 0 rl0 => Script done on Tue Jun 5 20:39:10 2001 Script started on Tue Jun 5 20:39:28 2001 perl# netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 127.0.0.1 127.0.0.1 UH 1 6 lo0 192.168.4 link#1 UC 2 0 rl0 => perl# route add default 192.168.4.65 add net default: gateway 192.168.4.65 perl# netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.4.65 UGSc 0 0 rl0 127.0.0.1 127.0.0.1 UH 1 6 lo0 192.168.4 link#1 UC 3 0 rl0 => Script done on Tue Jun 5 20:39:40 2001 Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message