Date: Thu, 19 Jul 2012 18:02:06 -0700 From: prabhakar lakhera <prabhakar.lakhera@gmail.com> To: freebsd-net@freebsd.org Subject: Re: defrouter_addreq calling RTFREE? Message-ID: <CALg%2BrhXJ-uE4BtUiBspfUKi243dGQYY6Vq%2ByGmuEda28numoiw@mail.gmail.com> In-Reply-To: <CALg%2BrhXhe7WShYJtKUtk3Eh8eGWqj-vnoxyB5O4woMtnnFbkLA@mail.gmail.com> References: <CALg%2BrhXhe7WShYJtKUtk3Eh8eGWqj-vnoxyB5O4woMtnnFbkLA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > > > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALg%2BrhXJ-uE4BtUiBspfUKi243dGQYY6Vq%2ByGmuEda28numoiw>