Subject: Re: Question about the call to rtflushclone when adding routes
To: Frederick Lefebvre <frederick.lefebvre@hexago.com>
From: Greg Troxel <gdt@ir.bbn.com>
List: tech-net
Date: 03/08/2005 13:07:35
  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?

It seems there shouldn't be any such pointers.

  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?

It is, but it's also possible that it is incorrect.
If the check were about the cloned route falling in the prefix instead
of the parent pointer, it would make more sense to me.
But I'm not confident I fully understand this.