From owner-freebsd-net@FreeBSD.ORG Fri Jul 20 01:02:08 2012 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 4DDD5106566C for ; Fri, 20 Jul 2012 01:02:08 +0000 (UTC) (envelope-from prabhakar.lakhera@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id BDDC28FC14 for ; Fri, 20 Jul 2012 01:02:07 +0000 (UTC) Received: by lbon10 with SMTP id n10so5472221lbo.13 for ; Thu, 19 Jul 2012 18:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=h97YnohDV8vuDLA0yrt9GQ4ZuJuFZ/aaEQsrgk9qX+c=; b=HkmPJ+8cTzJP9SGTRTdlSAMsFyxRMdeIwzgeII01axZ9oI+lSH65wV+V9hB+bkvM2s Man8xCfz7mVaoAAlkOoaC8tQrraZt1m6GkOf/mvyU/46Prsgrao3pH4P2Mc0ncB/9aEX UXLGs+SoYfTEmq04aenItnJMrB1h+JOt8JQPnW5kRzUvi6/4RRF5WgGsiYOApsOo74k3 JNeW95ud2IB2TVsZE5LmfTzKywFi646vHg4oz4smI2+qG4h1Tpx4V70qE+oWEGpOrYWr GftpocMlyzduOeEVA2heS6gh5peWgpYnqEIOmK+Op9jsQj6tTXeZo/3A802tDrCc8YI8 4XRw== MIME-Version: 1.0 Received: by 10.112.86.105 with SMTP id o9mr2087186lbz.32.1342746126714; Thu, 19 Jul 2012 18:02:06 -0700 (PDT) Received: by 10.114.23.170 with HTTP; Thu, 19 Jul 2012 18:02:06 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Jul 2012 18:02:06 -0700 Message-ID: From: prabhakar lakhera To: freebsd-net@freebsd.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: defrouter_addreq calling RTFREE? 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: Fri, 20 Jul 2012 01:02:08 -0000 I see that it changed from 7 to 8. However doesn't specify why. Have some semantics changed? On Thu, Jul 19, 2012 at 5:59 PM, prabhakar lakhera < prabhakar.lakhera@gmail.com> wrote: > Hi, > > It could very well be that my brain wires are not working late in the day= . > From what I know most of the routing table entries (unless referenced by > some other entity or another route in routing table) have reference count > 0. At least that's how things used to be in BSD as also stated in TCP IP > illustrated: > > *Routing Table Reference Counts* > *The handling of the routing table reference count, rt_refcnt, differs > from most other reference * > *counts. We see in Figure 18.2 that most routes have a reference count of > 0, yet the routing table entries * > *without any references are not deleted. We just saw the reason in > rtfree: an entry with a * > *reference count of 0 is not deleted unless the entry=92s RTF_UP flag is > not set. The only time this flag * > *is cleared is by rtrequest when a route is deleted from the routing > tree. * > > I fail to understand why defrouter_addreq in nd6_rtr.c calls RTFREE: > > error =3D rtrequest(RTM_ADD, (struct sockaddr *)&def, > (struct sockaddr *)&gate, (struct sockaddr *)&mask, > RTF_GATEWAY, &newrt); > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> Since we provide &= newrt the reference would be > incremented to 1? > if (newrt) { > nd6_rtmsg(RTM_ADD, newrt); /* tell user process */ > RTFREE(newrt); > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> When we ca= ll RTFREE the reference is 1? > } > > Now RTFREE has been defined as: > > #define RTFREE(_rt) do { \ > RT_LOCK(_rt); \ > RTFREE_LOCKED(_rt); \ > } while (0) > > and RTFREE_LOCKED is defined as: > > #define RTFREE_LOCKED(_rt) do { \ > if ((_rt)->rt_refcnt <=3D 1) \ > rtfree(_rt); \ > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D> r= tfree will be called since ref > else { \ > RT_REMREF(_rt); \ > RT_UNLOCK(_rt); \ > } \ > /* guard against invalid refs */ \ > _rt =3D 0; \ > } while (0) > > > Shouldn't the count be just decremented calling RT_REMREF(rt); like in > rtinit? > > Best, > > Prabhakar > > > >