From owner-freebsd-net@FreeBSD.ORG Tue Feb 24 02:15:07 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 6C1FF16A4CE for ; Tue, 24 Feb 2004 02:15:07 -0800 (PST) Received: from mailtoaster1.pipeline.ch (mailtoaster1.pipeline.ch [62.48.0.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B42243D1F for ; Tue, 24 Feb 2004 02:15:06 -0800 (PST) (envelope-from andre@freebsd.org) Received: (qmail 35268 invoked from network); 24 Feb 2004 10:15:05 -0000 Received: from unknown (HELO freebsd.org) ([62.48.0.54]) (envelope-sender ) by mailtoaster1.pipeline.ch (qmail-ldap-1.03) with SMTP for ; 24 Feb 2004 10:15:05 -0000 Message-ID: <403B2423.DABF2E48@freebsd.org> Date: Tue, 24 Feb 2004 11:14:59 +0100 From: Andre Oppermann X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Gleb Smirnoff References: <20040224080353.GA76272@cell.sick.ru> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 10:15:07 -0000 Gleb Smirnoff wrote: > > Dear sirs, > > please take a look at the following problem. I've been > successfully using the following code on STABLE and 5.1-RELEASE: > > struct route ro; > struct sockaddr_in *sin; > > bzero((caddr_t)&ro, sizeof(ro)); > sin = (struct sockaddr_in *)&ro.ro_dst; > sin->sin_len = sizeof(*sin); > sin->sin_family = AF_INET; > sin->sin_addr = fle->r.r_dst; > rtalloc(&ro); Most of the time, if you don't need a cloned route allocated, you can just use rtalloc_ign(&ro, RTF_CLONING) to just get a reference to the existing rtentry. Not allocating a new cloned route saves work and time for the rtalloc code. > if (ro.ro_rt != NULL) { > struct rtentry *rt = ro.ro_rt; > > /* here some read-only things are done with rt */ Maybe you do some nasty things to rt here? > rtfree(ro.ro_rt); > } > > But on CURRENT rtfree() causes panic. Here is backtrace: ... > Does this mean that something is broken in CURRENT or I am doing something wrong? rtalloc() and rtfree() are used quite often in the network code and otherwise work fine. The odds are high that you are doing something wrong. -- Andre