Subject: Re: Question about the call to rtflushclone when adding routes
To: Greg Troxel <gdt@ir.bbn.com>
From: Frederick Lefebvre <frederick.lefebvre@hexago.com>
List: tech-net
Date: 03/07/2005 15:08:05
--On Monday, March 07, 2005 12:35:46 -0500 Greg Troxel <gdt@ir.bbn.com> 
wrote:

>   My understanding is that the function 'rtflushclone'  is used to
>   delete any entry in the routing table that were cloned from the
>   'rtentry' received in arguments.  Is that right?
>   If so, why is 'rtfluchclone' called in rtrequest1 when a new route is
>   added?  How could that new route already have clones?
>
> My view is that in all cases of caching routing information, the
> correct behavior is to behave the same way (just faster) as if there
> were no caching.  A cloned route serves two purposes: a) it stores the
> mac address and b) it is a cache entry which hits on ipaddr/32 and
> points to an interface.  This second purpose is really a cache.
> Consider a route 10.1.0.0/16 on an interface.  Then consider adding
> 10.1.2.0/24 on a second interface.  Had there been any arp in entries
> in the second prefix on the first interface, it would be incorrect for
> them to remain.   So when adding a route, all cloned routes which lie
> within the new prefix must be removed.
>
> Yes, it's twisted to have setups like this.  But still cache
> consistency shouldn't be an issue.
>
> --
>         Greg Troxel <gdt@ir.bbn.com>

Thank's Greg!  But I still do not understand.  I know what clone routes are 
used for but I'm mainly interrested in the following lines of code that can 
be found at the end of 'rtrequest1' when req = RTM_ADD or RTM_RESOLVE:

if ((rt->rt_flags & RTF_CLONING) != 0) {
	/* clean up any cloned children */
	rtflushclone(rnh, rt);
}

'rtflushclone' then calls 'rn_walktree' which will then call 
'rtflushclone1' for each route in the routing table.  And 'rtflushclone1' 
will delete any rtentry that has a rt_parent pointing to the route just 
created by 'rtrequest1'.
So...my question is/are:
How can there exist any pointers to a rtentry structure that we have just 
created?
Is it possible that this code is just there to catch orphan cloned routes 
that would have be en left hanging around from a previous delete of an 
route using the same memory address?


Frederick Lefebvre
--
System and Network administrator
Hexago Inc. / Viagenie
(418)266-5533 #226
------------------------------------------------
http://www.freenet6.net : Free IPv6 Connectivity
------------------------------------------------