Revision acb04cfd nest/route.h

View differences:

nest/route.h
174 174
  ip_addr addr;				/* IP address of host, part of key */
175 175
  ip_addr link;				/* (link-local) IP address of host, used as gw
176 176
					   if host is directly attached */
177
  struct rtable *tab;			/* Dependent table, part of key*/
177
  struct rtable *tab;			/* Dependent table, part of key */
178 178
  struct hostentry *next;		/* Next in hash chain */
179 179
  unsigned hash_key;			/* Hash key */
180 180
  unsigned uc;				/* Use count */
......
507 507
void rta_set_recursive_next_hop(rtable *dep, rta *a, rtable *tab, ip_addr *gw, ip_addr *ll);
508 508

  
509 509
/*
510
 * rta_set_recursive_next_hop() acquires hostentry from hostcache and
511
 * fills rta->hostentry field.  New hostentry has zero use
512
 * count. Cached rta locks its hostentry (increases its use count),
513
 * uncached rta does not lock it. Hostentry with zero use count is
514
 * removed asynchronously during host cache update, therefore it is
515
 * safe to hold such hostentry temorarily. Hostentry holds a lock for
516
 * a 'source' rta, mainly to share multipath nexthops. There is no
517
 * need to hold a lock for hostentry->dep table, because that table
518
 * contains routes responsible for that hostentry, and therefore is
519
 * non-empty if given hostentry has non-zero use count. The protocol
520
 * responsible for routes with recursive next hops should also hold a
521
 * lock for a table governing that routes (argument tab to
522
 * rta_set_recursive_next_hop()).
510
 * rta_set_recursive_next_hop() acquires hostentry from hostcache and fills
511
 * rta->hostentry field.  New hostentry has zero use count. Cached rta locks its
512
 * hostentry (increases its use count), uncached rta does not lock it. Hostentry
513
 * with zero use count is removed asynchronously during host cache update,
514
 * therefore it is safe to hold such hostentry temorarily. Hostentry holds a
515
 * lock for a 'source' rta, mainly to share multipath nexthops.
516
 *
517
 * There is no need to hold a lock for hostentry->dep table, because that table
518
 * contains routes responsible for that hostentry, and therefore is non-empty if
519
 * given hostentry has non-zero use count. If the hostentry has zero use count,
520
 * the entry is removed before dep is referenced.
521
 *
522
 * The protocol responsible for routes with recursive next hops should hold a
523
 * lock for a 'source' table governing that routes (argument tab to
524
 * rta_set_recursive_next_hop()), because its routes reference hostentries
525
 * (through rta) related to the governing table. When all such routes are
526
 * removed, rtas are immediately removed achieving zero uc. Then the 'source'
527
 * table lock could be immediately released, although hostentries may still
528
 * exist - they will be freed together with the 'source' table.
523 529
 */
524 530

  
525 531
static inline void rt_lock_hostentry(struct hostentry *he) { if (he) he->uc++; }

Also available in: Unified diff