defrouter_addreq calling RTFREE?
prabhakar lakhera
prabhakar.lakhera at gmail.com
Fri Jul 20 01:02:08 UTC 2012
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 at 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’s 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 = rtrequest(RTM_ADD, (struct sockaddr *)&def,
> (struct sockaddr *)&gate, (struct sockaddr *)&mask,
> RTF_GATEWAY, &newrt);
> ================> Since we provide &newrt the reference would be
> incremented to 1?
> if (newrt) {
> nd6_rtmsg(RTM_ADD, newrt); /* tell user process */
> RTFREE(newrt);
> ================> When we call 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 <= 1) \
> rtfree(_rt); \
> ================> rtfree will be called since ref
> else { \
> RT_REMREF(_rt); \
> RT_UNLOCK(_rt); \
> } \
> /* guard against invalid refs */ \
> _rt = 0; \
> } while (0)
>
>
> Shouldn't the count be just decremented calling RT_REMREF(rt); like in
> rtinit?
>
> Best,
>
> Prabhakar
>
>
>
>
More information about the freebsd-net
mailing list