xorp

DeletionTable< A > Class Template Reference

DeletionTable is a temporary BGPRouteTable used to delete routes when a peer goes down. More...

#include <route_table_deletion.hh>

Inheritance diagram for DeletionTable< A >:
RouteTable< A > BGPRouteTable< A > CrashDumper

List of all members.

Public Member Functions

 DeletionTable (string tablename, Safi safi, BgpTrie< A > *route_table, const PeerHandler *peer, uint32_t genid, BGPRouteTable< A > *parent)
int add_route (InternalMessage< A > &rtmsg, BGPRouteTable< A > *caller)
int replace_route (InternalMessage< A > &old_rtmsg, InternalMessage< A > &new_rtmsg, BGPRouteTable< A > *caller)
int delete_route (InternalMessage< A > &rtmsg, BGPRouteTable< A > *caller)
int route_dump (InternalMessage< A > &rtmsg, BGPRouteTable< A > *caller, const PeerHandler *dump_peer)
int push (BGPRouteTable< A > *caller)
const SubnetRoute< A > * lookup_route (const IPNet< A > &net, uint32_t &genid, FPAListRef &pa_list) const
void route_used (const SubnetRoute< A > *route, bool in_use)
RouteTableType type () const
string str () const
void output_state (bool, BGPRouteTable< A > *)
bool get_next_message (BGPRouteTable< A > *)
void initiate_background_deletion ()
uint32_t genid () const
string dump_state () const
 DeletionTable (const string &tablename, RouteTable< A > *parent, Trie< A, const IPRouteEntry< A > * > *ip_route_trie, EventLoop &eventloop)
 DeletionTable constructor.
 ~DeletionTable ()
 DeletionTable destructor.
int add_route (const IPRouteEntry< A > &route, RouteTable< A > *caller)
 Add a route.
int delete_route (const IPRouteEntry< A > *route, RouteTable< A > *caller)
 Delete a route.
void delete_all_routes ()
 Delete all the routes that are in this DeletionTable.
const IPRouteEntry< A > * lookup_route (const IPNet< A > &net) const
 Lookup a specific subnet to see if it is in this DeletionTable or the upstream tables.
const IPRouteEntry< A > * lookup_route (const A &addr) const
 Lookup an IP address to get the most specific (longest prefix length) route in the DeletionTable or the upstream tables that matches this address.
RouteRange< A > * lookup_route_range (const A &addr) const
 Lookup an IP addressto get the most specific (longest prefix length) route in the union of the DeletionTable and the upstream tables that matches this address, along with the RouteRange information for this address and route.
void background_deletion_pass ()
 Delete a route, and reschedule background_deletion_pass again on a zero-second timer until all the routes have been deleted.
void unplumb_self ()
 Remove ourself from the plumbing and delete ourself.
TableType type () const
void replumb (RouteTable< A > *old_parent, RouteTable< A > *new_parent)
 Change the parent of this route table.
string str () const
 Render the DeletionTable as a string for debugging purposes.
RouteTable< A > * parent ()

Private Member Functions

void unplumb_self ()
bool delete_next_chain ()
EventLoopeventloop () const

Private Attributes

const PeerHandler_peer
uint32_t _genid
BgpTrie< A > * _route_table
BgpTrie< A >
::PathmapType::const_iterator 
_del_sweep
int _deleted
int _chains
XorpTask _deletion_task
RouteTable< A > * _parent
EventLoop_eventloop
Trie< A, const IPRouteEntry< A > * > * _ip_route_table
XorpTimer _background_deletion_timer

Detailed Description

template<class A>
class DeletionTable< A >

DeletionTable is a temporary BGPRouteTable used to delete routes when a peer goes down.

RouteTable that performs background deletion of routes when a routing protocol goes down leaving routes in the RIB.

When a peer goes down, all the routes stored in a RibIn need to be deleted. However, this can take some time, so it cannot occur in one atomic operation, so it must be done route-by-route as a background task. This is complicated by the fact that the peering may come back up while this background deletion is occuring, and new routes may appear. To handle the background deletion while keeping the RibIn simple, we simply create a new DeletionTable route table, plumb it in directly after the RibIn, and pass the RibIn's entire route trie to the DeletionTable. RibIn can now forget these routes ever existed, and DeletionTable can get on with the background deletion task, unplumbing and deleting itself when no routes remain.

Care must be taken to ensure that the downstream routing tables see consistent information. For example, if there is a route for subnet X in the DeletionTable that has not yet been deleted, and an add_route for X comes downstream from rthe RibIn, then this would need to be propagated downstream as a replace_route.

Note that if a peering flaps multiple times, multiple DeletionTables may be plumbed in, one after another, behind a RibInTable.

Its template class, A, must be either the IPv4 class of the IPv6 class.


Constructor & Destructor Documentation

template<class A >
DeletionTable< A >::DeletionTable ( const string &  tablename,
RouteTable< A > *  parent,
Trie< A, const IPRouteEntry< A > * > *  ip_route_trie,
EventLoop eventloop 
)

DeletionTable constructor.

Parameters:
tablenameused for debugging.
parentUpstream routing table (usually an origin table).
ip_route_triethe entire route trie from the OriginTable that contains routes we're going to delete (as a background task).

Member Function Documentation

template<class A >
int DeletionTable< A >::add_route ( const IPRouteEntry< A > &  route,
RouteTable< A > *  caller 
) [virtual]

Add a route.

If the route was stored in the DeletionTable, we'll remove it and propagate the delete and add downstream.

Parameters:
routethe route entry to be added.
callerthe caller route table.
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements RouteTable< A >.

template<class A >
void DeletionTable< A >::delete_all_routes ( )

Delete all the routes that are in this DeletionTable.

The deletion is not propagated downstream, so this is only useful when shutting down the RIB.

template<class A >
int DeletionTable< A >::delete_route ( const IPRouteEntry< A > *  route,
RouteTable< A > *  caller 
) [virtual]

Delete a route.

This route MUST NOT be in the DeletionTable trie.

Parameters:
routethe route entry to be deleted.
callerthe caller route table.
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements RouteTable< A >.

template<class A >
uint32_t DeletionTable< A >::genid ( ) const [inline]
Returns:
the generation id.
template<class A >
const IPRouteEntry< A > * DeletionTable< A >::lookup_route ( const IPNet< A > &  net) const [virtual]

Lookup a specific subnet to see if it is in this DeletionTable or the upstream tables.

Parameters:
netthe subnet to look up.
Returns:
a pointer to the route entry if it exists, NULL otherwise.

Implements RouteTable< A >.

template<class A >
const IPRouteEntry< A > * DeletionTable< A >::lookup_route ( const A &  addr) const [virtual]

Lookup an IP address to get the most specific (longest prefix length) route in the DeletionTable or the upstream tables that matches this address.

Parameters:
addrthe IP address to look up.
Returns:
a pointer to the most specific route entry if any entry matches, NULL otherwise.

Implements RouteTable< A >.

template<class A >
RouteRange< A > * DeletionTable< A >::lookup_route_range ( const A &  addr) const [virtual]

Lookup an IP addressto get the most specific (longest prefix length) route in the union of the DeletionTable and the upstream tables that matches this address, along with the RouteRange information for this address and route.

See also:
RouteRange
Parameters:
addrthe IP address to look up.
Returns:
a pointer to a RouteRange class instance containing the relevant answer. It is up to the recipient of this pointer to free the associated memory.

Implements RouteTable< A >.

template<class A >
TableType DeletionTable< A >::type ( ) const [inline, virtual]
Returns:
the table type (TableType).

Implements BGPRouteTable< A >.


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