|
xorp
|
Master class for a RIB. More...
#include <rib.hh>
Public Member Functions | |
| RIB (RibTransportType rib_type, RibManager &rib_manager, EventLoop &eventloop) | |
| RIB Constructor. | |
| virtual | ~RIB () |
| RIB Destructor. | |
| void | set_errors_are_fatal () |
| Set test-mode: abort on some errors that we'd normally mask. | |
| list< string > | registered_protocol_names () const |
| Get the list with the registered protocol names. | |
| void | initialize (RegisterServer ®ister_server) |
| Initialize the RIB. | |
| int | initialize_redist_all (const string &all) |
| Initialize the RIB's RedistTable at the end so that the winning routes are exported to the RIB clients (e.g., the FEA). | |
| int | initialize_policy_redist () |
| Initialize the RIB's PolicyRedistTable. | |
| int | initialize_register (RegisterServer ®ister_server) |
| Initialize the RIB's RegisterTable. | |
| int | new_origin_table (const string &tablename, const string &target_class, const string &target_instance, uint32_t admin_distance, ProtocolType protocol_type) |
| Add a new OriginTable. | |
| virtual int | new_vif (const string &vifname, const Vif &vif) |
| Inform the RIB about the existence of a Virtual Interface. | |
| virtual int | delete_vif (const string &vifname) |
| Inform the RIB that a VIF no longer exists. | |
| virtual void | destroy_deleted_vif (RibVif *rib_vif) |
| Destroy a VIF container for a VIF that no longer exists. | |
| virtual int | set_vif_flags (const string &vifname, bool is_p2p, bool is_loopback, bool is_multicast, bool is_broadcast, bool is_up, uint32_t mtu) |
| Set the vif flags of a configured vif. | |
| virtual int | add_vif_address (const string &vifname, const A &addr, const IPNet< A > &subnet, const A &broadcast_addr, const A &peer_addr) |
| Add an address and subnet to a existing VIF. | |
| virtual int | delete_vif_address (const string &vifname, const A &addr) |
| Remove an address and the associated subnet from an existing VIF. | |
| int | add_connected_route (const RibVif &vif, const IPNet< A > &net, const A &nexthop_addr, const A &peer_addr) |
| Add a route to the "connected" OriginTable. | |
| int | delete_connected_route (const RibVif &vif, const IPNet< A > &net, const A &peer_addr) |
| Delete a route from the "connected" OriginTable. | |
| virtual int | add_route (const string &tablename, const IPNet< A > &net, const A &nexthop_addr, const string &ifname, const string &vifname, uint32_t metric, const PolicyTags &policytags) |
| Add a route via the OriginTable called tablename. | |
| virtual int | replace_route (const string &tablename, const IPNet< A > &net, const A &nexthop_addr, const string &ifname, const string &vifname, uint32_t metric, const PolicyTags &policytags) |
| Replace an existing route via the OriginTable called tablename. | |
| virtual int | verify_route (const A &lookupaddr, const string &ifname, const A &nexthop_addr, uint32_t metric, RibVerifyType matchtype) |
| Verify the result of a route lookup in the RIB matches the parameters we expect. | |
| virtual int | delete_route (const string &tablename, const IPNet< A > &subnet) |
| Delete an existing route via the OriginTable called tablename. | |
| virtual const A & | lookup_route (const A &lookupaddr) |
| Lookup an address in the RIB to determine the nexthop router to which packets for this address will be forwarded. | |
| virtual RouteRange< A > * | route_range_lookup (const A &lookupaddr) |
| Used for debugging only. | |
| virtual RouteRegister< A > * | route_register (const A &lookupaddr, const string &module) |
| Register interest in being notified about all changes to routing information that would affect traffic destined for a particular address. | |
| virtual int | route_deregister (const IPNet< A > &subnet, const string &module) |
| De-register interest in being notified about all changes to routing information for a particular address. | |
| Protocol * | find_protocol (const string &protocol) |
| Find a routing protocol, given its protocol name. | |
| RedistTable< A > * | protocol_redist_table (const string &protocol) |
| Get route redistribution table for specified routing protocol. | |
| virtual int | add_igp_table (const string &tablename, const string &target_class, const string &target_instance) |
| Create the OriginTable for an IGP protocol and plumb it into the RIB. | |
| virtual int | delete_igp_table (const string &tablename, const string &target_class, const string &target_instance) |
| Delete the OriginTable for an IGP protocol and unplumb it from the RIB. | |
| virtual int | add_egp_table (const string &tablename, const string &target_class, const string &target_instance) |
| Create the OriginTable for an EGP protocol and plumb it into the RIB. | |
| virtual int | delete_egp_table (const string &tablename, const string &target_class, const string &target_instance) |
| Delete the OriginTable for an EGP protocol and unplumb it from the RIB. | |
| void | target_death (const string &target_class, const string &target_instance) |
| An XRL Target died. | |
| void | print_rib () const |
| Print the RIB structure for debugging. | |
| string | name () const |
| Get RIB name. | |
| void | push_routes () |
| Push routes through policy filters for re-filtering. | |
| int | set_protocol_admin_distance (const string &protocol_name, const uint32_t &admin_distance) |
| Set the admin distance associated with a routing protocol. | |
| map< string, uint32_t > & | get_protocol_admin_distances () |
| Get the map of all registered admin distances. | |
| uint32_t | get_protocol_admin_distance (const string &protocol_name) |
| Get the admin distance associated with a routing protocol. | |
Protected Attributes | |
| RibManager & | _rib_manager |
| EventLoop & | _eventloop |
| RouteTable< A > * | _final_table |
| RegisterTable< A > * | _register_table |
| bool | _multicast |
| bool | _errors_are_fatal |
| PolicyRedistTable< A > * | _policy_redist_table |
| list< RouteTable< A > * > | _tables |
| map< string, Protocol * > | _protocols |
| map< string, OriginTable< A > * > | _routing_protocol_instances |
| map< string, RibVif * > | _vifs |
| map< string, RibVif * > | _deleted_vifs |
| map< string, uint32_t > | _admin_distances |
| map< A, IPExternalNextHop< A > > | _external_nexthops |
| map< A, IPPeerNextHop< A > > | _peer_nexthops |
Private Member Functions | |
| int | add_origin_table (const string &tablename, const string &target_class, const string &target_instance, ProtocolType protocol_type) |
| Used to implement add_igp_table and add_egp_table. | |
| int | delete_origin_table (const string &tablename, const string &target_class, const string &target_instance) |
| Used to implement delete_igp_table and delete_egp_table. | |
| int | add_policy_connected_table (const string &origin_tablename) |
| Add a table for policy filtering of connected routes. | |
| int | add_redist_table (const string &origin_tablename) |
| Add a RedistTable behind OriginTable. | |
| RouteTable< A > * | track_back (RouteTable< A > *rt, int typemask) const |
| track_back trough the RouteTables' parent pointers to find the last (i.e, nearest the OriginTable) table that matches the mask in typemask. | |
| RouteTable< A > * | track_forward (RouteTable< A > *rt, int typemask) const |
| track_forward trough the RouteTables' child pointers to find the last able that matches the mask in typemask. | |
| RouteTable< A > * | find_table (const string &tablename) |
| Find a routing table, given its table name. | |
| OriginTable< A > * | find_table_by_instance (const string &tablename, const string &target_class, const string &target_instance) |
| Find a routing table, given its protocol name and XRL target instance name. | |
| int | add_table (RouteTable< A > *table) |
| Add table to RIB, but don't do any plumbing. | |
| int | remove_table (const string &tablename) |
| Remove table from RIB, but don't do any unplumbing. | |
| RibVif * | find_vif (const A &addr) |
| Find the virtual interface associated with one of this router's addresses. | |
| IPExternalNextHop< A > * | find_external_nexthop (const A &addr) |
| Find the IP External Nexthop class instance associated with an IP address. | |
| IPPeerNextHop< A > * | find_peer_nexthop (const A &addr) |
| Find the IP Peer Nexthop class instance associated with an IP address. | |
| IPExternalNextHop< A > * | find_or_create_external_nexthop (const A &addr) |
| Find or create the IP External Nexthop class instance associated with an IP address. | |
| IPPeerNextHop< A > * | find_or_create_peer_nexthop (const A &addr) |
| Find or create the IP Peer Nexthop class instance associated with an IP address. | |
| void | flush () |
| Flush out routing table changes to other processes. | |
Master class for a RIB.
RIB is the master class for a Routing Information Base. It holds the RibVif table, routing tables for each protocol, etc. Typically we would have one RIB for IPv4 unicast, one for IPv4 multicast topology, one for IPv6 unicast and one for IPv6 multicast.
Note that the XRL commands assume some level of filtering has already taken place to route to command to the right RIB.
| RIB< A >::RIB | ( | RibTransportType | rib_type, |
| RibManager & | rib_manager, | ||
| EventLoop & | eventloop | ||
| ) |
RIB Constructor.
| rib_type | indicates whether this RIB holds UNICAST or MULTICAST routing information. In the case of multicast, this is the topology information, not the forwarding information. |
| rib_manager | the main RIB manager process holding stuff that's common to all the individual RIBs. |
| eventloop | the main event loop. |
| int RIB< A >::add_connected_route | ( | const RibVif & | vif, |
| const IPNet< A > & | net, | ||
| const A & | nexthop_addr, | ||
| const A & | peer_addr | ||
| ) |
Add a route to the "connected" OriginTable.
| vif | the vif with the connected route. |
| net | the subnet (address and prefix length) of the route. |
| nexthop_addr | the nexthop address of the route to add. |
| peer_addr | the peer address for the route to add (if a point-to-point interface). |
| int RIB< A >::add_egp_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [virtual] |
Create the OriginTable for an EGP protocol and plumb it into the RIB.
Typically this will be called when a new instance of an EGP routing protocol such as EBGP or IBGP starts up. Note that EBGP and IBGP should register separately.
| tablename | the routing protocol name. This should be one of the list of names the RIB knows about, or the incorrect default administrative distance will be applied. |
| target_class | the XRL target class of the routing protocol that will supply routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that will supply routes to this OriginTable. |
| int RIB< A >::add_igp_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [virtual] |
Create the OriginTable for an IGP protocol and plumb it into the RIB.
Typically this will be called when a new instance of an IGP routing protocol such as OSPF starts up.
| tablename | the routing protocol name. This should be one of the list of names the RIB knows about, or the incorrect default administrative distance will be applied. |
| target_class | the XRL target class of the routing protocol that will supply routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that will supply routes to this OriginTable. |
| int RIB< A >::add_origin_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance, | ||
| ProtocolType | protocol_type | ||
| ) | [private] |
Used to implement add_igp_table and add_egp_table.
| tablename | the routing protocol name. |
| target_class | the XRL target class of the routing protocol that will supply routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that will supply routes to this OriginTable. |
| protocol_type | the routing protocol type (ProtocolType). |
| int RIB< A >::add_policy_connected_table | ( | const string & | origin_tablename | ) | [private] |
Add a table for policy filtering of connected routes.
This is used to enable route redistribution of connected routes.
| origin_tablename | The name of the origin table. |
| int RIB< A >::add_redist_table | ( | const string & | origin_tablename | ) | [private] |
Add a RedistTable behind OriginTable.
This allows routes associated with the OriginTable to be redistributed in future.
| origin_tablename | Name of OriginTable. |
| int RIB< A >::add_route | ( | const string & | tablename, |
| const IPNet< A > & | net, | ||
| const A & | nexthop_addr, | ||
| const string & | ifname, | ||
| const string & | vifname, | ||
| uint32_t | metric, | ||
| const PolicyTags & | policytags | ||
| ) | [virtual] |
Add a route via the OriginTable called tablename.
| tablename | the name of the OriginTable into which the route should be inserted. |
| net | the subnet (address and prefix length) of the route. |
| nexthop_addr | the nexthop that packets destined for net should be forwarded to. |
| ifname | the name of the physical interface toward the destination. If an empty string the interface will be chosen by RIB. |
| vifname | the name of the virtual interface toward the destination. If an empty string the interface will be chosen by RIB. |
| metric | the routing protocol metric associated with this route. |
| policytags | the policy-tags for this route. |
| int RIB< A >::add_table | ( | RouteTable< A > * | table | ) | [inline, private] |
| int RIB< A >::add_vif_address | ( | const string & | vifname, |
| const A & | addr, | ||
| const IPNet< A > & | subnet, | ||
| const A & | broadcast_addr, | ||
| const A & | peer_addr | ||
| ) | [virtual] |
Add an address and subnet to a existing VIF.
Each VIF may have multiple addresses and associated subnets.
| vifname | the name of the VIF the address will be added to. |
| addr | the address to be added. This must be one of the addresses of this router. |
| subnet | the subnet that is connected to this VIF corresponding to the address addr. |
| broadcast | the broadcast address to add. In case of IPv6 this address is ignored. |
| peer | the peer address to add. |
| int RIB< A >::delete_egp_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [virtual] |
Delete the OriginTable for an EGP protocol and unplumb it from the RIB.
Typically this will be called when an instance of an EGP routing protocol such as BGP exits.
| tablename | the routing protocol name, previously registered using add_igp_table. |
| target_class | the XRL target class of the routing protocol that supplied routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that supplied routes to this OriginTable. |
| int RIB< A >::delete_igp_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [virtual] |
Delete the OriginTable for an IGP protocol and unplumb it from the RIB.
Typically this will be called when an instance of an IGP routing protocol such as OSPF exits.
| tablename | the routing protocol name, previously registered using add_igp_table. |
| target_class | the XRL target class of the routing protocol that supplied routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that supplied routes to this OriginTable. |
| int RIB< A >::delete_origin_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [private] |
Used to implement delete_igp_table and delete_egp_table.
| tablename | the routing protocol name. |
| target_class | the XRL target class of the routing protocol that will supply routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that supplied routes to this OriginTable. |
| int RIB< A >::delete_route | ( | const string & | tablename, |
| const IPNet< A > & | subnet | ||
| ) | [virtual] |
Delete an existing route via the OriginTable called tablename.
| tablename | the name of the OriginTable in which the route should be deleted. |
| subnet | the subnet (address and prefix length) of the route to be deleted. |
| int RIB< A >::delete_vif | ( | const string & | vifname | ) | [virtual] |
| int RIB< A >::delete_vif_address | ( | const string & | vifname, |
| const A & | addr | ||
| ) | [virtual] |
Destroy a VIF container for a VIF that no longer exists.
| rib_vif | the VIF container that will be destroyed. |
| IPExternalNextHop< A > * RIB< A >::find_external_nexthop | ( | const A & | addr | ) | [inline, private] |
| IPExternalNextHop< A > * RIB< A >::find_or_create_external_nexthop | ( | const A & | addr | ) | [inline, private] |
| IPPeerNextHop< A > * RIB< A >::find_or_create_peer_nexthop | ( | const A & | addr | ) | [inline, private] |
| IPPeerNextHop< A > * RIB< A >::find_peer_nexthop | ( | const A & | addr | ) | [inline, private] |
| RouteTable< A > * RIB< A >::find_table | ( | const string & | tablename | ) | [inline, private] |
| OriginTable< A > * RIB< A >::find_table_by_instance | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance | ||
| ) | [inline, private] |
Find a routing table, given its protocol name and XRL target instance name.
| tablename | the name of the protocol to search for. |
| target_class | the name of the target class to search for. |
| target_instance | the name of the target instance to search for. |
| uint32_t RIB< A >::get_protocol_admin_distance | ( | const string & | protocol_name | ) | [inline] |
| map<string, uint32_t>& RIB< A >::get_protocol_admin_distances | ( | ) | [inline] |
| void RIB< A >::initialize | ( | RegisterServer & | register_server | ) |
| int RIB< A >::initialize_policy_redist | ( | ) |
Initialize the RIB's PolicyRedistTable.
The PolicyRedistTable enables route redistribution according to policy configuration. Based on the policy tags of routes passing through this table, a redistribution request is sent to the relevant protocols. If routes are being deleted, protocols are informed to stop advertising the route.
| int RIB< A >::initialize_redist_all | ( | const string & | all | ) |
Initialize the RIB's RedistTable at the end so that the winning routes are exported to the RIB clients (e.g., the FEA).
Note that it is an error to initialize the table twice.
| all | a keyword string which can be used by RIB clients to register with the RIB to receive the winning routes from the RedistTable. |
| int RIB< A >::initialize_register | ( | RegisterServer & | register_server | ) |
Initialize the RIB's RegisterTable.
The RegisterTable allows routing protocols such as BGP to register interest in routing information that affects specfic addresses. Note that it is an error to initialize the table twice.
| register_server | the RegisterServer to initialize the Rib with. |
| const A & RIB< A >::lookup_route | ( | const A & | lookupaddr | ) | [virtual] |
| int RIB< A >::new_origin_table | ( | const string & | tablename, |
| const string & | target_class, | ||
| const string & | target_instance, | ||
| uint32_t | admin_distance, | ||
| ProtocolType | protocol_type | ||
| ) |
Add a new OriginTable.
Use is deprecated, except in test suites.
| tablename | human-readable name for this table to help in debugging. |
| target_class | the XRL target class of the routing protocol that will supply routes to this OriginTable. |
| target_instance | the XRL target instance of the routing protocol that will supply routes to this OriginTable. |
| admin_distance | default administrative distance to be applied to routes that enter the RIB through this OriginTable. |
| protocol_type | the routing protocol type (ProtocolType). |
Inform the RIB about the existence of a Virtual Interface.
Note that it is an error to add twice a vif with the same vifname.
| vifname | the name of the VIF, as understood by the FEA. |
| vif | Vif class instance giving the information about this vif. |
| list< string > RIB< A >::registered_protocol_names | ( | ) | const |
| int RIB< A >::remove_table | ( | const string & | tablename | ) | [inline, private] |
| int RIB< A >::replace_route | ( | const string & | tablename, |
| const IPNet< A > & | net, | ||
| const A & | nexthop_addr, | ||
| const string & | ifname, | ||
| const string & | vifname, | ||
| uint32_t | metric, | ||
| const PolicyTags & | policytags | ||
| ) | [virtual] |
Replace an existing route via the OriginTable called tablename.
| tablename | the name of the OriginTable in which the route should be replaced. |
| net | the subnet (address and prefix length) of the route. |
| nexthop_addr | the new nexthop that packets destined for net should be forwarded to. |
| ifname | the name of the physical interface toward the destination. If an empty string the interface will be chosen by RIB. |
| vifname | the name of the virtual interface toward the destination. If an empty string the interface will be chosen by RIB. |
| metric | the new routing protocol metric associated with this |
| policytags | the policy-tags for this route. route. |
| int RIB< A >::route_deregister | ( | const IPNet< A > & | subnet, |
| const string & | module | ||
| ) | [virtual] |
De-register interest in being notified about all changes to routing information for a particular address.
| lookupaddr | the address to de-register interest in. |
| module | the XRL module name to which notifications of changes should no longer be sent. |
| RouteRegister< A > * RIB< A >::route_register | ( | const A & | lookupaddr, |
| const string & | module | ||
| ) | [virtual] |
| int RIB< A >::set_protocol_admin_distance | ( | const string & | protocol_name, |
| const uint32_t & | admin_distance | ||
| ) |
| int RIB< A >::set_vif_flags | ( | const string & | vifname, |
| bool | is_p2p, | ||
| bool | is_loopback, | ||
| bool | is_multicast, | ||
| bool | is_broadcast, | ||
| bool | is_up, | ||
| uint32_t | mtu | ||
| ) | [virtual] |
Set the vif flags of a configured vif.
| vifname | the name of the vif. |
| is_pim_register | true if the vif is a PIM Register interface. |
| is_p2p | true if the vif is point-to-point interface. |
| is_loopback | true if the vif is a loopback interface. |
| is_multicast | true if the vif is multicast capable. |
| is_broadcast | true if the vif is broadcast capable. |
| is_up | true if the underlying vif is UP. |
| mtu | the MTU of the vif. |
| void RIB< A >::target_death | ( | const string & | target_class, |
| const string & | target_instance | ||
| ) |
| RouteTable< A > * RIB< A >::track_back | ( | RouteTable< A > * | rt, |
| int | typemask | ||
| ) | const [private] |
track_back trough the RouteTables' parent pointers to find the last (i.e, nearest the OriginTable) table that matches the mask in typemask.
If the table given by rt doesn't match the mask, return it anyway. If a table has more than one parent, then this is an error.
| rt | the routing table to start with. |
| typemask | the bitwise-or of the routing table types that we may track back through. |
| RouteTable< A > * RIB< A >::track_forward | ( | RouteTable< A > * | rt, |
| int | typemask | ||
| ) | const [private] |
track_forward trough the RouteTables' child pointers to find the last able that matches the mask in typemask.
Unlike track_back, if rt doesn't match, but the next does, the track forward anyway.
| rt | the routing table to start with. |
| typemask | the bitwise-or of the routing table types that we may track forward through. |
| int RIB< A >::verify_route | ( | const A & | lookupaddr, |
| const string & | ifname, | ||
| const A & | nexthop_addr, | ||
| uint32_t | metric, | ||
| RibVerifyType | matchtype | ||
| ) | [virtual] |
Verify the result of a route lookup in the RIB matches the parameters we expect.
Intended for testing purposes only.
| lookupaddr | the destination to be verified. |
| nexthop_addr | the expected next hop address. |
| ifname | the expected interface. |
| metric | the expected routing protocol metric. |
| type | the expected type of match. |