|
xorp
|
Container class for FEA Interface objects in a system. More...
#include <iftree.hh>
Public Types | |
|
typedef map< string, IfTreeInterface * > | IfMap |
|
typedef map< uint32_t, IfTreeInterface * > | IfIndexMap |
|
typedef multimap< uint32_t, IfTreeVif * > | VifIndexMap |
Public Member Functions | |
| IfTree (const char *tree_name) | |
| Default constructor. | |
| IfTree (const IfTree &other) | |
| Constructor from another IfTree. | |
| virtual | ~IfTree () |
| Destructor. | |
| IfTree & | operator= (const IfTree &other) |
| Assignment operator. | |
| void | clear () |
| Remove all interface state from the interface tree. | |
| void | registerListener (IfTreeListener *l) const |
| Not really const, but better than having to pass non-const references to other classes. | |
| void | unregisterListener (IfTreeListener *l) const |
| Not really const, but better than having to pass non-const references to other classes. | |
| void | add_recursive_interface (const IfTreeInterface &other_iface, bool mark_state) |
| Add recursively a new interface. | |
| int | add_interface (const string &ifname) |
| Create a new interface. | |
| int | remove_interface (const string &ifname) |
| Label interface as ready for deletion. | |
| int | update_interface (const IfTreeInterface &other_iface) |
| Recursively create a new interface or update its state if it already exists. | |
| IfTreeInterface * | find_interface (const string &ifname) |
| Find an interface. | |
| const IfTreeInterface * | find_interface (const string &ifname) const |
| Find a const interface. | |
| IfTreeInterface * | find_interface (uint32_t pif_index) |
| Find an interface for a given physical index. | |
| const IfTreeInterface * | find_interface (uint32_t pif_index) const |
| Find a const interface for a given physical index. | |
| IfTreeVif * | find_vif (const string &ifname, const string &vifname) |
| Find a vif. | |
| const IfTreeVif * | find_vif (const string &ifname, const string &vifname) const |
| Find a const vif. | |
| IfTreeVif * | find_vif (uint32_t pif_index) |
| Find a vif for a given physical index. | |
| const IfTreeVif * | find_vif (uint32_t pif_index) const |
| Find a const vif for a given physical index. | |
| IfTreeAddr4 * | find_addr (const string &ifname, const string &vifname, const IPv4 &addr) |
| Find an IPv4 address. | |
| const IfTreeAddr4 * | find_addr (const string &ifname, const string &vifname, const IPv4 &addr) const |
| Find a const IPv4 address. | |
| IfTreeAddr6 * | find_addr (const string &ifname, const string &vifname, const IPv6 &addr) |
| Find an IPv6 address. | |
| const IfTreeAddr6 * | find_addr (const string &ifname, const string &vifname, const IPv6 &addr) const |
| Find a const IPv6 address. | |
| bool | find_interface_vif_by_addr (const IPvX &addr, const IfTreeInterface *&ifp, const IfTreeVif *&vifp) const |
| Find an interface and a vif by an address that belongs to that interface and vif. | |
| bool | find_interface_vif_same_subnet_or_p2p (const IPvX &addr, const IfTreeInterface *&ifp, const IfTreeVif *&vifp) const |
| Find an interface and a vif by an address that shares the same subnet or p2p address. | |
| IfMap & | interfaces () |
| Get the map with the stored interfaces. | |
| const IfMap & | interfaces () const |
| Get the const map with the stored interfaces. | |
| IfTree & | align_with_pulled_changes (const IfTree &other, const IfTree &user_config) |
| Align system-user merged configuration with the pulled changes in the system configuration. | |
| IfTree & | align_with_observed_changes (const IfTree &other, const IfTree &user_config) |
| Align system-user merged configuration with the observed changes in the system configuration. | |
| IfTree & | align_with_user_config (const IfTree &other) |
| Align system-user merged configuration with the user configuration changes. | |
| IfTree & | prepare_replacement_state (const IfTree &other) |
| Prepare configuration for pushing and replacing previous configuration. | |
| IfTree & | prune_bogus_deleted_state (const IfTree &old_iftree) |
| Prune bogus deleted state. | |
| void | finalize_state () |
| Delete interfaces labelled as ready for deletion, call finalize_state() on remaining interfaces, and set state to NO_CHANGE. | |
| string | str () const |
| const string & | getName () const |
| void | markVifDeleted (IfTreeVif *ifp) |
| void | markIfaceDeleted (IfTreeInterface *ifp) |
Protected Member Functions | |
| void | insert_ifindex (IfTreeInterface *ifp) |
| void | erase_ifindex (IfTreeInterface *ifp) |
| void | insert_vifindex (IfTreeVif *vifp) |
| void | erase_vifindex (IfTreeVif *vifp) |
| void | sendEvent (IfTreeVifEventE e, IfTreeVif *vifp) |
| void | sendEvent (IfTreeIfaceEventE e, IfTreeInterface *ifp) |
Private Attributes | |
| string | name |
| IfMap | _interfaces |
| IfIndexMap | _ifindex_map |
| VifIndexMap | _vifindex_map |
| list< IfTreeListener * > | listeners |
Friends | |
| class | IfTreeInterface |
| class | IfTreeVif |
Container class for FEA Interface objects in a system.
| IfTree::IfTree | ( | const IfTree & | other | ) |
| int IfTree::add_interface | ( | const string & | ifname | ) |
Create a new interface.
| ifname | the interface name. |
| void IfTree::add_recursive_interface | ( | const IfTreeInterface & | other_iface, |
| bool | mark_state | ||
| ) |
Align system-user merged configuration with the observed changes in the system configuration.
Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system). On certain systems there could be asynchronous updates originated by the system that are captured by the FEA interface observer (e.g., a cable is unplugged, a tunnel interface is added/deleted, etc).
This method is used to align those updates with the merged configuration.
1. If an interface in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the interface is ignored. Otherwise it is created, its state is merged from the user config and other tree, and is marked as "CREATED". 2. If an interface in the local tree is marked as "soft", its state is not modified and the rest of the processing is ignored. 3. If an interface in the local tree is marked as "default_system_config", the rest of the processing is not applied, and its state (and the subtree below it) is copied as-is from the other tree. 4. If an item in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the item is ignored. Otherwise it is created, its state is merged from the user config and the other tree, and is marked as "CREATED". 5. If an item in the other tree is marked as: (a) "NO_CHANGE": The state of the entry in the other tree is not propagated to the local tree, but its subtree entries are processed. (b) "DELETED": The item in the local tree is disabled, and the subtree entries are ignored. (c) "CREATED" or "CHANGED": If the state of the entry is different in the other and the local tree, it is copied to the local tree, and the item in the local tree is marked as "CREATED" or "CHANGED". unless it was marked earlier as "CREATED". Also, if the item is disabled in the user config tree, it is marked as "disabled" in the local tree.
| other | the configuration tree to align state with. |
| user_config | the user configuration tree to reference during the alignment. |
Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system). On certain systems there could be asynchronous updates originated by the system that are captured by the FEA interface observer (e.g., a cable is unplugged, a tunnel interface is added/deleted, etc).
This method is used to align those updates with the merged configuration.
The alignment works as follows: 1. If an interface in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the interface is ignored. Otherwise it is created, its state is merged from the user config and other tree, and is marked as "CREATED". 2. If an interface in the local tree is marked as "soft", its state is not modified and the rest of the processing is ignored. 3. If an interface in the local tree is marked as "default_system_config", the rest of the processing is not applied, and its state (and the subtree below it) is copied as-is from the other tree. 4. If an item in the other tree is not in the local tree, it is tested whether is in the user configuration tree. If not, the rest of the processing is not applied and the item is ignored. Otherwise it is created, its state is merged from the user config and the other tree, and is marked as "CREATED". 5. If an item in the other tree is marked as: (a) "NO_CHANGE": The state of the entry in the other tree is not propagated to the local tree, but its subtree entries are processed. (b) "DELETED": The item in the local tree is disabled, and the subtree entries are ignored. (c) "CREATED" or "CHANGED": If the state of the entry is different in the other and the local tree, it is copied to the local tree, and the item in the local tree is marked as "CREATED" or "CHANGED". Also, if the item is disabled in the user config tree, it is marked as "disabled" in the local tree.
| other | the configuration tree to align state with. |
| user_config | the user configuration tree to reference during the alignment. |
Align system-user merged configuration with the pulled changes in the system configuration.
Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system). Errors may occur pushing the user config down onto the hardware and we need a method to update the merged config from the h/w config that exists after the config push. We can't just copy the h/w config since the user config is restricted to configuration set by the user.
The alignment works as follows: 1. If an interface in the local tree is marked as "soft", its state is not modified and the rest of the processing is ignored. 2. If an interface in the local tree is marked as "default_system_config", the rest of the processing is not applied, and the following rules are used instead: (a) If the interface is not in the other tree, it is marked as "disabled" and its vifs are marked for deletion. (b) Otherwise, its state (and the subtree below it) is copied as-is from the other tree. 3. If an item in the local tree is not in the other tree, it is marked as "disabled" in the local tree. 4. If an item in the local tree is in the other tree, and its state is different in the local and the other tree, the state is copied from the other tree to the local tree. Also, if the item is disabled in the user config tree, it is marked as "disabled" in the local tree.
| other | the configuration tree to align state with. |
| user_config | the user configuration tree to reference during the alignment. |
Align system-user merged configuration with the user configuration changes.
Inside the FEA there may be multiple configuration representations, typically one the user modifies, one that mirrors the hardware, and one that merges those two (e.g., some of the merged information comes from the user configuration while other might come from the underlying system).
This method is used to align the user configuration changes with the merged configuration.
The alignment works as follows: 1. If an item in the other tree is not in the local tree, it is created in the local tree and its state (and the subtree below it) is copied as-is from the other tree, and the rest of the processing is ignored. 2. If an item in the other tree is marked as: (a) "DELETED": The item in the local tree is marked as "DELETED", and the subtree entries are ignored. (b) All other: If the state of the item is different in the other and the local tree, it is copied to the local tree. Note that we compare the state even for "NO_CHANGE" items in case a previous change to a parent item in the merged tree has affected the entry (e.g., disabled interface would disable the vifs and addresses as well).
| other | the configuration tree to align state with. |
| const IfTreeAddr4 * IfTree::find_addr | ( | const string & | ifname, |
| const string & | vifname, | ||
| const IPv4 & | addr | ||
| ) | const |
| IfTreeAddr4 * IfTree::find_addr | ( | const string & | ifname, |
| const string & | vifname, | ||
| const IPv4 & | addr | ||
| ) |
| const IfTreeAddr6 * IfTree::find_addr | ( | const string & | ifname, |
| const string & | vifname, | ||
| const IPv6 & | addr | ||
| ) | const |
| IfTreeAddr6 * IfTree::find_addr | ( | const string & | ifname, |
| const string & | vifname, | ||
| const IPv6 & | addr | ||
| ) |
| IfTreeInterface * IfTree::find_interface | ( | const string & | ifname | ) |
Find an interface.
| ifname | the interface name to search for. |
| const IfTreeInterface * IfTree::find_interface | ( | const string & | ifname | ) | const |
Find a const interface.
| ifname | the interface name to search for. |
| IfTreeInterface * IfTree::find_interface | ( | uint32_t | pif_index | ) |
Find an interface for a given physical index.
| pif_index | the physical interface index to search for. |
| const IfTreeInterface * IfTree::find_interface | ( | uint32_t | pif_index | ) | const |
Find a const interface for a given physical index.
| pif_index | the physical interface index to search for. |
| bool IfTree::find_interface_vif_by_addr | ( | const IPvX & | addr, |
| const IfTreeInterface *& | ifp, | ||
| const IfTreeVif *& | vifp | ||
| ) | const |
| bool IfTree::find_interface_vif_same_subnet_or_p2p | ( | const IPvX & | addr, |
| const IfTreeInterface *& | ifp, | ||
| const IfTreeVif *& | vifp | ||
| ) | const |
| const IfTreeVif * IfTree::find_vif | ( | uint32_t | pif_index | ) | const |
| IfTreeVif * IfTree::find_vif | ( | const string & | ifname, |
| const string & | vifname | ||
| ) |
| const IfTreeVif * IfTree::find_vif | ( | const string & | ifname, |
| const string & | vifname | ||
| ) | const |
| IfTreeVif * IfTree::find_vif | ( | uint32_t | pif_index | ) |
| IfMap& IfTree::interfaces | ( | ) | [inline] |
| const IfMap& IfTree::interfaces | ( | ) | const [inline] |
Prepare configuration for pushing and replacing previous configuration.
If the previous configuration is to be replaced with new configuration, we need to prepare the state that will delete, update, and add the new state as appropriate. The preparation works as follows:
If the previous configuration is to be replaced with new configuration, we need to prepare the state that will delete, update, and add the new state as appropriate. The preparation works as follows:
| int IfTree::remove_interface | ( | const string & | ifname | ) |
Label interface as ready for deletion.
Deletion does not occur until finalize_state() is called.
| string IfTree::str | ( | ) | const |
Reimplemented from IfTreeItem.
| int IfTree::update_interface | ( | const IfTreeInterface & | other_iface | ) |