X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Fext%2Fvom_test.cpp;h=69de5f1ad3dfa4522efb7b2450fa3debd7880390;hb=7c03ed4;hp=4c09ab4439cccbf50cda34482666e52f3962b5da;hpb=d91d14095b8ac0d3151fd8f6b03277d447029814;p=vpp.git diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 4c09ab4439c..69de5f1ad3d 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -20,8 +20,13 @@ #include "vom/om.hpp" #include "vom/interface.hpp" #include "vom/interface_cmds.hpp" +#include "vom/bond_interface_cmds.hpp" +#include "vom/bond_group_binding.hpp" +#include "vom/bond_group_binding_cmds.hpp" #include "vom/l2_binding.hpp" #include "vom/l2_binding_cmds.hpp" +#include "vom/l2_xconnect.hpp" +#include "vom/l2_xconnect_cmds.hpp" #include "vom/l3_binding.hpp" #include "vom/l3_binding_cmds.hpp" #include "vom/bridge_domain.hpp" @@ -33,6 +38,7 @@ #include "vom/prefix.hpp" #include "vom/route.hpp" #include "vom/route_cmds.hpp" +#include "vom/mroute_cmds.hpp" #include "vom/route_domain.hpp" #include "vom/route_domain_cmds.hpp" #include "vom/vxlan_tunnel.hpp" @@ -51,6 +57,12 @@ #include "vom/arp_proxy_binding.hpp" #include "vom/arp_proxy_config_cmds.hpp" #include "vom/arp_proxy_binding_cmds.hpp" +#include "vom/igmp_binding.hpp" +#include "vom/igmp_binding_cmds.hpp" +#include "vom/igmp_listen.hpp" +#include "vom/igmp_listen_cmds.hpp" +#include "vom/ip_punt_redirect.hpp" +#include "vom/ip_punt_redirect_cmds.hpp" #include "vom/ip_unnumbered.hpp" #include "vom/ip_unnumbered_cmds.hpp" #include "vom/interface_ip6_nd.hpp" @@ -62,6 +74,8 @@ #include "vom/nat_static_cmds.hpp" #include "vom/nat_binding.hpp" #include "vom/nat_binding_cmds.hpp" +#include "vom/pipe.hpp" +#include "vom/pipe_cmds.hpp" using namespace boost; using namespace VOM; @@ -82,10 +96,10 @@ public: class MockListener : public interface::event_listener, public interface::stat_listener { - void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd) + void handle_interface_stat(const interface& itf) { } - void handle_interface_event(interface_cmds::events_cmd *cmd) + void handle_interface_event(std::vector events) { } }; @@ -174,6 +188,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd)) { rc = handle_derived(f_exp, f_act); @@ -182,6 +204,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd)) { rc = handle_derived(f_exp, f_act); @@ -198,6 +228,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd)) { rc = handle_derived(f_exp, f_act); @@ -214,6 +252,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::update_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd)) { rc = handle_derived(f_exp, f_act); @@ -266,6 +312,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::unbind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd)) { rc = handle_derived(f_exp, f_act); @@ -286,6 +340,10 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd)) { rc = handle_derived(f_exp, f_act); @@ -334,6 +392,30 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(igmp_binding_cmds::bind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(igmp_binding_cmds::unbind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(igmp_listen_cmds::listen_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(igmp_listen_cmds::unlisten_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::config_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::unconfig_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd)) { rc = handle_derived(f_exp, f_act); @@ -386,6 +468,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else { throw ExpException(2); @@ -605,12 +695,15 @@ BOOST_AUTO_TEST_CASE(test_interface) { TRY_CHECK(OM::mark(go)); std::string itf2_name = "afpacket2"; + std::string itf2_tag = "uuid-of-afpacket2-interface"; interface itf2(itf2_name, interface::type_t::AFPACKET, - interface::admin_state_t::UP); + interface::admin_state_t::UP, + itf2_tag); HW::item hw_ifh2(3, rc_t::OK); ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag)); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); TRY_CHECK_RC(OM::write(go, itf2)); @@ -623,6 +716,23 @@ BOOST_AUTO_TEST_CASE(test_interface) { ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); TRY_CHECK(OM::sweep(go)); + + + std::string itf3_name = "/PATH/TO/vhost_user1.sock"; + std::string itf3_tag = "uuid-of-vhost_user1-interface"; + interface itf3(itf3_name, + interface::type_t::VHOST, + interface::admin_state_t::UP, + itf3_tag); + HW::item hw_ifh3(4, rc_t::OK); + + ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3)); + TRY_CHECK_RC(OM::write(go, itf3)); + + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3)); + ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name)); + TRY_CHECK(OM::remove(go)); } BOOST_AUTO_TEST_CASE(test_bvi) { @@ -738,6 +848,80 @@ BOOST_AUTO_TEST_CASE(test_bvi) { TRY_CHECK(OM::remove(graham)); } +BOOST_AUTO_TEST_CASE(test_bond) { + VppInit vi; + const std::string cb = "CarolBerg"; + rc_t rc = rc_t::OK; + + /* + * creates the interfaces + */ + std::string itf1_name = "afpacket1"; + interface itf1(itf1_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + + HW::item hw_ifh(2, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); + + HW::item hw_as_up(interface::admin_state_t::UP, rc_t::OK); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); + + TRY_CHECK_RC(OM::write(cb, itf1)); + + std::string itf2_name = "afpacket2"; + interface itf2(itf2_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + + + HW::item hw_ifh2(4, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); + + TRY_CHECK_RC(OM::write(cb, itf2)); + + std::string bond_name = "bond"; + bond_interface bond_itf(bond_name, interface::admin_state_t::UP, + bond_interface::mode_t::LACP); + + HW::item hw_ifh3(6, rc_t::OK); + ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name, + bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3)); + + TRY_CHECK_RC(OM::write(cb, bond_itf)); + + bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE, + bond_member::rate_t::SLOW); + bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE, + bond_member::rate_t::SLOW); + bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2}); + + HW::item bond_hw_bind(true, rc_t::OK); + ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1)); + ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2)); + + TRY_CHECK_RC(OM::write(cb, *bgb)); + + delete bgb; + delete bm2; + delete bm1; + + STRICT_ORDER_OFF(); + HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); + ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data())); + ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data())); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3)); + ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); + + TRY_CHECK(OM::remove(cb)); +} + BOOST_AUTO_TEST_CASE(test_bridge) { VppInit vi; const std::string franz = "FranzKafka"; @@ -767,7 +951,11 @@ BOOST_AUTO_TEST_CASE(test_bridge) { bridge_domain bd1(33); HW::item hw_bd(33, rc_t::OK); - ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::ON)); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, + bridge_domain::learning_mode_t::ON, + bridge_domain::arp_term_mode_t::ON, + bridge_domain::flood_mode_t::ON, + bridge_domain::mac_age_mode_t::OFF)); TRY_CHECK_RC(OM::write(franz, bd1)); @@ -777,7 +965,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { l2_binding *l2itf = new l2_binding(itf1, bd1); HW::item hw_l2_bind(true, rc_t::OK); - ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, + hw_ifh.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); TRY_CHECK_RC(OM::write(franz, *l2itf)); /* @@ -800,7 +991,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { HW::item hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK); l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68); - ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, + hw_ifh2.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68)); TRY_CHECK_RC(OM::write(dante, *l2itf2)); @@ -824,7 +1018,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { delete l2itf; HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); - ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, + hw_ifh.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); TRY_CHECK(OM::remove(franz)); @@ -837,7 +1034,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { STRICT_ORDER_OFF(); ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1)); ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false)); - ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, + hw_ifh2.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); @@ -848,7 +1048,11 @@ BOOST_AUTO_TEST_CASE(test_bridge) { bridge_domain bd2(99); HW::item hw_bd2(99, rc_t::OK); - ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2, bridge_domain::learning_mode_t::ON)); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2, + bridge_domain::learning_mode_t::ON, + bridge_domain::arp_term_mode_t::ON, + bridge_domain::flood_mode_t::ON, + bridge_domain::mac_age_mode_t::OFF)); TRY_CHECK_RC(OM::write(jkr, bd2)); @@ -864,7 +1068,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { TRY_CHECK_RC(OM::write(jkr, itf3)); l2_binding *l2itf3 = new l2_binding(itf3, bd2); - ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true)); + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, + hw_ifh3.data(), + hw_bd2.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI)); TRY_CHECK_RC(OM::write(jkr, *l2itf3)); HW::item hw_be2(true, rc_t::OK); @@ -876,7 +1083,10 @@ BOOST_AUTO_TEST_CASE(test_bridge) { delete l2itf3; delete be2; STRICT_ORDER_OFF(); - ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, + hw_ifh3.data(), + hw_bd2.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI)); ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true)); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3)); ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3)); @@ -884,6 +1094,60 @@ BOOST_AUTO_TEST_CASE(test_bridge) { TRY_CHECK(OM::remove(jkr)); } +BOOST_AUTO_TEST_CASE(test_l2_xconnect) { + VppInit vi; + const std::string nicholas = "NicholasAbercrombie"; + rc_t rc = rc_t::OK; + + /* + * Interface 1 + */ + std::string itf1_name = "host1"; + interface itf1(itf1_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + HW::item hw_ifh(2, rc_t::OK); + HW::item hw_as_up(interface::admin_state_t::UP, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); + TRY_CHECK_RC(OM::write(nicholas, itf1)); + + /* + * Interface 2 + */ + std::string itf2_name = "host2"; + interface itf2(itf2_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + + HW::item hw_ifh2(4, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); + TRY_CHECK_RC(OM::write(nicholas, itf2)); + + l2_xconnect *l2_xconn = new l2_xconnect(itf1, itf2); + HW::item xconnect_east(true, rc_t::OK); + HW::item xconnect_west(true, rc_t::OK); + HW::item xconnect_east_unbind(false, rc_t::OK); + HW::item xconnect_west_unbind(false, rc_t::OK); + ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_east, hw_ifh.data(), hw_ifh2.data())); + ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_west, hw_ifh2.data(), hw_ifh.data())); + TRY_CHECK_RC(OM::write(nicholas, *l2_xconn)); + + delete l2_xconn; + + HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); + STRICT_ORDER_OFF(); + ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_east_unbind, hw_ifh.data(), hw_ifh2.data())); + ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_west_unbind, hw_ifh2.data(), hw_ifh.data())); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); + + TRY_CHECK(OM::remove(nicholas)); +} + BOOST_AUTO_TEST_CASE(test_vxlan) { VppInit vi; const std::string franz = "FranzKafka"; @@ -895,21 +1159,29 @@ BOOST_AUTO_TEST_CASE(test_vxlan) { // VXLAN create vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"), - boost::asio::ip::address::from_string("10.10.10.11"), - 322); + boost::asio::ip::address::from_string("10.10.10.11"), + 322); vxlan_tunnel vxt(ep.src, ep.dst, ep.vni); HW::item hw_vxt(3, rc_t::OK); - ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep)); + ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep, + handle_t::INVALID)); TRY_CHECK_RC(OM::write(franz, vxt)); // bridge-domain create - bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF); + bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON); HW::item hw_bd(33, rc_t::OK); - ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::OFF)); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, + bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON)); TRY_CHECK_RC(OM::write(franz, bd1)); @@ -919,14 +1191,20 @@ BOOST_AUTO_TEST_CASE(test_vxlan) { l2_binding *l2itf = new l2_binding(vxt, bd1); HW::item hw_l2_bind(true, rc_t::OK); - ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, + hw_vxt.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); TRY_CHECK_RC(OM::write(franz, *l2itf)); // flush Franz's state delete l2itf; HW::item hw_vxtdel(3, rc_t::NOOP); STRICT_ORDER_OFF(); - ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, + hw_vxt.data(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep)); TRY_CHECK(OM::remove(franz)); @@ -1067,12 +1345,58 @@ BOOST_AUTO_TEST_CASE(test_acl) { ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT, hw_ifh.data(), hw_acl.data())); ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl)); + ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data())); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); TRY_CHECK(OM::remove(fyodor)); } +BOOST_AUTO_TEST_CASE(test_igmp) { + VppInit vi; + const std::string Isaiah = "IsaiahBerlin"; + rc_t rc = rc_t::OK; + + boost::asio::ip::address_v4 gaddr = boost::asio::ip::address_v4::from_string("232.0.0.1"); + boost::asio::ip::address_v4 saddr1 = boost::asio::ip::address_v4::from_string("192.168.0.20"); + boost::asio::ip::address_v4 saddr2 = boost::asio::ip::address_v4::from_string("192.168.0.30"); + + std::string itf3_name = "host3"; + interface itf3(itf3_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + HW::item hw_ifh(2, rc_t::OK); + HW::item hw_as_up(interface::admin_state_t::UP, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); + TRY_CHECK_RC(OM::write(Isaiah, itf3)); + + igmp_binding *ib = new igmp_binding(itf3); + HW::item hw_binding(true, rc_t::OK); + ADD_EXPECT(igmp_binding_cmds::bind_cmd(hw_binding, hw_ifh.data())); + TRY_CHECK_RC(OM::write(Isaiah, *ib)); + + igmp_listen::src_addrs_t saddrs = {saddr1, saddr2}; + + igmp_listen *il = new igmp_listen(*ib, gaddr, saddrs); + HW::item hw_as_listen(true, rc_t::OK); + ADD_EXPECT(igmp_listen_cmds::listen_cmd(hw_as_listen, hw_ifh.data(), gaddr, saddrs)); + TRY_CHECK_RC(OM::write(Isaiah, *il)); + + delete il; + delete ib; + + HW::item hw_as_down(interface::admin_state_t::DOWN, + rc_t::OK); + STRICT_ORDER_OFF(); + ADD_EXPECT(igmp_listen_cmds::unlisten_cmd(hw_as_listen, hw_ifh.data(), gaddr)); + ADD_EXPECT(igmp_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data())); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name)); + + TRY_CHECK(OM::remove(Isaiah)); +} + BOOST_AUTO_TEST_CASE(test_arp_proxy) { VppInit vi; const std::string kurt = "KurtVonnegut"; @@ -1096,7 +1420,7 @@ BOOST_AUTO_TEST_CASE(test_arp_proxy) { ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); TRY_CHECK_RC(OM::write(kurt, itf3)); - arp_proxy_binding *apb = new arp_proxy_binding(itf3, ap); + arp_proxy_binding *apb = new arp_proxy_binding(itf3); HW::item hw_binding(true, rc_t::OK); ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data())); TRY_CHECK_RC(OM::write(kurt, *apb)); @@ -1114,6 +1438,58 @@ BOOST_AUTO_TEST_CASE(test_arp_proxy) { TRY_CHECK(OM::remove(kurt)); } +BOOST_AUTO_TEST_CASE(test_ip_punt_redirect) { + VppInit vi; + const std::string eliot = "EliotReed"; + rc_t rc = rc_t::OK; + + /* + * Interface 1 is the tx interface + */ + std::string itf1_name = "tx-itf"; + interface itf1(itf1_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + HW::item hw_ifh(2, rc_t::OK); + HW::item hw_as_up(interface::admin_state_t::UP, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); + TRY_CHECK_RC(OM::write(eliot, itf1)); + + boost::asio::ip::address addr = boost::asio::ip::address::from_string("192.168.0.20"); + + /* + * Interface 2 is the rx interface + */ + std::string itf2_name = "rx-itf"; + interface itf2(itf2_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + + HW::item hw_ifh2(4, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); + TRY_CHECK_RC(OM::write(eliot, itf2)); + + ip_punt_redirect *ip_punt = new ip_punt_redirect(itf2, itf1, addr); + HW::item hw_ip_cfg(true, rc_t::OK); + HW::item hw_ip_uncfg(false, rc_t::OK); + ADD_EXPECT(ip_punt_redirect_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data(), addr)); + TRY_CHECK_RC(OM::write(eliot, *ip_punt)); + + delete ip_punt; + + HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); + STRICT_ORDER_OFF(); + ADD_EXPECT(ip_punt_redirect_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data(), addr)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); + + TRY_CHECK(OM::remove(eliot)); +} + BOOST_AUTO_TEST_CASE(test_ip_unnumbered) { VppInit vi; const std::string eric = "EricAmbler"; @@ -1395,6 +1771,26 @@ BOOST_AUTO_TEST_CASE(test_routing) { ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, {*path_l2})); TRY_CHECK_RC(OM::write(ian, *route_dvr)); + /* + * a multicast route + */ + route::mprefix_t mpfx_4(boost::asio::ip::address::from_string("232.1.1.1"), 32); + route::ip_mroute *mroute_4 = new route::ip_mroute(mpfx_4); + + route::path *mp1 = new route::path(itf1, nh_proto_t::IPV4); + route::path *mp2 = new route::path(*itf2, nh_proto_t::IPV4); + mroute_4->add(*mp1, route::itf_flags_t::FORWARD); + mroute_4->add(*mp1, route::itf_flags_t::ACCEPT); + mroute_4->add(*mp2, route::itf_flags_t::FORWARD); + HW::item hw_mroute_4(true, rc_t::OK); + ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4, + *mp1, route::itf_flags_t::FORWARD)); + ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4, + *mp2, route::itf_flags_t::FORWARD)); + ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4, + *mp1, route::itf_flags_t::ACCEPT)); + TRY_CHECK_RC(OM::write(ian, *mroute_4)); + STRICT_ORDER_OFF(); // delete the stack objects that hold references to others // so the OM::remove is the call that removes the last reference @@ -1408,6 +1804,18 @@ BOOST_AUTO_TEST_CASE(test_routing) { delete route_dvr; delete path_l2; delete ne; + delete mroute_4; + + ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4, + *mp1, route::itf_flags_t::FORWARD)); + ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4, + *mp2, route::itf_flags_t::FORWARD)); + ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4, + *mp1, route::itf_flags_t::ACCEPT)); + + delete mp1; + delete mp2; + ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10)); ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6)); ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5)); @@ -1655,4 +2063,74 @@ BOOST_AUTO_TEST_CASE(test_prefixes) { } +BOOST_AUTO_TEST_CASE(test_pipes) { + VppInit vi; + const std::string gk = "GKChesterton"; + + const std::string pipe_name_1 = "pipe1"; + VOM::pipe pipe1(1, interface::admin_state_t::UP); + HW::item hw_hdl(4, rc_t::OK); + HW::item hw_hdl_pair(std::make_pair(5,6), rc_t::OK); + + HW::item hw_as_up(interface::admin_state_t::UP, + rc_t::OK); + HW::item hw_as_down(interface::admin_state_t::DOWN, + rc_t::OK); + ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl)); + TRY_CHECK_RC(OM::write(gk, pipe1)); + + pipe1.set_ends(hw_hdl_pair.data()); + + // put each end of the pipe in a BD + bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON); + + HW::item hw_bd(33, rc_t::OK); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, + bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON)); + + TRY_CHECK_RC(OM::write(gk, bd1)); + + l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1); + HW::item hw_l2_1_bind(true, rc_t::OK); + + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind, + pipe1.east()->handle(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); + TRY_CHECK_RC(OM::write(gk, *l2_1)); + + l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1); + HW::item hw_l2_2_bind(true, rc_t::OK); + + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind, + pipe1.west()->handle(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); + TRY_CHECK_RC(OM::write(gk, *l2_2)); + + STRICT_ORDER_OFF(); + + delete l2_1; + delete l2_2; + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind, + pipe1.east()->handle(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind, + pipe1.west()->handle(), + hw_bd.data(), + l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl)); + ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair)); + ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); + TRY_CHECK(OM::remove(gk)); +} + BOOST_AUTO_TEST_SUITE_END()