diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-04-11 08:08:30 -0700 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-07-17 08:53:33 +0000 |
commit | 208c29aac523231af2420a95ba7e5d361698780b (patch) | |
tree | d16ac1d772d55afdf5277345a1ec8db211d1f27f /extras/vom | |
parent | 4faab21a75a208d83c184bd424938c4dbf6b38e4 (diff) |
VOM: support for pipes
Change-Id: I5c381dfe2f926f94a34ee8ed8f1b9ec6038d5fe2
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'extras/vom')
80 files changed, 886 insertions, 300 deletions
diff --git a/extras/vom/vom/Makefile.am b/extras/vom/vom/Makefile.am index 6c24d01ce7c..f976b6fad90 100644 --- a/extras/vom/vom/Makefile.am +++ b/extras/vom/vom/Makefile.am @@ -127,6 +127,8 @@ libvom_la_SOURCES = \ neighbour_cmds.cpp \ object_base.cpp \ om.cpp \ + pipe.cpp \ + pipe_cmds.cpp \ prefix.cpp \ ra_config.cpp \ ra_prefix.cpp \ @@ -214,6 +216,7 @@ vominclude_HEADERS = \ neighbour.hpp \ object_base.hpp \ om.hpp \ + pipe.hpp \ prefix.hpp \ ra_config.hpp \ ra_prefix.hpp \ diff --git a/extras/vom/vom/acl_binding_cmds.cpp b/extras/vom/vom/acl_binding_cmds.cpp index 8c33cd47b79..062c1b90c9f 100644 --- a/extras/vom/vom/acl_binding_cmds.cpp +++ b/extras/vom/vom/acl_binding_cmds.cpp @@ -34,9 +34,7 @@ l3_bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> @@ -64,9 +62,7 @@ l3_unbind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> @@ -116,9 +112,7 @@ l2_bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> @@ -145,9 +139,7 @@ l2_unbind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> diff --git a/extras/vom/vom/acl_binding_cmds.hpp b/extras/vom/vom/acl_binding_cmds.hpp index b9af66e70c8..8515b4148ac 100644 --- a/extras/vom/vom/acl_binding_cmds.hpp +++ b/extras/vom/vom/acl_binding_cmds.hpp @@ -29,7 +29,7 @@ namespace binding_cmds { * A command class that binds the ACL to the interface */ template <typename BIND> -class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND> +class bind_cmd : public rpc_cmd<HW::item<bool>, BIND> { public: /** @@ -39,7 +39,7 @@ public: const direction_t& direction, const handle_t& itf, const handle_t& acl) - : rpc_cmd<HW::item<bool>, rc_t, BIND>(item) + : rpc_cmd<HW::item<bool>, BIND>(item) , m_direction(direction) , m_itf(itf) , m_acl(acl) @@ -85,7 +85,7 @@ private: * A command class that binds the ACL to the interface */ template <typename BIND> -class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, BIND> +class unbind_cmd : public rpc_cmd<HW::item<bool>, BIND> { public: /** @@ -95,7 +95,7 @@ public: const direction_t& direction, const handle_t& itf, const handle_t& acl) - : rpc_cmd<HW::item<bool>, rc_t, BIND>(item) + : rpc_cmd<HW::item<bool>, BIND>(item) , m_direction(direction) , m_itf(itf) , m_acl(acl) diff --git a/extras/vom/vom/acl_ethertype_cmds.cpp b/extras/vom/vom/acl_ethertype_cmds.cpp index c05a428c725..0fa1d6db73e 100644 --- a/extras/vom/vom/acl_ethertype_cmds.cpp +++ b/extras/vom/vom/acl_ethertype_cmds.cpp @@ -58,9 +58,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/acl_ethertype_cmds.hpp b/extras/vom/vom/acl_ethertype_cmds.hpp index f72a3fb97b5..a294a758056 100644 --- a/extras/vom/vom/acl_ethertype_cmds.hpp +++ b/extras/vom/vom/acl_ethertype_cmds.hpp @@ -28,9 +28,8 @@ namespace acl_ethertype_cmds { /** * A command class that binds the ethertype list to the interface */ -class bind_cmd : public rpc_cmd<HW::item<bool>, - rc_t, - vapi::Acl_interface_set_etype_whitelist> +class bind_cmd + : public rpc_cmd<HW::item<bool>, vapi::Acl_interface_set_etype_whitelist> { public: /** @@ -69,9 +68,8 @@ private: /** * A command class that unbinds the ethertype list to the interface */ -class unbind_cmd : public rpc_cmd<HW::item<bool>, - rc_t, - vapi::Acl_interface_set_etype_whitelist> +class unbind_cmd + : public rpc_cmd<HW::item<bool>, vapi::Acl_interface_set_etype_whitelist> { public: /** diff --git a/extras/vom/vom/acl_list_cmds.cpp b/extras/vom/vom/acl_list_cmds.cpp index 2e59763f4fe..343b2e5d513 100644 --- a/extras/vom/vom/acl_list_cmds.cpp +++ b/extras/vom/vom/acl_list_cmds.cpp @@ -74,7 +74,8 @@ l3_update_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); + if (m_hw_item.rc() == rc_t::OK) insert_acl(); @@ -140,7 +141,8 @@ l2_update_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); + if (m_hw_item.rc() == rc_t::OK) insert_acl(); diff --git a/extras/vom/vom/acl_list_cmds.hpp b/extras/vom/vom/acl_list_cmds.hpp index d24e75229de..ec69773f857 100644 --- a/extras/vom/vom/acl_list_cmds.hpp +++ b/extras/vom/vom/acl_list_cmds.hpp @@ -29,8 +29,7 @@ namespace list_cmds { * A command class that Create the list */ template <typename RULE, typename UPDATE> -class update_cmd - : public rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE> +class update_cmd : public rpc_cmd<HW::item<handle_t>, UPDATE> { public: typedef typename list<RULE>::rules_t cmd_rules_t; @@ -42,7 +41,7 @@ public: update_cmd(HW::item<handle_t>& item, const cmd_key_t& key, const cmd_rules_t& rules) - : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>(item) + : rpc_cmd<HW::item<handle_t>, UPDATE>(item) , m_key(key) , m_rules(rules) { @@ -78,7 +77,7 @@ public: void succeeded() { - rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, UPDATE>::succeeded(); + rpc_cmd<HW::item<handle_t>, UPDATE>::succeeded(); list<RULE>::add(m_key, this->item()); } @@ -124,14 +123,14 @@ private: * A cmd class that Deletes an ACL */ template <typename RULE, typename DELETE> -class delete_cmd : public rpc_cmd<HW::item<handle_t>, rc_t, DELETE> +class delete_cmd : public rpc_cmd<HW::item<handle_t>, DELETE> { public: /** * Constructor */ delete_cmd(HW::item<handle_t>& item) - : rpc_cmd<HW::item<handle_t>, rc_t, DELETE>(item) + : rpc_cmd<HW::item<handle_t>, DELETE>(item) { } diff --git a/extras/vom/vom/arp_proxy_binding_cmds.cpp b/extras/vom/vom/arp_proxy_binding_cmds.cpp index 2314d531add..6da956c1c38 100644 --- a/extras/vom/vom/arp_proxy_binding_cmds.cpp +++ b/extras/vom/vom/arp_proxy_binding_cmds.cpp @@ -41,9 +41,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/arp_proxy_binding_cmds.hpp b/extras/vom/vom/arp_proxy_binding_cmds.hpp index fcf0a4a2530..cafc1420f87 100644 --- a/extras/vom/vom/arp_proxy_binding_cmds.hpp +++ b/extras/vom/vom/arp_proxy_binding_cmds.hpp @@ -27,7 +27,7 @@ namespace arp_proxy_binding_cmds { * A command class that binds the LLDP config to the interface */ class bind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_enable_disable> + : public rpc_cmd<HW::item<bool>, vapi::Proxy_arp_intfc_enable_disable> { public: /** @@ -60,7 +60,7 @@ private: * A cmd class that Unbinds ArpProxy Config from an interface */ class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_intfc_enable_disable> + : public rpc_cmd<HW::item<bool>, vapi::Proxy_arp_intfc_enable_disable> { public: /** diff --git a/extras/vom/vom/arp_proxy_config_cmds.cpp b/extras/vom/vom/arp_proxy_config_cmds.cpp index 122c51bdb95..deb52c459b7 100644 --- a/extras/vom/vom/arp_proxy_config_cmds.cpp +++ b/extras/vom/vom/arp_proxy_config_cmds.cpp @@ -48,7 +48,7 @@ config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); + wait(); return (rc_t::OK); } diff --git a/extras/vom/vom/arp_proxy_config_cmds.hpp b/extras/vom/vom/arp_proxy_config_cmds.hpp index 77abc74556b..d1a0a420411 100644 --- a/extras/vom/vom/arp_proxy_config_cmds.hpp +++ b/extras/vom/vom/arp_proxy_config_cmds.hpp @@ -27,7 +27,7 @@ namespace arp_proxy_config_cmds { /** * A command class that adds the ARP Proxy config */ -class config_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del> +class config_cmd : public rpc_cmd<HW::item<bool>, vapi::Proxy_arp_add_del> { public: /** @@ -62,8 +62,7 @@ private: /** * A cmd class that Unconfigs ArpProxy Config from an interface */ -class unconfig_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Proxy_arp_add_del> +class unconfig_cmd : public rpc_cmd<HW::item<bool>, vapi::Proxy_arp_add_del> { public: /** diff --git a/extras/vom/vom/bond_group_binding.cpp b/extras/vom/vom/bond_group_binding.cpp index 60721dd4265..e5d4f3891b5 100644 --- a/extras/vom/vom/bond_group_binding.cpp +++ b/extras/vom/vom/bond_group_binding.cpp @@ -161,7 +161,7 @@ bond_group_binding::event_handler::order() const * We want enslaved interfaces bind to bond after interface * but before anything else. */ - return (dependency_t::BOND_BINDING); + return (dependency_t::VIRTUAL_INTERFACE); } void diff --git a/extras/vom/vom/bond_group_binding_cmds.cpp b/extras/vom/vom/bond_group_binding_cmds.cpp index 3ffe9810173..b257f776373 100644 --- a/extras/vom/vom/bond_group_binding_cmds.cpp +++ b/extras/vom/vom/bond_group_binding_cmds.cpp @@ -45,9 +45,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/bond_group_binding_cmds.hpp b/extras/vom/vom/bond_group_binding_cmds.hpp index 71c4f9fad64..3d9bfeedc61 100644 --- a/extras/vom/vom/bond_group_binding_cmds.hpp +++ b/extras/vom/vom/bond_group_binding_cmds.hpp @@ -26,7 +26,7 @@ namespace bond_group_binding_cmds { /** * A command class that binds the slave interface to the bond interface */ -class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bond_enslave> +class bind_cmd : public rpc_cmd<HW::item<bool>, vapi::Bond_enslave> { public: /** @@ -65,7 +65,7 @@ private: /** * A cmd class that detach slave from a bond interface */ -class unbind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bond_detach_slave> +class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Bond_detach_slave> { public: /** diff --git a/extras/vom/vom/bond_interface_cmds.cpp b/extras/vom/vom/bond_interface_cmds.cpp index d59560d4f5f..a43a832222a 100644 --- a/extras/vom/vom/bond_interface_cmds.cpp +++ b/extras/vom/vom/bond_interface_cmds.cpp @@ -51,7 +51,8 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); + if (m_hw_item.rc() == rc_t::OK) { insert_interface(); } diff --git a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp index 824dcadad02..d404d5d72d8 100644 --- a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp +++ b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp @@ -49,9 +49,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/bridge_domain_arp_entry_cmds.hpp b/extras/vom/vom/bridge_domain_arp_entry_cmds.hpp index 094de4c7fb6..9637e37a845 100644 --- a/extras/vom/vom/bridge_domain_arp_entry_cmds.hpp +++ b/extras/vom/vom/bridge_domain_arp_entry_cmds.hpp @@ -27,7 +27,7 @@ namespace bridge_domain_arp_entry_cmds { /** * A command class that creates or updates the bridge domain ARP Entry */ -class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Bd_ip_mac_add_del> { public: /** @@ -62,7 +62,7 @@ private: /** * A cmd class that deletes a bridge domain ARP entry */ -class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Bd_ip_mac_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Bd_ip_mac_add_del> { public: /** diff --git a/extras/vom/vom/bridge_domain_cmds.cpp b/extras/vom/vom/bridge_domain_cmds.cpp index d1d536f6d39..0e533be2899 100644 --- a/extras/vom/vom/bridge_domain_cmds.cpp +++ b/extras/vom/vom/bridge_domain_cmds.cpp @@ -55,9 +55,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string diff --git a/extras/vom/vom/bridge_domain_cmds.hpp b/extras/vom/vom/bridge_domain_cmds.hpp index 3257d83dc75..0ab1bfad95c 100644 --- a/extras/vom/vom/bridge_domain_cmds.hpp +++ b/extras/vom/vom/bridge_domain_cmds.hpp @@ -28,7 +28,7 @@ namespace bridge_domain_cmds { * A command class that creates an Bridge-Domain */ class create_cmd - : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del> + : public rpc_cmd<HW::item<uint32_t>, vapi::Bridge_domain_add_del> { public: /** @@ -77,7 +77,7 @@ private: * A cmd class that Delete an Bridge-Domain */ class delete_cmd - : public rpc_cmd<HW::item<uint32_t>, rc_t, vapi::Bridge_domain_add_del> + : public rpc_cmd<HW::item<uint32_t>, vapi::Bridge_domain_add_del> { public: /** diff --git a/extras/vom/vom/bridge_domain_entry_cmds.cpp b/extras/vom/vom/bridge_domain_entry_cmds.cpp index f2a3ed9c2cc..ffdd02de0d2 100644 --- a/extras/vom/vom/bridge_domain_entry_cmds.cpp +++ b/extras/vom/vom/bridge_domain_entry_cmds.cpp @@ -51,9 +51,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/bridge_domain_entry_cmds.hpp b/extras/vom/vom/bridge_domain_entry_cmds.hpp index dc46719ffda..dfee04f2a0d 100644 --- a/extras/vom/vom/bridge_domain_entry_cmds.hpp +++ b/extras/vom/vom/bridge_domain_entry_cmds.hpp @@ -28,7 +28,7 @@ namespace bridge_domain_entry_cmds { /** * A command class that creates or updates the bridge_domain */ -class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::L2fib_add_del> { public: /** @@ -65,7 +65,7 @@ private: /** * A cmd class that deletes a bridge_domain */ -class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2fib_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::L2fib_add_del> { public: /** diff --git a/extras/vom/vom/dhcp_client_cmds.cpp b/extras/vom/vom/dhcp_client_cmds.cpp index 181a15f8f96..9b632fe88f9 100644 --- a/extras/vom/vom/dhcp_client_cmds.cpp +++ b/extras/vom/vom/dhcp_client_cmds.cpp @@ -63,9 +63,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/dhcp_client_cmds.hpp b/extras/vom/vom/dhcp_client_cmds.hpp index e7db38f4e3b..89fe7eefa73 100644 --- a/extras/vom/vom/dhcp_client_cmds.hpp +++ b/extras/vom/vom/dhcp_client_cmds.hpp @@ -29,7 +29,7 @@ namespace dhcp_client_cmds { /** * A command class that binds the DHCP config to the interface */ -class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config> +class bind_cmd : public rpc_cmd<HW::item<bool>, vapi::Dhcp_client_config> { public: /** @@ -80,8 +80,7 @@ private: /** * A cmd class that Unbinds Dhcp Config from an interface */ -class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config> +class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Dhcp_client_config> { public: /** diff --git a/extras/vom/vom/event_cmd.hpp b/extras/vom/vom/event_cmd.hpp index a0e9b4af112..1120f75b399 100644 --- a/extras/vom/vom/event_cmd.hpp +++ b/extras/vom/vom/event_cmd.hpp @@ -36,14 +36,14 @@ namespace VOM { * The client can then 'pop' these events from this command object. */ template <typename WANT, typename EVENT> -class event_cmd : public rpc_cmd<HW::item<bool>, rc_t, WANT> +class event_cmd : public rpc_cmd<HW::item<bool>, WANT> { public: /** * Default constructor */ event_cmd(HW::item<bool>& b) - : rpc_cmd<HW::item<bool>, rc_t, WANT>(b) + : rpc_cmd<HW::item<bool>, WANT>(b) { } diff --git a/extras/vom/vom/gbp_contract_cmds.cpp b/extras/vom/vom/gbp_contract_cmds.cpp index a98dc62bc59..dea5350160d 100644 --- a/extras/vom/vom/gbp_contract_cmds.cpp +++ b/extras/vom/vom/gbp_contract_cmds.cpp @@ -49,9 +49,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -94,9 +92,7 @@ delete_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/gbp_contract_cmds.hpp b/extras/vom/vom/gbp_contract_cmds.hpp index 705c1a0a3db..31b9a00ed14 100644 --- a/extras/vom/vom/gbp_contract_cmds.hpp +++ b/extras/vom/vom/gbp_contract_cmds.hpp @@ -27,8 +27,7 @@ namespace gbp_contract_cmds { /** * A command class that creates or updates the GBP contract */ -class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_contract_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_contract_add_del> { public: /** @@ -63,8 +62,7 @@ private: /** * A cmd class that deletes a GBP contract */ -class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_contract_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_contract_add_del> { public: /** diff --git a/extras/vom/vom/gbp_endpoint_cmds.cpp b/extras/vom/vom/gbp_endpoint_cmds.cpp index 88d2f377bc7..1f9078f9b7f 100644 --- a/extras/vom/vom/gbp_endpoint_cmds.cpp +++ b/extras/vom/vom/gbp_endpoint_cmds.cpp @@ -54,9 +54,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -97,9 +95,7 @@ delete_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/gbp_endpoint_cmds.hpp b/extras/vom/vom/gbp_endpoint_cmds.hpp index 2893ef51eec..dea4c2c5605 100644 --- a/extras/vom/vom/gbp_endpoint_cmds.hpp +++ b/extras/vom/vom/gbp_endpoint_cmds.hpp @@ -27,8 +27,7 @@ namespace gbp_endpoint_cmds { /** * A command class that creates or updates the GBP endpoint */ -class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_endpoint_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_add_del> { public: /** @@ -65,8 +64,7 @@ private: /** * A cmd class that deletes a GBP endpoint */ -class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_endpoint_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_add_del> { public: /** diff --git a/extras/vom/vom/gbp_endpoint_group_cmds.cpp b/extras/vom/vom/gbp_endpoint_group_cmds.cpp index 55e81d3a528..a7b46f8a80b 100644 --- a/extras/vom/vom/gbp_endpoint_group_cmds.cpp +++ b/extras/vom/vom/gbp_endpoint_group_cmds.cpp @@ -53,9 +53,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -92,9 +90,7 @@ delete_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/gbp_endpoint_group_cmds.hpp b/extras/vom/vom/gbp_endpoint_group_cmds.hpp index 4da3a4247b4..4cf88cff116 100644 --- a/extras/vom/vom/gbp_endpoint_group_cmds.hpp +++ b/extras/vom/vom/gbp_endpoint_group_cmds.hpp @@ -28,7 +28,7 @@ namespace gbp_endpoint_group_cmds { * A command class that creates or updates the GBP endpoint_group */ class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_endpoint_group_add_del> + : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_group_add_del> { public: /** @@ -66,7 +66,7 @@ private: * A cmd class that deletes a GBP endpoint_group */ class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_endpoint_group_add_del> + : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_group_add_del> { public: /** diff --git a/extras/vom/vom/gbp_recirc_cmds.cpp b/extras/vom/vom/gbp_recirc_cmds.cpp index 757fcb99065..b14697c9f6f 100644 --- a/extras/vom/vom/gbp_recirc_cmds.cpp +++ b/extras/vom/vom/gbp_recirc_cmds.cpp @@ -49,9 +49,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -88,9 +86,7 @@ delete_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/gbp_recirc_cmds.hpp b/extras/vom/vom/gbp_recirc_cmds.hpp index fe17834ebf5..3c25d4495ca 100644 --- a/extras/vom/vom/gbp_recirc_cmds.hpp +++ b/extras/vom/vom/gbp_recirc_cmds.hpp @@ -27,8 +27,7 @@ namespace gbp_recirc_cmds { /** * A command class that creates or updates the GBP recirc */ -class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_recirc_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_recirc_add_del> { public: /** @@ -63,8 +62,7 @@ private: /** * A cmd class that deletes a GBP recirc */ -class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_recirc_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_recirc_add_del> { public: /** diff --git a/extras/vom/vom/gbp_subnet_cmds.cpp b/extras/vom/vom/gbp_subnet_cmds.cpp index d087e5c67d8..3816a596e6d 100644 --- a/extras/vom/vom/gbp_subnet_cmds.cpp +++ b/extras/vom/vom/gbp_subnet_cmds.cpp @@ -57,9 +57,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -105,9 +103,7 @@ delete_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/gbp_subnet_cmds.hpp b/extras/vom/vom/gbp_subnet_cmds.hpp index 3dbc8db2359..118303b7178 100644 --- a/extras/vom/vom/gbp_subnet_cmds.hpp +++ b/extras/vom/vom/gbp_subnet_cmds.hpp @@ -27,8 +27,7 @@ namespace gbp_subnet_cmds { /** * A command class that creates or updates the GBP subnet */ -class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_subnet_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_subnet_add_del> { public: /** @@ -67,8 +66,7 @@ private: /** * A cmd class that deletes a GBP subnet */ -class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Gbp_subnet_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_subnet_add_del> { public: /** diff --git a/extras/vom/vom/hw_cmds.cpp b/extras/vom/vom/hw_cmds.cpp index e628c354d71..429c123e9e9 100644 --- a/extras/vom/vom/hw_cmds.cpp +++ b/extras/vom/vom/hw_cmds.cpp @@ -30,9 +30,7 @@ poll::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string diff --git a/extras/vom/vom/hw_cmds.hpp b/extras/vom/vom/hw_cmds.hpp index b499ccecca0..c10f71e524c 100644 --- a/extras/vom/vom/hw_cmds.hpp +++ b/extras/vom/vom/hw_cmds.hpp @@ -27,7 +27,7 @@ namespace hw_cmds { /** *A command poll the HW for liveness */ -class poll : public rpc_cmd<HW::item<bool>, rc_t, vapi::Control_ping> +class poll : public rpc_cmd<HW::item<bool>, vapi::Control_ping> { public: /** diff --git a/extras/vom/vom/interface.hpp b/extras/vom/vom/interface.hpp index 92e14a791d6..a46b114833e 100644 --- a/extras/vom/vom/interface.hpp +++ b/extras/vom/vom/interface.hpp @@ -115,6 +115,16 @@ public: const static type_t BOND; /** + * pipe-parent type + */ + const static type_t PIPE; + + /** + * pipe-end type + */ + const static type_t PIPE_END; + + /** * Convert VPP's name of the interface to a type */ static type_t from_string(const std::string& str); @@ -271,11 +281,11 @@ public: * A base class for interface Create commands */ template <typename MSG> - class create_cmd : public rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG> + class create_cmd : public rpc_cmd<HW::item<handle_t>, MSG> { public: create_cmd(HW::item<handle_t>& item, const std::string& name) - : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG>(item) + : rpc_cmd<HW::item<handle_t>, MSG>(item) , m_name(name) { } @@ -298,7 +308,7 @@ public: */ void succeeded() { - rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG>::succeeded(); + rpc_cmd<HW::item<handle_t>, MSG>::succeeded(); interface::add(m_name, this->item()); } @@ -321,9 +331,7 @@ public: handle = sw_if_index; } - HW::item<handle_t> res(handle, rc); - - this->fulfill(res); + this->fulfill(HW::item<handle_t>(handle, rc)); return (VAPI_OK); } @@ -339,17 +347,17 @@ public: * Base class for intterface Delete commands */ template <typename MSG> - class delete_cmd : public rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG> + class delete_cmd : public rpc_cmd<HW::item<handle_t>, MSG> { public: delete_cmd(HW::item<handle_t>& item, const std::string& name) - : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG>(item) + : rpc_cmd<HW::item<handle_t>, MSG>(item) , m_name(name) { } delete_cmd(HW::item<handle_t>& item) - : rpc_cmd<HW::item<handle_t>, HW::item<handle_t>, MSG>(item) + : rpc_cmd<HW::item<handle_t>, MSG>(item) , m_name() { } @@ -471,6 +479,7 @@ protected: */ void set(const handle_t& handle); friend class interface_factory; + friend class pipe; /** * The SW interface handle VPP has asigned to the interface diff --git a/extras/vom/vom/interface_cmds.cpp b/extras/vom/vom/interface_cmds.cpp index e78ed46272d..9e2772584c0 100644 --- a/extras/vom/vom/interface_cmds.cpp +++ b/extras/vom/vom/interface_cmds.cpp @@ -37,7 +37,7 @@ loopback_create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); if (m_hw_item.rc() == rc_t::OK) { insert_interface(); @@ -74,7 +74,7 @@ af_packet_create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); if (m_hw_item.rc() == rc_t::OK) { insert_interface(); @@ -120,7 +120,7 @@ vhost_create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); if (m_hw_item.rc() == rc_t::OK) { insert_interface(); @@ -257,9 +257,7 @@ state_change_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -299,9 +297,7 @@ set_table_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string @@ -338,9 +334,7 @@ set_mac_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string @@ -380,9 +374,7 @@ collect_detail_stats_change_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string @@ -691,9 +683,7 @@ set_tag::issue(connection& con) VAPI_CALL(req.execute()); - wait(); - - return rc_t::OK; + return (wait()); } std::string set_tag::to_string() const diff --git a/extras/vom/vom/interface_cmds.hpp b/extras/vom/vom/interface_cmds.hpp index 1d0c4f543bc..b646e4ec9b8 100644 --- a/extras/vom/vom/interface_cmds.hpp +++ b/extras/vom/vom/interface_cmds.hpp @@ -177,7 +177,7 @@ public: * A command class to set tag on interfaces */ class set_tag - : public rpc_cmd<HW::item<handle_t>, rc_t, vapi::Sw_interface_tag_add_del> + : public rpc_cmd<HW::item<handle_t>, vapi::Sw_interface_tag_add_del> { public: /** @@ -211,7 +211,6 @@ private: * A cmd class that changes the admin state */ class state_change_cmd : public rpc_cmd<HW::item<interface::admin_state_t>, - rc_t, vapi::Sw_interface_set_flags> { public: @@ -246,9 +245,8 @@ private: /** * A command class that binds an interface to an L3 table */ -class set_table_cmd : public rpc_cmd<HW::item<route::table_id_t>, - rc_t, - vapi::Sw_interface_set_table> +class set_table_cmd + : public rpc_cmd<HW::item<route::table_id_t>, vapi::Sw_interface_set_table> { public: /** @@ -289,9 +287,8 @@ private: /** * A command class that changes the MAC address on an interface */ -class set_mac_cmd : public rpc_cmd<HW::item<l2_address_t>, - rc_t, - vapi::Sw_interface_set_mac_address> +class set_mac_cmd + : public rpc_cmd<HW::item<l2_address_t>, vapi::Sw_interface_set_mac_address> { public: /** @@ -327,7 +324,6 @@ private: */ class collect_detail_stats_change_cmd : public rpc_cmd<HW::item<interface::stats_type_t>, - rc_t, vapi::Collect_detailed_interface_stats> { public: @@ -474,9 +470,7 @@ private: * A command class represents our desire to recieve interface stats */ class stats_disable_cmd - : public rpc_cmd<HW::item<bool>, - rc_t, - vapi::Want_per_interface_combined_stats> + : public rpc_cmd<HW::item<bool>, vapi::Want_per_interface_combined_stats> { public: /** diff --git a/extras/vom/vom/interface_factory.cpp b/extras/vom/vom/interface_factory.cpp index c417c1cc3de..f4425130a4e 100644 --- a/extras/vom/vom/interface_factory.cpp +++ b/extras/vom/vom/interface_factory.cpp @@ -79,6 +79,12 @@ interface_factory::new_interface(const vapi_payload_sw_interface_details& vd) sp = interface::find(hdl); if (sp && !tag.empty()) sp->set(tag); + } else if (interface::type_t::PIPE == type) { + /* + * there's not enough information in a SW interface record to + * construct a pipe. so skip it. They have + * their own dump routines + */ } else if ((name.find(".") != std::string::npos) && (0 != vd.sub_id)) { /* * Sub-interface @@ -228,6 +234,24 @@ interface_factory::new_bond_member_interface( bond_member bm(*itf, mode, rate); return (bm); } + +std::shared_ptr<pipe> +interface_factory::new_pipe_interface(const vapi_payload_pipe_details& payload) +{ + std::shared_ptr<pipe> sp; + + handle_t hdl(payload.sw_if_index); + pipe::handle_pair_t hdl_pair(payload.pipe_sw_if_index[0], + payload.pipe_sw_if_index[1]); + + sp = pipe(payload.instance, interface::admin_state_t::UP).singular(); + + sp->set(hdl); + sp->set_ends(hdl_pair); + + return (sp); +} + }; // namespace VOM /* diff --git a/extras/vom/vom/interface_factory.hpp b/extras/vom/vom/interface_factory.hpp index 1bb60a899f0..120816bddba 100644 --- a/extras/vom/vom/interface_factory.hpp +++ b/extras/vom/vom/interface_factory.hpp @@ -18,13 +18,16 @@ #include <vapi/vapi.hpp> +#include "vom/bond_interface.hpp" #include "vom/bond_member.hpp" #include "vom/interface.hpp" +#include "vom/pipe.hpp" #include "vom/tap_interface.hpp" #include <vapi/af_packet.api.vapi.hpp> #include <vapi/bond.api.vapi.hpp> #include <vapi/interface.api.vapi.hpp> +#include <vapi/pipe.api.vapi.hpp> #include <vapi/tap.api.vapi.hpp> #include <vapi/tapv2.api.vapi.hpp> #include <vapi/vhost_user.api.vapi.hpp> @@ -57,6 +60,9 @@ public: static bond_member new_bond_member_interface( const vapi_payload_sw_interface_slave_details& vd); + + static std::shared_ptr<pipe> new_pipe_interface( + const vapi_payload_pipe_details& payload); }; }; diff --git a/extras/vom/vom/interface_ip6_nd.hpp b/extras/vom/vom/interface_ip6_nd.hpp index 22f545acdbb..fa5a479248c 100644 --- a/extras/vom/vom/interface_ip6_nd.hpp +++ b/extras/vom/vom/interface_ip6_nd.hpp @@ -131,14 +131,14 @@ public: /** * A functor class that binds the ra config to the interface */ - class config_cmd : public rpc_cmd<HW::item<bool>, rc_t, CMD> + class config_cmd : public rpc_cmd<HW::item<bool>, CMD> { public: /** * Constructor */ config_cmd(HW::item<bool>& item, const handle_t& itf, const class_t& cls) - : rpc_cmd<HW::item<bool>, rc_t, CMD>(item) + : rpc_cmd<HW::item<bool>, CMD>(item) , m_itf(itf) , m_cls(cls) { @@ -184,14 +184,14 @@ public: /** * A cmd class that Unbinds L3 Config from an interface */ - class unconfig_cmd : public rpc_cmd<HW::item<bool>, rc_t, CMD> + class unconfig_cmd : public rpc_cmd<HW::item<bool>, CMD> { public: /** * Constructor */ unconfig_cmd(HW::item<bool>& item, const handle_t& itf, const class_t& cls) - : rpc_cmd<HW::item<bool>, rc_t, CMD>(item) + : rpc_cmd<HW::item<bool>, CMD>(item) , m_itf(itf) , m_cls(cls) { diff --git a/extras/vom/vom/interface_ip6_nd_cmds.cpp b/extras/vom/vom/interface_ip6_nd_cmds.cpp index c6f53f04919..b8909637644 100644 --- a/extras/vom/vom/interface_ip6_nd_cmds.cpp +++ b/extras/vom/vom/interface_ip6_nd_cmds.cpp @@ -31,9 +31,7 @@ ip6nd_ra_config::config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> @@ -68,9 +66,7 @@ ip6nd_ra_prefix::config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } template <> diff --git a/extras/vom/vom/interface_span_cmds.cpp b/extras/vom/vom/interface_span_cmds.cpp index 3b8b8d25ec7..72bd6100bc0 100644 --- a/extras/vom/vom/interface_span_cmds.cpp +++ b/extras/vom/vom/interface_span_cmds.cpp @@ -51,9 +51,7 @@ config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/interface_span_cmds.hpp b/extras/vom/vom/interface_span_cmds.hpp index fa8096ebb10..e83ed728fb1 100644 --- a/extras/vom/vom/interface_span_cmds.hpp +++ b/extras/vom/vom/interface_span_cmds.hpp @@ -29,7 +29,7 @@ namespace interface_span_cmds { * A command class that configures the interface span */ class config_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_span_enable_disable> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable> { public: /** @@ -73,7 +73,7 @@ private: * A cmd class that Unconfigs interface span */ class unconfig_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_span_enable_disable> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_span_enable_disable> { public: /** diff --git a/extras/vom/vom/interface_types.cpp b/extras/vom/vom/interface_types.cpp index b20a3857146..73400373743 100644 --- a/extras/vom/vom/interface_types.cpp +++ b/extras/vom/vom/interface_types.cpp @@ -29,6 +29,8 @@ const interface::type_t interface::type_t::TAP(7, "TAP"); const interface::type_t interface::type_t::TAPV2(8, "TAPV2"); const interface::type_t interface::type_t::VHOST(9, "VHOST"); const interface::type_t interface::type_t::BOND(10, "Bond"); +const interface::type_t interface::type_t::PIPE(11, "Pipe"); +const interface::type_t interface::type_t::PIPE_END(12, "Pipe-end"); const interface::oper_state_t interface::oper_state_t::DOWN(0, "down"); const interface::oper_state_t interface::oper_state_t::UP(1, "up"); @@ -66,6 +68,8 @@ interface::type_t::from_string(const std::string& str) return interface::type_t::TAPV2; } else if (str.find("bvi") != std::string::npos) { return interface::type_t::BVI; + } else if (str.find("pipe") != std::string::npos) { + return interface::type_t::PIPE; } return interface::type_t::UNKNOWN; diff --git a/extras/vom/vom/ip_unnumbered_cmds.cpp b/extras/vom/vom/ip_unnumbered_cmds.cpp index fa7a1150cc4..227a1509e7e 100644 --- a/extras/vom/vom/ip_unnumbered_cmds.cpp +++ b/extras/vom/vom/ip_unnumbered_cmds.cpp @@ -47,9 +47,7 @@ config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/ip_unnumbered_cmds.hpp b/extras/vom/vom/ip_unnumbered_cmds.hpp index 40030139b8c..fdd00520404 100644 --- a/extras/vom/vom/ip_unnumbered_cmds.hpp +++ b/extras/vom/vom/ip_unnumbered_cmds.hpp @@ -29,7 +29,7 @@ namespace ip_unnumbered_cmds { *A command class that configures the IP unnumbered */ class config_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_unnumbered> { public: /** @@ -66,7 +66,7 @@ private: * A cmd class that Unconfigs L3 Config from an interface */ class unconfig_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_unnumbered> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_unnumbered> { public: /** diff --git a/extras/vom/vom/l2_binding_cmds.cpp b/extras/vom/vom/l2_binding_cmds.cpp index 0f91e4b3b7a..c072f67fd56 100644 --- a/extras/vom/vom/l2_binding_cmds.cpp +++ b/extras/vom/vom/l2_binding_cmds.cpp @@ -49,9 +49,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string @@ -142,9 +140,7 @@ set_vtr_op_cmd::issue(connection& con) VAPI_CALL(req.execute()); - wait(); - - return (rc_t::OK); + return (wait()); } std::string diff --git a/extras/vom/vom/l2_binding_cmds.hpp b/extras/vom/vom/l2_binding_cmds.hpp index d105c18a40d..3d138b1d1af 100644 --- a/extras/vom/vom/l2_binding_cmds.hpp +++ b/extras/vom/vom/l2_binding_cmds.hpp @@ -29,7 +29,7 @@ namespace l2_binding_cmds { * A functor class that binds L2 configuration to an interface */ class bind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge> { public: /** @@ -72,7 +72,7 @@ private: * A cmd class that Unbinds L2 configuration from an interface */ class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_bridge> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_bridge> { public: /** @@ -118,7 +118,6 @@ private: * A cmd class sets the VTR operation */ class set_vtr_op_cmd : public rpc_cmd<HW::item<l2_binding::l2_vtr_op_t>, - rc_t, vapi::L2_interface_vlan_tag_rewrite> { public: diff --git a/extras/vom/vom/l2_emulation_cmds.cpp b/extras/vom/vom/l2_emulation_cmds.cpp index 27f84830191..fac764a1c66 100644 --- a/extras/vom/vom/l2_emulation_cmds.cpp +++ b/extras/vom/vom/l2_emulation_cmds.cpp @@ -42,9 +42,7 @@ enable_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string diff --git a/extras/vom/vom/l2_emulation_cmds.hpp b/extras/vom/vom/l2_emulation_cmds.hpp index aeff3a8ddd7..aab4af51faa 100644 --- a/extras/vom/vom/l2_emulation_cmds.hpp +++ b/extras/vom/vom/l2_emulation_cmds.hpp @@ -27,7 +27,7 @@ namespace l2_emulation_cmds { /** * A functor class that enable L2 emulation to an interface */ -class enable_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2_emulation> +class enable_cmd : public rpc_cmd<HW::item<bool>, vapi::L2_emulation> { public: /** @@ -59,7 +59,7 @@ private: /** * A cmd class that Unbinds L2 configuration from an interface */ -class disable_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::L2_emulation> +class disable_cmd : public rpc_cmd<HW::item<bool>, vapi::L2_emulation> { public: /** diff --git a/extras/vom/vom/l2_xconnect_cmds.cpp b/extras/vom/vom/l2_xconnect_cmds.cpp index dc2c40c3b46..37eca9ecfc8 100644 --- a/extras/vom/vom/l2_xconnect_cmds.cpp +++ b/extras/vom/vom/l2_xconnect_cmds.cpp @@ -44,7 +44,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); + wait(); return (rc_t::OK); } diff --git a/extras/vom/vom/l2_xconnect_cmds.hpp b/extras/vom/vom/l2_xconnect_cmds.hpp index fbb869f025b..db0e721453f 100644 --- a/extras/vom/vom/l2_xconnect_cmds.hpp +++ b/extras/vom/vom/l2_xconnect_cmds.hpp @@ -30,7 +30,7 @@ namespace l2_xconnect_cmds { * A functor class that binds L2 configuration to an interface */ class bind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_xconnect> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_xconnect> { public: /** @@ -70,7 +70,7 @@ private: * A cmd class that Unbinds L2 configuration from an interface */ class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_l2_xconnect> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_l2_xconnect> { public: /** diff --git a/extras/vom/vom/l3_binding_cmds.cpp b/extras/vom/vom/l3_binding_cmds.cpp index 66691f86059..4afe13e1076 100644 --- a/extras/vom/vom/l3_binding_cmds.cpp +++ b/extras/vom/vom/l3_binding_cmds.cpp @@ -48,9 +48,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/l3_binding_cmds.hpp b/extras/vom/vom/l3_binding_cmds.hpp index 1387bc47f5d..b7a30f8865c 100644 --- a/extras/vom/vom/l3_binding_cmds.hpp +++ b/extras/vom/vom/l3_binding_cmds.hpp @@ -30,7 +30,7 @@ namespace l3_binding_cmds { * A functor class that binds the L3 config to the interface */ class bind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_add_del_address> { public: /** @@ -70,7 +70,7 @@ private: * A cmd class that Unbinds L3 Config from an interface */ class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_add_del_address> + : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_add_del_address> { public: /** diff --git a/extras/vom/vom/lldp_binding_cmds.cpp b/extras/vom/vom/lldp_binding_cmds.cpp index 7dacdafe20f..8c27579a643 100644 --- a/extras/vom/vom/lldp_binding_cmds.cpp +++ b/extras/vom/vom/lldp_binding_cmds.cpp @@ -49,9 +49,7 @@ bind_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/lldp_binding_cmds.hpp b/extras/vom/vom/lldp_binding_cmds.hpp index b3038017e06..77ba8ee90e7 100644 --- a/extras/vom/vom/lldp_binding_cmds.hpp +++ b/extras/vom/vom/lldp_binding_cmds.hpp @@ -28,8 +28,7 @@ namespace lldp_binding_cmds { /** *A command class that binds the LLDP config to the interface */ -class bind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp> +class bind_cmd : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_lldp> { public: /** @@ -68,8 +67,7 @@ private: /** * A cmd class that Unbinds Lldp Config from an interface */ -class unbind_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp> +class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Sw_interface_set_lldp> { public: /** diff --git a/extras/vom/vom/lldp_global_cmds.cpp b/extras/vom/vom/lldp_global_cmds.cpp index 8237114f789..7ea9b7895ea 100644 --- a/extras/vom/vom/lldp_global_cmds.cpp +++ b/extras/vom/vom/lldp_global_cmds.cpp @@ -48,9 +48,7 @@ config_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/lldp_global_cmds.hpp b/extras/vom/vom/lldp_global_cmds.hpp index 621e73ff71d..732c700062f 100644 --- a/extras/vom/vom/lldp_global_cmds.hpp +++ b/extras/vom/vom/lldp_global_cmds.hpp @@ -28,7 +28,7 @@ namespace lldp_global_cmds { /** * A command class that binds the LLDP global to the interface */ -class config_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Lldp_config> +class config_cmd : public rpc_cmd<HW::item<bool>, vapi::Lldp_config> { public: /** diff --git a/extras/vom/vom/nat_binding_cmds.cpp b/extras/vom/vom/nat_binding_cmds.cpp index 4d98268249a..d67a0828003 100644 --- a/extras/vom/vom/nat_binding_cmds.cpp +++ b/extras/vom/vom/nat_binding_cmds.cpp @@ -44,9 +44,7 @@ bind_44_input_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -86,9 +84,7 @@ unbind_44_input_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -128,9 +124,7 @@ bind_44_output_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -170,9 +164,7 @@ unbind_44_output_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -276,7 +268,7 @@ bind_66_input_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); + wait(); return rc_t::OK; } @@ -318,7 +310,7 @@ unbind_66_input_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); + wait(); return rc_t::OK; } diff --git a/extras/vom/vom/nat_binding_cmds.hpp b/extras/vom/vom/nat_binding_cmds.hpp index aa5a200515e..9b59d0dbd2c 100644 --- a/extras/vom/vom/nat_binding_cmds.hpp +++ b/extras/vom/vom/nat_binding_cmds.hpp @@ -28,7 +28,7 @@ namespace nat_binding_cmds { * A functor class that binds a NAT configuration to an input interface */ class bind_44_input_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_interface_add_del_feature> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_feature> { public: /** @@ -68,7 +68,7 @@ private: * A cmd class that unbinds a NAT configuration from an input interface */ class unbind_44_input_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_interface_add_del_feature> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_feature> { public: /** @@ -108,9 +108,7 @@ private: * A functor class that binds a NAT configuration to an output interface */ class bind_44_output_cmd - : public rpc_cmd<HW::item<bool>, - rc_t, - vapi::Nat44_interface_add_del_output_feature> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_output_feature> { public: /** @@ -150,9 +148,7 @@ private: * A cmd class that unbinds a NAT configuration from an output interface */ class unbind_44_output_cmd - : public rpc_cmd<HW::item<bool>, - rc_t, - vapi::Nat44_interface_add_del_output_feature> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_interface_add_del_output_feature> { public: /** @@ -260,7 +256,7 @@ private: * A functor class that binds a NAT configuration to an input interface */ class bind_66_input_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat66_add_del_interface> + : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_interface> { public: /** @@ -300,7 +296,7 @@ private: * A cmd class that unbinds a NAT configuration from an input interface */ class unbind_66_input_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat66_add_del_interface> + : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_interface> { public: /** diff --git a/extras/vom/vom/nat_static_cmds.cpp b/extras/vom/vom/nat_static_cmds.cpp index a80e47416ea..299f2f5f328 100644 --- a/extras/vom/vom/nat_static_cmds.cpp +++ b/extras/vom/vom/nat_static_cmds.cpp @@ -55,9 +55,7 @@ create_44_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -178,9 +176,7 @@ create_66_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/nat_static_cmds.hpp b/extras/vom/vom/nat_static_cmds.hpp index 95061cae1ad..8d514d85771 100644 --- a/extras/vom/vom/nat_static_cmds.hpp +++ b/extras/vom/vom/nat_static_cmds.hpp @@ -28,7 +28,7 @@ namespace nat_static_cmds { * A command class that creates NAT 44 static mapping */ class create_44_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_add_del_static_mapping> { public: /** @@ -64,7 +64,7 @@ private: * A cmd class that deletes a NAT 44 static mapping */ class delete_44_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat44_add_del_static_mapping> + : public rpc_cmd<HW::item<bool>, vapi::Nat44_add_del_static_mapping> { public: /** @@ -133,7 +133,7 @@ private: * A command class that creates NAT 66 static mapping */ class create_66_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat66_add_del_static_mapping> + : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_static_mapping> { public: /** @@ -169,7 +169,7 @@ private: * A cmd class that deletes a NAT 66 static mapping */ class delete_66_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Nat66_add_del_static_mapping> + : public rpc_cmd<HW::item<bool>, vapi::Nat66_add_del_static_mapping> { public: /** diff --git a/extras/vom/vom/neighbour_cmds.cpp b/extras/vom/vom/neighbour_cmds.cpp index 63534f3dd94..9bd32923379 100644 --- a/extras/vom/vom/neighbour_cmds.cpp +++ b/extras/vom/vom/neighbour_cmds.cpp @@ -49,9 +49,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/neighbour_cmds.hpp b/extras/vom/vom/neighbour_cmds.hpp index fe6dd155cd9..388dbf1b7ba 100644 --- a/extras/vom/vom/neighbour_cmds.hpp +++ b/extras/vom/vom/neighbour_cmds.hpp @@ -27,8 +27,8 @@ namespace neighbour_cmds { /** * A command class that creates or updates the bridge domain ARP Entry */ -class create_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, + vapi::Ip_neighbor_add_del> { public: /** @@ -63,8 +63,8 @@ private: /** * A cmd class that deletes a bridge domain ARP entry */ -class delete_cmd - : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_neighbor_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, + vapi::Ip_neighbor_add_del> { public: /** diff --git a/extras/vom/vom/pipe.cpp b/extras/vom/vom/pipe.cpp new file mode 100644 index 00000000000..9e10aeb4ea6 --- /dev/null +++ b/extras/vom/vom/pipe.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "vom/pipe.hpp" +#include "vom/interface_factory.hpp" +#include "vom/pipe_cmds.hpp" +#include "vom/singular_db_funcs.hpp" + +namespace VOM { + +typedef enum end_t_ { + EAST = 0, + WEST, +} end_t; +#define N_ENDS (WEST + 1) + +pipe::event_handler pipe::m_evh; + +static const std::string +pipe_mk_name(uint32_t instance) +{ + return ("pipe" + std::to_string(instance)); +} + +/** + * Construct a new object matching the desried state + */ +pipe::pipe(uint32_t instance, admin_state_t state) + : interface(pipe_mk_name(instance), type_t::PIPE, state) + , m_instance(instance) +{ +} + +pipe::~pipe() +{ + sweep(); + release(); +} + +pipe::pipe(const pipe& o) + : interface(o) + , m_instance(o.m_instance) +{ +} + +std::string +pipe::to_string(void) const +{ + std::ostringstream s; + + s << "[pipe: " << interface::to_string() << " instance:" << m_instance + << " ends:[" << m_hdl_pair.rc().to_string() << " " + << m_hdl_pair.data().first << ", " << m_hdl_pair.data().second << "]]"; + + return (s.str()); +} + +std::queue<cmd*>& +pipe::mk_create_cmd(std::queue<cmd*>& q) +{ + q.push(new pipe_cmds::create_cmd(m_hdl, m_name, m_instance, m_hdl_pair)); + + return (q); +} + +std::queue<cmd*>& +pipe::mk_delete_cmd(std::queue<cmd*>& q) +{ + q.push(new pipe_cmds::delete_cmd(m_hdl, m_hdl_pair)); + + return (q); +} + +std::shared_ptr<pipe> +pipe::singular() const +{ + return std::dynamic_pointer_cast<pipe>(singular_i()); +} + +std::shared_ptr<interface> +pipe::singular_i() const +{ + return m_db.find_or_add(key(), *this); +} + +std::shared_ptr<pipe> +pipe::find(const key_t& k) +{ + return std::dynamic_pointer_cast<pipe>(m_db.find(k)); +} + +std::shared_ptr<interface> +pipe::west() +{ + if (!m_ends[WEST]) { + if (rc_t::OK == m_hdl_pair.rc()) { + m_ends[WEST] = pipe_end(*this, WEST).singular(); + m_ends[WEST]->set(m_hdl_pair.data().first); + } + } + + return (m_ends[WEST]); +} + +std::shared_ptr<interface> +pipe::east() +{ + if (!m_ends[EAST]) { + if (rc_t::OK == m_hdl_pair.rc()) { + m_ends[EAST] = pipe_end(*this, EAST).singular(); + m_ends[EAST]->set(m_hdl_pair.data().first); + } + } + + return (m_ends[EAST]); +} + +pipe::pipe_end::pipe_end(const pipe& p, uint8_t id) + : interface(p.name() + "." + std::to_string(id), + interface::type_t::PIPE_END, + interface::admin_state_t::UP) + , m_pipe(p.singular()) +{ +} + +std::queue<cmd*>& +pipe::pipe_end::mk_create_cmd(std::queue<cmd*>& q) +{ + return (q); +} + +std::queue<cmd*>& +pipe::pipe_end::mk_delete_cmd(std::queue<cmd*>& q) +{ + return (q); +} + +void +pipe::set_ends(const handle_pair_t& p) +{ + if (handle_t::INVALID != p.first && handle_t::INVALID != p.second) { + m_hdl_pair = { p, rc_t::OK }; + } else { + m_hdl_pair = { p, rc_t::INVALID }; + } +} + +pipe::event_handler::event_handler() +{ + OM::register_listener(this); + inspect::register_handler({ "pipe" }, "pipes", this); +} + +void +pipe::event_handler::handle_replay() +{ + // m_db.replay(); +} + +void +pipe::event_handler::handle_populate(const client_db::key_t& key) +{ + std::shared_ptr<pipe_cmds::dump_cmd> cmd = + std::make_shared<pipe_cmds::dump_cmd>(); + + HW::enqueue(cmd); + HW::write(); + + for (auto& record : *cmd) { + std::shared_ptr<pipe> sp; + + sp = interface_factory::new_pipe_interface(record.get_payload()); + + VOM_LOG(log_level_t::DEBUG) << " pipe-dump: " << sp->to_string(); + OM::commit(key, *sp); + } +} + +dependency_t +pipe::event_handler::order() const +{ + return (dependency_t::VIRTUAL_INTERFACE); +} + +void +pipe::event_handler::show(std::ostream& os) +{ + db_dump(m_db, os); +} + +}; // namespace VOM + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */ diff --git a/extras/vom/vom/pipe.hpp b/extras/vom/vom/pipe.hpp new file mode 100644 index 00000000000..7da3a1f162a --- /dev/null +++ b/extras/vom/vom/pipe.hpp @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __VOM_PIPE_H__ +#define __VOM_PIPE_H__ + +#include "vom/interface.hpp" + +namespace VOM { +/** + * A Pipe interface. + * A pipe is composed for 3 'interfaces'. + * 1) the 'parent' interface - this is used as the 'key' for the pipe + * 2) the two 'ends' of the pipe - these are used to RX/TX packets + * form/to. The ends are retreivable using the east()/west() functions. + * The east and west end are exactly equivalent, they are merely + * named differently for logical purposes. + */ +class pipe : public interface +{ +public: + typedef std::pair<handle_t, handle_t> handle_pair_t; + + /** + * Construct a new object matching the desried state + */ + pipe(uint32_t instance, admin_state_t state); + + /** + * Destructor + */ + ~pipe(); + + /** + * Copy Constructor + */ + pipe(const pipe& o); + + /** + * comparison operator - for UT + */ + bool operator==(const pipe& s) const; + + /** + * Return the matching 'singular instance' of the sub-interface + */ + std::shared_ptr<pipe> singular() const; + + /** + * Find a subinterface from its key + */ + static std::shared_ptr<pipe> find(const key_t& k); + + /** + * The interface that is the east end of the pipe + */ + std::shared_ptr<interface> east(); + + /** + * The interface that is the west end of the pipe. + * The east and west end are exactly equivalent, they are merely + * named differently for logical purposes. + */ + std::shared_ptr<interface> west(); + + virtual std::string to_string(void) const; + + void set_ends(const handle_pair_t& p); + +private: + /** + * The interface type that forms the ends of the pipe + */ + class pipe_end : public interface + { + public: + pipe_end(const pipe& p, uint8_t id); + + private: + virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds); + virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds); + + std::shared_ptr<pipe> m_pipe; + }; + + /** +*Class definition for listeners to OM events +*/ + class event_handler : public OM::listener, public inspect::command_handler + { + public: + event_handler(); + virtual ~event_handler() = default; + + /** + * Handle a populate event + */ + void handle_populate(const client_db::key_t& key); + + /** + * Handle a replay event + */ + void handle_replay(); + + /** + * Show the object in the Singular DB + */ + void show(std::ostream& os); + + /** + * Get the sortable Id of the listener + */ + dependency_t order() const; + }; + static event_handler m_evh; + + /** + * Return the matching 'instance' of the pipe + * over-ride from the base class + */ + std::shared_ptr<interface> singular_i() const; + + /** + * Virtual functions to construct an interface create commands. + */ + virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds); + + /** + * Virtual functions to construct an interface delete commands. + */ + virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds); + + /** + * the handles that are set during the create command + */ + HW::item<handle_pair_t> m_hdl_pair; + + /** + * The ends of the pipe + */ + std::shared_ptr<interface> m_ends[2]; + + /** + * Instance number + */ + uint32_t m_instance; +}; + +}; // namespace VOM + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */ + +#endif diff --git a/extras/vom/vom/pipe_cmds.cpp b/extras/vom/vom/pipe_cmds.cpp new file mode 100644 index 00000000000..9215efe635f --- /dev/null +++ b/extras/vom/vom/pipe_cmds.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2018 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "vom/pipe_cmds.hpp" + +DEFINE_VAPI_MSG_IDS_PIPE_API_JSON; + +namespace VOM { +namespace pipe_cmds { + +create_cmd::create_cmd(HW::item<handle_t>& item, + const std::string& name, + uint32_t instance, + HW::item<pipe::handle_pair_t>& ends) + : interface::create_cmd<vapi::Pipe_create>(item, name) + , m_hdl_pair(ends) + , m_instance(instance) +{ +} + +bool +create_cmd::operator==(const create_cmd& other) const +{ + return (m_name == other.m_name); +} + +vapi_error_e +create_cmd::operator()(vapi::Pipe_create& reply) +{ + auto& payload = reply.get_response().get_payload(); + + VOM_LOG(log_level_t::DEBUG) << to_string() << " " << payload.retval; + + const rc_t& rc = rc_t::from_vpp_retval(payload.retval); + + m_hdl_pair = { pipe::handle_pair_t(payload.pipe_sw_if_index[0], + payload.pipe_sw_if_index[1]), + rc }; + + fulfill(HW::item<handle_t>(payload.sw_if_index, rc)); + + return (VAPI_OK); +} +rc_t +create_cmd::issue(connection& con) +{ + msg_t req(con.ctx(), std::ref(*this)); + + auto& payload = req.get_request().get_payload(); + + payload.is_specified = 1; + payload.user_instance = m_instance; + + VAPI_CALL(req.execute()); + + if (rc_t::OK == wait()) { + insert_interface(); + } + + return rc_t::OK; +} + +std::string +create_cmd::to_string() const +{ + std::ostringstream s; + + s << "pipe-create: " << m_name << " instance:" << m_instance; + + return (s.str()); +} + +delete_cmd::delete_cmd(HW::item<handle_t>& item, + HW::item<pipe::handle_pair_t>& end_pair) + : interface::delete_cmd<vapi::Pipe_delete>(item) + , m_hdl_pair(end_pair) +{ +} + +bool +delete_cmd::operator==(const delete_cmd& other) const +{ + return (m_hw_item == other.m_hw_item); +} + +rc_t +delete_cmd::issue(connection& con) +{ + msg_t req(con.ctx(), std::ref(*this)); + + VAPI_CALL(req.execute()); + + wait(); + m_hw_item.set(rc_t::NOOP); + m_hdl_pair.set(rc_t::NOOP); + + remove_interface(); + + return (rc_t::OK); +} + +std::string +delete_cmd::to_string() const +{ + return ("pipe-delete"); +} + +bool +dump_cmd::operator==(const dump_cmd& other) const +{ + return (true); +} + +rc_t +dump_cmd::issue(connection& con) +{ + m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); + + VAPI_CALL(m_dump->execute()); + + wait(); + + return rc_t::OK; +} + +std::string +dump_cmd::to_string() const +{ + return ("pipe-dump"); +} + +} // namespace pipe_cmds +} // namespace VOM + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */ diff --git a/extras/vom/vom/pipe_cmds.hpp b/extras/vom/vom/pipe_cmds.hpp new file mode 100644 index 00000000000..8c26fd60fd3 --- /dev/null +++ b/extras/vom/vom/pipe_cmds.hpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __VOM_PIPE_CMDS_H__ +#define __VOM_PIPE_CMDS_H__ + +#include "vom/dump_cmd.hpp" +#include "vom/pipe.hpp" +#include "vom/rpc_cmd.hpp" + +#include <vapi/pipe.api.vapi.hpp> + +namespace VOM { +namespace pipe_cmds { +/** + * A functor class that creates an interface + */ +class create_cmd : public interface::create_cmd<vapi::Pipe_create> +{ +public: + /** + * Cstrunctor taking the reference to the parent + * and the sub-interface's VLAN + */ + create_cmd(HW::item<handle_t>& item, + const std::string& name, + uint32_t instance, + HW::item<pipe::handle_pair_t>& ends); + + /** + * Issue the command to VPP/HW + */ + rc_t issue(connection& con); + + /** + * convert to string format for debug purposes + */ + std::string to_string() const; + + /** + * Comparison operator - only used for UT + */ + bool operator==(const create_cmd& i) const; + + virtual vapi_error_e operator()(vapi::Pipe_create& reply); + +private: + HW::item<pipe::handle_pair_t>& m_hdl_pair; + uint32_t m_instance; +}; + +/** + * A cmd class that Delete an interface + */ +class delete_cmd : public interface::delete_cmd<vapi::Pipe_delete> +{ +public: + /** + * Constructor + */ + delete_cmd(HW::item<handle_t>& item, HW::item<pipe::handle_pair_t>& end_pair); + + /** + * Issue the command to VPP/HW + */ + rc_t issue(connection& con); + + /** + * convert to string format for debug purposes + */ + std::string to_string() const; + + /** + * Comparison operator - only used for UT + */ + bool operator==(const delete_cmd& i) const; + +private: + HW::item<pipe::handle_pair_t>& m_hdl_pair; +}; + +/** + * A cmd class that Dumps all the Vpp interfaces + */ +class dump_cmd : public VOM::dump_cmd<vapi::Pipe_dump> +{ +public: + /** + * Default Constructor + */ + dump_cmd() = default; + + /** + * Issue the command to VPP/HW + */ + rc_t issue(connection& con); + /** + * convert to string format for debug purposes + */ + std::string to_string() const; + + /** + * Comparison operator - only used for UT + */ + bool operator==(const dump_cmd& i) const; +}; + +}; // namespace pipe_cmds +}; // namespace VOM + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */ + +#endif diff --git a/extras/vom/vom/route_cmds.cpp b/extras/vom/vom/route_cmds.cpp index 83d44ccc01d..240592f909f 100644 --- a/extras/vom/vom/route_cmds.cpp +++ b/extras/vom/vom/route_cmds.cpp @@ -100,9 +100,7 @@ update_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string diff --git a/extras/vom/vom/route_cmds.hpp b/extras/vom/vom/route_cmds.hpp index f2c10ff60ad..2e6ce73068c 100644 --- a/extras/vom/vom/route_cmds.hpp +++ b/extras/vom/vom/route_cmds.hpp @@ -29,7 +29,7 @@ namespace ip_route_cmds { /** * A command class that creates or updates the route */ -class update_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route> +class update_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_add_del_route> { public: /** @@ -64,7 +64,7 @@ private: /** * A cmd class that deletes a route */ -class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_add_del_route> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_add_del_route> { public: /** diff --git a/extras/vom/vom/route_domain_cmds.cpp b/extras/vom/vom/route_domain_cmds.cpp index 845497f5989..9eb50436cc2 100644 --- a/extras/vom/vom/route_domain_cmds.cpp +++ b/extras/vom/vom/route_domain_cmds.cpp @@ -45,9 +45,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return (rc_t::OK); + return (wait()); } std::string diff --git a/extras/vom/vom/route_domain_cmds.hpp b/extras/vom/vom/route_domain_cmds.hpp index f3911bd59f0..6ac679bd343 100644 --- a/extras/vom/vom/route_domain_cmds.hpp +++ b/extras/vom/vom/route_domain_cmds.hpp @@ -27,7 +27,7 @@ namespace route_domain_cmds { /** * A command class that creates the IP table */ -class create_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del> +class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_table_add_del> { public: /** @@ -65,7 +65,7 @@ private: /** * A cmd class that Deletes the IP Table */ -class delete_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Ip_table_add_del> +class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Ip_table_add_del> { public: /** diff --git a/extras/vom/vom/rpc_cmd.hpp b/extras/vom/vom/rpc_cmd.hpp index 84b6717c53b..1996f4b3fbe 100644 --- a/extras/vom/vom/rpc_cmd.hpp +++ b/extras/vom/vom/rpc_cmd.hpp @@ -34,7 +34,7 @@ namespace VOM { * The command is templatised on the type of the HW::item to be set by * the command, and the data returned in the promise, */ -template <typename HWITEM, typename DATA, typename MSG> +template <typename HWITEM, typename MSG> class rpc_cmd : public cmd { public: @@ -71,34 +71,27 @@ public: /** * Fulfill the commands promise. Called from the RX thread */ - void fulfill(const DATA& d) - { - m_promise.set_value(d); - - /* - * we reset the promise after setting the value to reuse it - * when we run the retire command from the same cmd object - */ - // m_promise = std::promise<DATA>(); - } + void fulfill(const HWITEM& d) { m_promise.set_value(d); } /** * Wait on the commands promise. i.e. block on the completion * of the command. */ - DATA wait() + rc_t wait() { std::future_status status; - std::future<DATA> result; + std::future<HWITEM> result; result = m_promise.get_future(); status = result.wait_for(std::chrono::seconds(5)); if (status != std::future_status::ready) { - return (DATA(rc_t::TIMEOUT)); + m_hw_item.set(rc_t::TIMEOUT); + } else { + m_hw_item = result.get(); } - return (result.get()); + return (m_hw_item.rc()); } /** @@ -116,9 +109,13 @@ public: */ virtual vapi_error_e operator()(MSG& reply) { + HWITEM hi = m_hw_item; int retval = reply.get_response().get_payload().retval; VOM_LOG(log_level_t::DEBUG) << to_string() << " " << retval; - fulfill(rc_t::from_vpp_retval(retval)); + + /* set a temporary value in this callback thread */ + hi.set(rc_t::from_vpp_retval(retval)); + fulfill(hi); return (VAPI_OK); } @@ -137,7 +134,7 @@ protected: /** * The promise that implements the synchronous issue */ - std::promise<DATA> m_promise; + std::promise<HWITEM> m_promise; }; }; diff --git a/extras/vom/vom/sub_interface_cmds.cpp b/extras/vom/vom/sub_interface_cmds.cpp index 47af69268d1..853a9b63698 100644 --- a/extras/vom/vom/sub_interface_cmds.cpp +++ b/extras/vom/vom/sub_interface_cmds.cpp @@ -49,7 +49,7 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); if (m_hw_item.rc() == rc_t::OK) { insert_interface(); diff --git a/extras/vom/vom/tap_interface_cmds.cpp b/extras/vom/vom/tap_interface_cmds.cpp index 763ded56bdc..4ebd2be4cf0 100644 --- a/extras/vom/vom/tap_interface_cmds.cpp +++ b/extras/vom/vom/tap_interface_cmds.cpp @@ -61,12 +61,12 @@ tap_create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); if (m_hw_item.rc() == rc_t::OK) { insert_interface(); } - return rc_t::OK; + return (m_hw_item.rc()); } std::string diff --git a/extras/vom/vom/types.hpp b/extras/vom/vom/types.hpp index 53654c51ac5..7b08d831352 100644 --- a/extras/vom/vom/types.hpp +++ b/extras/vom/vom/types.hpp @@ -53,15 +53,9 @@ enum class dependency_t INTERFACE, /** - * bond group binding is after interfaces but before - * anything else + * virtual interfaces - those that depend on some real interface */ - BOND_BINDING, - - /** - * Tunnel or virtual interfaces next - */ - TUNNEL, + VIRTUAL_INTERFACE, /** * Tables in which entries are added, e.g bridge/route-domains @@ -89,8 +83,6 @@ enum class dependency_t */ struct rc_t : public enum_base<rc_t> { - rc_t(const rc_t& rc) = default; - /** * Destructor */ diff --git a/extras/vom/vom/vxlan_tunnel.cpp b/extras/vom/vom/vxlan_tunnel.cpp index 3d5ed64c5e0..9e7c01d01c6 100644 --- a/extras/vom/vom/vxlan_tunnel.cpp +++ b/extras/vom/vom/vxlan_tunnel.cpp @@ -246,7 +246,7 @@ vxlan_tunnel::event_handler::handle_replay() dependency_t vxlan_tunnel::event_handler::order() const { - return (dependency_t::TUNNEL); + return (dependency_t::VIRTUAL_INTERFACE); } void diff --git a/extras/vom/vom/vxlan_tunnel_cmds.cpp b/extras/vom/vom/vxlan_tunnel_cmds.cpp index ca4ccf3c38a..dcc06e71797 100644 --- a/extras/vom/vom/vxlan_tunnel_cmds.cpp +++ b/extras/vom/vom/vxlan_tunnel_cmds.cpp @@ -51,9 +51,9 @@ create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); - if (m_hw_item) { + if (rc_t::OK == m_hw_item.rc()) { insert_interface(); } |