From owner-freebsd-net Thu Jul 22 23:29:20 1999 Delivered-To: freebsd-net@freebsd.org Received: from mc-qout4.whowhere.com (mc-qout4.whowhere.com [209.185.123.18]) by hub.freebsd.org (Postfix) with SMTP id DC5F314F8F for ; Thu, 22 Jul 1999 23:29:17 -0700 (PDT) (envelope-from utterchaos@angelfire.com) Received: from Unknown/Local ([?.?.?.?]) by angelfire.com; Thu Jul 22 23:20:38 1999 To: freebsd-net@freebsd.org Date: Thu, 22 Jul 1999 23:20:38 -0700 From: "Shantanu R Kothavale" Message-ID: Mime-Version: 1.0 Cc: X-Sent-Mail: on Reply-To: X-Mailer: MailCity Service Subject: Question about radix trie & ether_output() X-Sender-Ip: 207.135.89.228 Organization: Angelfire (http://email.angelfire.com:80) Content-Type: text/plain; charset=us-ascii Content-Length: 2403 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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