xorp

SubnetRoute< A > Class Template Reference

SubnetRoute holds a BGP routing table entry. More...

#include <subnet_route.hh>

Inheritance diagram for SubnetRoute< A >:
ChainedSubnetRoute< A >

List of all members.

Public Member Functions

 SubnetRoute (const SubnetRoute< A > &route_to_clone)
 SubnetRoute copy constructor.
 SubnetRoute (const IPNet< A > &net, PAListRef< A > attributes, const SubnetRoute< A > *parent_route)
 SubnetRoute constructor.
 SubnetRoute (const IPNet< A > &net, PAListRef< A > attributes, const SubnetRoute< A > *parent_route, uint32_t igp_metric)
 SubnetRoute constructor.
bool operator== (const SubnetRoute< A > &them) const
 Equality comparison for SubnetRoutes.
const IPNet< A > & net () const
PAListRef< A > attributes () const
bool in_use () const
void set_in_use (bool used) const
 Record whether or not this route is in use.
bool is_winner () const
 returns true if the route was chosen by the routing decision process as the winning route for this subnet.
void set_is_winner (uint32_t igp_metric) const
 when a route is chosen by the routing decision process as the winning route for this subnet, set_is_winner should be called to record this fact and to record the igp_metric at the time the route was chosen.
void set_is_not_winner () const
 when a route fails to be chosen by the routing decision process as the winning route for this subnet, set_is_not_winner should be called to record this fact.
void set_nexthop_resolved (bool resolved) const
 record whether or not a route's nexthop resolved
bool nexthop_resolved () const
 did the route's nexthop resolve when it was passed through the NextHop resolver table.
bool is_filtered () const
 is_filtered returns true if the route was filtered out by the incoming filter bank, false otherwise.
void set_filtered (bool filtered) const
 set_filtered record whether or not the route was filtered out by the incoming filter bank.
bool is_deleted () const
 is_deleted returns true if the route has already been deleted (but the class instance representing it has not been because it's reference count is non-zero)
string str () const
uint32_t igp_metric () const
const SubnetRoute< A > * original_route () const
const SubnetRoute< A > * parent_route () const
void set_parent_route (const SubnetRoute< A > *parent)
 record the original version of this route, before any filters were applied.
void unref () const
 delete this route
uint16_t refcount () const
const PolicyTagspolicytags () const
void set_policytags (const PolicyTags &tags) const
 Replaced policy tags of route.
const RefPfpolicyfilter (uint32_t i) const
void set_policyfilter (uint32_t i, const RefPf &pf) const
void set_aggr_brief_mode () const
 Set the "brief" mode flag on an candidate for aggregation.
void clear_aggr_brief_mode () const
 Clear the "brief" mode flag on an candidate for aggregation.
bool aggr_brief_mode () const
 Read the "brief" aggregation mode flag.
void set_aggr_prefix_len (uint32_t preflen)
 Set the target prefix length on an candidate for aggregation.
uint32_t aggr_prefix_len () const
 Read the aggregation prefix length marker.

Protected Member Functions

 ~SubnetRoute ()
 protected SubnetRoute destructor.

Private Member Functions

void bump_refcount (int delta) const
const SubnetRoute< A > & operator= (const SubnetRoute< A > &)

Private Attributes

IPNet< A > _net
 _net is the subnet (address and prefix) for this route.
PAListRef< A > _attributes
 _attributes is a pointer to the path attribute list for this route.
const SubnetRoute< A > * _parent_route
 _parent_route is a pointer to the original version of this route, before any filters modified it.
RouteMetaData _metadata

Friends

class SubnetRouteRef< A >
class SubnetRouteConstRef< A >

Detailed Description

template<class A>
class SubnetRoute< A >

SubnetRoute holds a BGP routing table entry.

SubnetRoute is the basic class used to hold a BGP routing table entry in BGP's internal representation. It's templated so the same code can be used to hold IPv4 or IPv6 routes - their representation is essentially the same internally, even though they're encoded differently on the wire by the BGP protocol. A route essentially consists of the subnet (address and prefix) referred to by the route, a BGP path attribute list, and some metadata for our own use. When a route update from BGP comes it, it is split into multiple subnet routes, one for each NLRI (IPv4) or MP_REACH (IPv6) attribute. SubnetRoute is also the principle way routing information is passed around internally in our BGP implementation.

SubnetRoute is reference-counted - delete should NOT normally be called directly on a SubnetRoute; instead unref should be called, which will decrement the reference count, and delete the instance if the reference count has reached zero.


Constructor & Destructor Documentation

template<class A>
SubnetRoute< A >::SubnetRoute ( const IPNet< A > &  net,
PAListRef< A >  attributes,
const SubnetRoute< A > *  parent_route 
)

SubnetRoute constructor.

Parameters:
netthe subnet (address and prefix) this route refers to.
attributespointer to the path attribute list associated with * this route.
parent_routethe SubnetRoute that this route was derived from. For example, if a filter takes one SubnetRoute and generates a modified version, the parent_route of the new one should point to the original. If this is set to non-NULL, care must be taken to ensure the original route is never deleted before the derived route.
template<class A>
SubnetRoute< A >::SubnetRoute ( const IPNet< A > &  net,
PAListRef< A >  attributes,
const SubnetRoute< A > *  parent_route,
uint32_t  igp_metric 
)

SubnetRoute constructor.

Parameters:
netthe subnet (address and prefix) this route refers to.
attributespointer to the path attribute list associated with * this route.
parent_routethe SubnetRoute that this route was derived from. For example, if a filter takes one SubnetRoute and generates a modified version, the parent_route of the new one should point to the original. If this is set to non-NULL, care must be taken to ensure the original route is never deleted before the derived route.
igp_metricthe IGP routing protocol metric to reach the nexthop obtained from the RIB.
template<class A >
SubnetRoute< A >::~SubnetRoute ( ) [protected]

protected SubnetRoute destructor.

The destructor is protected because you are not supposed to directly delete a SubnetRoute. Instead you should call unref() and the SubnetRoute will be deleted when it's reference count reaches zero.


Member Function Documentation

template<class A>
uint32_t SubnetRoute< A >::aggr_prefix_len ( ) const [inline]

Read the aggregation prefix length marker.

The field is also used for storing aggregation markers.

template<class A>
PAListRef<A> SubnetRoute< A >::attributes ( ) const [inline]
Returns:
a pointer to the path attribute list for this route.
template<class A>
uint32_t SubnetRoute< A >::igp_metric ( ) const [inline]
Returns:
the IGP routing protocol metric that applied when the route won the decision process. If the route has not won, this value is undefined.
template<class A>
bool SubnetRoute< A >::in_use ( ) const [inline]
Returns:
whether or not this route is in use. "in use" here does not mean the route won the decision process, but rather that it was at least a contender for decision, and was not filtered in the incoming filter bank.
template<class A>
bool SubnetRoute< A >::is_filtered ( ) const [inline]

is_filtered returns true if the route was filtered out by the incoming filter bank, false otherwise.

As such it only makes sense calling this on routes that are stored in the RibIn.

template<class A>
bool SubnetRoute< A >::is_winner ( ) const [inline]

returns true if the route was chosen by the routing decision process as the winning route for this subnet.

is_winner should NOT be called by anything other than the DecisionTable because caching means that it may not return the right answer anywhere else

template<class A>
const IPNet<A>& SubnetRoute< A >::net ( ) const [inline]
Returns:
the subnet this route refers to.
template<class A>
bool SubnetRoute< A >::operator== ( const SubnetRoute< A > &  them) const

Equality comparison for SubnetRoutes.

Equality comparison for SubnetRoutes. Only the subnet and attributes are compared, not the metadata such as flags, igp_metric, etc

Parameters:
themRoute to be compared against.
template<class A>
const SubnetRoute<A>* SubnetRoute< A >::original_route ( ) const [inline]
Returns:
the original version of this route, before any filters were applied to it to modify it. If no filters have been applied, this may be this route itself.
template<class A>
const SubnetRoute<A>* SubnetRoute< A >::parent_route ( ) const [inline]
Returns:
the original version of this route, before any filters were applied to it to modify it. If no filters have been applied, NULL will be returned.
template<class A>
const PolicyTags& SubnetRoute< A >::policytags ( ) const [inline]
Returns:
policy tags associated with route.
template<class A>
void SubnetRoute< A >::set_aggr_prefix_len ( uint32_t  preflen) [inline]

Set the target prefix length on an candidate for aggregation.

The field is also used for storing aggregation markers.

Parameters:
preflenprefix length of the requested aggregate route.
template<class A >
void SubnetRoute< A >::set_filtered ( bool  filtered) const

set_filtered record whether or not the route was filtered out by the incoming filter bank.

As such it only makes sense calling this on routes that are stored in the RibIn.

Parameters:
filteredtrue if the route was filtered, false otherwise.
template<class A >
void SubnetRoute< A >::set_in_use ( bool  used) const

Record whether or not this route is in use.

"in use" here does not mean the route won the decision process, but rather that it was at least a contender for decision, and was not filtered in the incoming filter bank.

Parameters:
usedtrue if the route is "in use".
template<class A >
void SubnetRoute< A >::set_is_winner ( uint32_t  igp_metric) const

when a route is chosen by the routing decision process as the winning route for this subnet, set_is_winner should be called to record this fact and to record the igp_metric at the time the route was chosen.

set_is_winner should NOT be called by anything other than the DecisionTable because caching means that it may not return the right answer anywhere else

template<class A>
void SubnetRoute< A >::set_parent_route ( const SubnetRoute< A > *  parent)

record the original version of this route, before any filters were applied.

Parameters:
parentthe original version of this route.
template<class A>
void SubnetRoute< A >::set_policytags ( const PolicyTags tags) const [inline]

Replaced policy tags of route.

Parameters:
tagsnew policy tags for route.
template<class A >
string SubnetRoute< A >::str ( ) const
Returns:
a string representation of the route for debugging purposes
template<class A >
void SubnetRoute< A >::unref ( ) const

delete this route

unref is called to delete a SubnetRoute, and should be called instead of calling delete on the route. SubnetRoutes are reference-counted, so unref decrements the reference count and deletes the storage only if the reference count reaches zero.


Member Data Documentation

template<class A>
PAListRef<A> SubnetRoute< A >::_attributes [private]

_attributes is a pointer to the path attribute list for this route.

The actual data storage for the path attribute list is handled inside the attribute manager

template<class A>
const SubnetRoute<A>* SubnetRoute< A >::_parent_route [private]

_parent_route is a pointer to the original version of this route, before any filters modified it.

It may be NULL, indicating this is the original version.


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