|
|
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.
SubnetRoute (const SubnetRoute<A>& route_to_clone)
| SubnetRoute |
SubnetRoute (const IPNet<A> &net,
PAListRef<A> attributes,
const SubnetRoute<A>* parent_route)
| SubnetRoute |
Parameters:
net | the subnet (address and prefix) this route refers to. |
attributes | pointer to the path attribute list associated with * this route. |
parent_route | the 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. |
SubnetRoute (const IPNet<A> &net,
PAListRef<A> attributes,
const SubnetRoute<A>* parent_route,
uint32_t igp_metric)
| SubnetRoute |
Parameters:
net | the subnet (address and prefix) this route refers to. |
attributes | pointer to the path attribute list associated with * this route. |
parent_route | the 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_metric | the IGP routing protocol metric to reach the nexthop obtained from the RIB. |
bool operator== (const SubnetRoute<A>& them)
| operator== |
[const]
Equality comparison for SubnetRoutes. Only the subnet and attributes are compared, not the metadata such as flags, igp_metric, etc
Parameters:
them | Route to be compared against. |
const IPNet<A>& net ()
| net |
[const]
Returns: the subnet this route refers to.
const A& nexthop ()
| nexthop |
[const]
Returns: the address of the nexthop for this route.
PAListRef<A> attributes ()
| attributes |
[const]
Returns: a pointer to the path attribute list for this route.
bool in_use ()
| in_use |
[const]
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.
void set_in_use (bool used)
| set_in_use |
[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:
used | true if the route is "in use". |
bool is_winner ()
| is_winner |
[const]
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
void set_is_winner (uint32_t igp_metric)
| set_is_winner |
[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
void set_is_not_winner ()
| 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)
| set_nexthop_resolved |
[const]
record whether or not a route's nexthop resolved
bool nexthop_resolved ()
| nexthop_resolved |
[const]
did the route's nexthop resolve when it was passed through the NextHop resolver table.
bool is_filtered ()
| is_filtered |
[const]
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.
void set_filtered (bool filtered)
| set_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:
filtered | true if the route was filtered, false otherwise. |
bool is_deleted ()
| 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 ()
| str |
[const]
Returns: a string representation of the route for debugging purposes
uint32_t igp_metric ()
| igp_metric |
[const]
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.
const SubnetRoute<A> * original_route ()
| original_route |
[const]
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.
const SubnetRoute<A>* parent_route ()
| parent_route |
[const]
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.
void set_parent_route (const SubnetRoute<A> *parent)
| set_parent_route |
Parameters:
parent | the original version of this route. |
void unref ()
| unref |
[const]
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.
uint16_t refcount ()
| refcount |
[const]
const PolicyTags& policytags ()
| policytags |
[const]
Returns: policy tags associated with route.
void set_policytags (const PolicyTags& tags)
| set_policytags |
[const]
Replaced policy tags of route.
Parameters:
tags | new policy tags for route. |
const RefPf& policyfilter (uint32_t i)
| policyfilter |
[const]
void set_policyfilter (uint32_t i, const RefPf& pf)
| set_policyfilter |
[const]
void set_aggr_brief_mode ()
| set_aggr_brief_mode |
[const]
Set the "brief" mode flag on an candidate for aggregation.
void clear_aggr_brief_mode ()
| clear_aggr_brief_mode |
[const]
Clear the "brief" mode flag on an candidate for aggregation.
bool aggr_brief_mode ()
| aggr_brief_mode |
[const]
Read the "brief" aggregation mode flag.
void set_aggr_prefix_len (uint32_t preflen)
| set_aggr_prefix_len |
Set the target prefix length on an candidate for aggregation. The field is also used for storing aggregation markers.
Parameters:
preflen | prefix length of the requested aggregate route. |
uint32_t aggr_prefix_len ()
| aggr_prefix_len |
[const]
Read the aggregation prefix length marker. The field is also used for storing aggregation markers.
~SubnetRoute ()
| ~SubnetRoute |
[protected]
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.