From owner-freebsd-net@FreeBSD.ORG Tue Feb 24 04:34:30 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2EDB16A4CE; Tue, 24 Feb 2004 04:34:30 -0800 (PST) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id EF53543D1D; Tue, 24 Feb 2004 04:34:29 -0800 (PST) (envelope-from glebius@cell.sick.ru) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.9/8.12.8) with ESMTP id i1OCYRQE078523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Feb 2004 15:34:28 +0300 (MSK) (envelope-from glebius@cell.sick.ru) Received: (from glebius@localhost) by cell.sick.ru (8.12.9/8.12.6/Submit) id i1OCYRM9078522; Tue, 24 Feb 2004 15:34:27 +0300 (MSK) Date: Tue, 24 Feb 2004 15:34:27 +0300 From: Gleb Smirnoff To: Andre Oppermann Message-ID: <20040224123427.GA78495@cell.sick.ru> Mail-Followup-To: Gleb Smirnoff , Andre Oppermann , freebsd-net@freebsd.org References: <20040224080353.GA76272@cell.sick.ru> <403B2423.DABF2E48@freebsd.org> <20040224102113.GB77406@cell.sick.ru> <403B4182.F6BD7101@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <403B4182.F6BD7101@freebsd.org> User-Agent: Mutt/1.5.6i cc: freebsd-net@freebsd.org Subject: Re: rtalloc()/rtfree() problems on CURRENT X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 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, 24 Feb 2004 12:34:31 -0000 On Tue, Feb 24, 2004 at 01:20:18PM +0100, Andre Oppermann wrote: A> > Thanks for this hint. So if using rtalloc_ign() I do not need to call rtfree()? A> You still have to call rtfree() to decrement the refcount of the rtentry. Thanks. A> > A> Maybe you do some nasty things to rt here? A> > A> > Really, I don't :) Exact code is given at end of the mail. A> A> You indeed do some nasty things. Please point me at 'em. I'm only reading some values from parent structure. A> > Here is exact code: A> > A> > bzero((caddr_t)&ro, sizeof(ro)); A> > sin = (struct sockaddr_in *)&ro.ro_dst; A> > sin->sin_len = sizeof(*sin); A> > sin->sin_family = AF_INET; A> > sin->sin_addr = fle->r.r_dst; A> > rtalloc(&ro); A> > if (ro.ro_rt != NULL) { A> > struct rtentry *rt = ro.ro_rt; A> > A> > /* This is cloned route, use its parent */ A> > if (ro.ro_rt->rt_flags & RTF_WASCLONED && A> > ro.ro_rt->rt_parent) A> > rt = ro.ro_rt->rt_parent; A> A> With rtalloc() you get a cloned route essentially every time. Use A> rtalloc_ign(&ro, RTF_CLONING) to get the parent route directly. A> A> > fle->o_ifx = rt->rt_ifp->if_index; A> > A> > if (rt->rt_flags & RTF_GATEWAY && A> > rt->rt_gateway->sa_family == AF_INET) A> > fle->next_hop = A> > ((struct sockaddr_in *)(rt->rt_gateway))->sin_addr; A> > A> > if (rt_mask(rt)) A> > fle->dst_mask = A> > bit_count(((struct sockaddr_in *)rt_mask(rt))->sin_addr.s_addr); A> > else if (rt->rt_flags & RTF_HOST) A> > /* Give up. We can't determine mask :( */ A> > fle->dst_mask = 32; A> > A> > rtfree(ro.ro_rt); A> A> Use the macro RTFREE() instead of rtfree(), it will take care of some A> locking issues. This should be present in manpage, too. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE