xorp

NextHopCache< A > Class Template Reference

A cache of next hop information. More...

#include <next_hop_resolver.hh>

List of all members.

Classes

struct  NextHopEntry

Public Member Functions

void add_entry (A addr, A nexthop, int prefix_len, int real_prefix_len, bool resolvable, uint32_t metric=0)
 Add an entry to our next hop table.
bool validate_entry (A addr, A nexthop, int prefix_len, int real_prefix_len)
 Validate an entry.
map< A, int > change_entry (A addr, int prefix_len, uint32_t metric)
 Change an entry in the next hop table.
map< A, int > delete_entry (A addr, int prefix_len)
 Delete an entry from the nexthop table.
bool lookup_by_addr (A addr, int prefix_len, bool &resolvable, uint32_t &metric) const
 Lookup by base address.
bool lookup_by_nexthop (A nexthop, bool &resolvable, uint32_t &metric) const
 Lookup next hop.
bool lookup_by_nexthop_without_entry (A nexthop, bool &resolvable, uint32_t &metric) const
 Lookup next hop without entry.
bool register_nexthop (A nexthop, int ref_cnt_incr=1)
bool deregister_nexthop (A nexthop, bool &last, A &addr, uint32_t &prefix_len)

Private Types

typedef set< NextHopEntry * > RealPrefixEntry
typedef
RefTriePostOrderIterator< A,
RealPrefixEntry > 
RealPrefixIterator
typedef NextHopEntry PrefixEntry
typedef
RefTriePostOrderIterator< A,
PrefixEntry * > 
PrefixIterator

Private Member Functions

PrefixEntryrpe_to_pe (const RealPrefixEntry &pe, A addr, int real_prefix_len) const
 Given a real prefix_len entry return a prefix_len entry.
PrefixEntryrpe_to_pe_delete (RealPrefixEntry &pe, A addr, int real_prefix_len)
 Given a real prefix_len entry return a prefix_len entry.

Private Attributes

RefTrie< A, PrefixEntry * > _next_hop_by_prefix
 The NextHopEntry is indexed in two ways either by prefix_len or by real_prefix_len.
RefTrie< A, RealPrefixEntry > _next_hop_by_real_prefix

Detailed Description

template<class A>
class NextHopCache< A >

A cache of next hop information.

BGP requires information regarding resolvabilty and metrics for next hops. This information is known by the RIB. Questions are asked of the RIB and the results are cached here. The RIB notes that questions have been asked and if the state of a next hop changes then this is reported back to BGP. In order to save space the RIB does not record information about each next hop but returns an address/prefix_len range for which the answer is valid.

Not only can the RIB report changes but can also report that a previous entry is totally invalid. In the case that an entry is invalid all the next hops need to be re-requested.


Member Function Documentation

template<class A>
void NextHopCache< A >::add_entry ( addr,
nexthop,
int  prefix_len,
int  real_prefix_len,
bool  resolvable,
uint32_t  metric = 0 
)

Add an entry to our next hop table.

Parameters:
addrBase address.
nexthopNext hop that is being added to the trie.
prefix_lenThe prefix_len that is masked with the nexhop.
real_prefix_lenThe actual prefix_len that this next hop resolves too. This is only used to match with upcalls from the RIB.
resolvableIs this route resolvable.
metricIf this route is resolvable its metric.
template<class A>
map< A, int > NextHopCache< A >::change_entry ( addr,
int  prefix_len,
uint32_t  metric 
)

Change an entry in the next hop table.

Parameters:
addrThe base address.
prefix_lenThe prefix_len that this next hop resolves too. This is only used to match with upcalls from the RIB.
metricIf this route is resolvable its metric.
Returns:
The map of next hops with reference counts that were covered by this entry.
template<class A>
map< A, int > NextHopCache< A >::delete_entry ( addr,
int  prefix_len 
)

Delete an entry from the nexthop table.

It is a fatal error to attempt to delete an entry that doesn't exist.

Parameters:
addrBase address that is being removed from the trie.
prefix_lenThe prefix_len.
Returns:
The map of next hops with reference counts that were covered by this entry.
template<class A>
bool NextHopCache< A >::lookup_by_addr ( addr,
int  prefix_len,
bool &  resolvable,
uint32_t &  metric 
) const

Lookup by base address.

Parameters:
addrBase address.
prefix_lenThe prefix length.
resolvableIs this route resolvable.
metricIf this route is resolvable the metric of this route.
Returns:
True if this next hop is found.
template<class A>
bool NextHopCache< A >::lookup_by_nexthop ( nexthop,
bool &  resolvable,
uint32_t &  metric 
) const

Lookup next hop.

Parameters:
nexthopNext hop.
resolvableIs this route resolvable.
metricIf this route is resolvable the metric of this route.
Returns:
True if this next hop is found.
template<class A>
bool NextHopCache< A >::lookup_by_nexthop_without_entry ( nexthop,
bool &  resolvable,
uint32_t &  metric 
) const

Lookup next hop without entry.

This lookup does not require that next hop is already known. That is the next hop is not in _nexthop_references.

Parameters:
nexthopNext hop.
resolvableIs this route resolvable.
metricIf this route is resolvable the metric of this route.
Returns:
True if this next hop is found.
template<class A>
NextHopCache< A >::PrefixEntry * NextHopCache< A >::rpe_to_pe ( const RealPrefixEntry &  pe,
addr,
int  real_prefix_len 
) const [private]

Given a real prefix_len entry return a prefix_len entry.

Parameters:
peA real prefix_len entry.
addrAddress.
real_prefix_lenThe real prefix_len.
Returns:
A prefix_len entry if found 0 otherwise.
template<class A>
NextHopCache< A >::PrefixEntry * NextHopCache< A >::rpe_to_pe_delete ( RealPrefixEntry &  pe,
addr,
int  real_prefix_len 
) [private]

Given a real prefix_len entry return a prefix_len entry.

Parameters:
peA real prefix_len entry.
addrAddress.
real_prefix_lenThe real prefix_len.
Returns:
A prefix_len entry if found 0 otherwise.
template<class A>
bool NextHopCache< A >::validate_entry ( addr,
nexthop,
int  prefix_len,
int  real_prefix_len 
)

Validate an entry.

add_entry creates an entry with no nexthop references. The assumption is that a register_nexthop will follow shortly after initial creation. It is possible due to a deregister_nexthop coming in while we are waiting for a response from the RIB that the register_nexthop never happens. This method checks that the specified entry is referenced and if it isn't it is deleted.

Parameters:
addrBase address.
nexthopNext hop that is being added to the trie.
prefix_lenThe prefix_len that is masked with the nexhop.
real_prefix_lenThe actual prefix_len that this next hop
Returns:
true if the entry is in use.

Member Data Documentation

template<class A>
RefTrie<A, PrefixEntry *> NextHopCache< A >::_next_hop_by_prefix [private]

The NextHopEntry is indexed in two ways either by prefix_len or by real_prefix_len.

Both of these data structures need to be kept in sync.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations