Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 1999 23:20:38 -0700
From:      "Shantanu R Kothavale" <utterchaos@angelfire.com>
To:        freebsd-net@freebsd.org
Subject:   Question about radix trie & ether_output()
Message-ID:  <OCLPDBIJMIOABAAA@angelfire.com>

next in thread | raw e-mail | index | archive | help
Hi freebsd-net-folks,

  I have a question about the freeing of routes in 
if_ethersubr.c: ether_output().  In the following code:

----------------------------------------------------------------------
    rt = rt0;
    if (rt) {
            if ((rt->rt_flags & RTF_UP) == 0) {
                    rt0 = rt = rtalloc1(dst, 1, 0UL);
                    if (rt0)
                            rt->rt_refcnt--;
                    else
                            senderr(EHOSTUNREACH);
            }
            if (rt->rt_flags & RTF_GATEWAY) {
                    if (rt->rt_gwroute == 0)
                            goto lookup;
*****               if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
*****                       rtfree(rt); rt = rt0;
*****               lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1,
                                                      0UL);
                            if ((rt = rt->rt_gwroute) == 0)
                                    senderr(EHOSTUNREACH);
                    }
            }
            /* Code deleted... */
     }
----------------------------------------------------------------------

  The code which frees the gwroute if it is down and rtalloc1()s a new 
gateway route...can rt->gwroute be re-used instead of having to allocate
a new route entry?

  Assuming gwroute points to a next hop route entry, if 
rtrequest(RTM_DELETE) is called to delete the entry but multiple routes 
point  to it, then the route is marked down (RTF_UP is cleared), it is
removed from the trie, but not deallocated.  

  All routes using this nexthop are still pointing to it, so as they 
try to access it, the reference count in the nexthop entry gets 
decremented until, finally, the entry is freed.

  Instead, if the nexthop entry could be fixed up and reused, all the
routes would point to the correct (new) nexthop information, since
their gwroute fields are still pointing to the entry.

  If there is a fatal flaw in this reasoning, please let me know.  
Otherwise, I'm curious to know why the route is freed and reallocated.
Is this to have a clean processing of deleted routes, or is there 
some scenario where it must be left hanging around until the reference
count has gone to zero?

  Thanks in advance,

  utter




Angelfire for your free web-based e-mail. http://www.angelfire.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OCLPDBIJMIOABAAA>