X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fext%2Fvom_test.cpp;h=4c09ab4439cccbf50cda34482666e52f3962b5da;hb=6525c7f9022fbed15c519872833097eb8607118b;hp=91769155040607402384dc58cb472610e9e0a623;hpb=a2ee029d0772e894911c84fb8a0cab5f253e145b;p=vpp.git diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 91769155040..4c09ab4439c 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -39,6 +39,8 @@ #include "vom/vxlan_tunnel_cmds.hpp" #include "vom/sub_interface.hpp" #include "vom/sub_interface_cmds.hpp" +#include "vom/acl_ethertype.hpp" +#include "vom/acl_ethertype_cmds.hpp" #include "vom/acl_list.hpp" #include "vom/acl_binding.hpp" #include "vom/acl_list_cmds.hpp" @@ -280,6 +282,10 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_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); @@ -472,7 +478,7 @@ public: } }; -BOOST_AUTO_TEST_SUITE(VppOM_test) +BOOST_AUTO_TEST_SUITE(vom) #define TRY_CHECK_RC(stmt) \ { \ @@ -736,6 +742,7 @@ BOOST_AUTO_TEST_CASE(test_bridge) { VppInit vi; const std::string franz = "FranzKafka"; const std::string dante = "Dante"; + const std::string jkr = "jkrowling"; rc_t rc = rc_t::OK; /* @@ -801,7 +808,8 @@ BOOST_AUTO_TEST_CASE(test_bridge) { HW::item hw_be1(true, rc_t::OK); mac_address_t mac1({0,1,2,3,4,5}); bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2); - ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data())); + ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(), + false)); TRY_CHECK_RC(OM::write(dante, *be1)); // Add some entries to the bridge-domain ARP termination table @@ -827,13 +835,53 @@ BOOST_AUTO_TEST_CASE(test_bridge) { delete be1; delete bea1; 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(bridge_domain_cmds::delete_cmd(hw_bd)); 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(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id())); - ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1)); - ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); TRY_CHECK(OM::remove(dante)); + + // test the BVI entry in l2fib + 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)); + + TRY_CHECK_RC(OM::write(jkr, bd2)); + + std::string itf3_name = "bvi"; + interface itf3(itf3_name, + interface::type_t::BVI, + interface::admin_state_t::UP); + + HW::item hw_ifh3(5, rc_t::OK); + ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name)); + ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3)); + 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)); + TRY_CHECK_RC(OM::write(jkr, *l2itf3)); + + HW::item hw_be2(true, rc_t::OK); + mac_address_t mac2({0,1,2,3,4,5}); + bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3); + ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true)); + TRY_CHECK_RC(OM::write(jkr, *be2)); + + 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(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)); + ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2)); + TRY_CHECK(OM::remove(jkr)); } BOOST_AUTO_TEST_CASE(test_vxlan) { @@ -942,6 +990,15 @@ BOOST_AUTO_TEST_CASE(test_acl) { ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); TRY_CHECK_RC(OM::write(fyodor, itf1)); + ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT); + ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT); + ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT); + ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3}; + ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e); + HW::item ae_binding(true, rc_t::OK); + ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e)); + TRY_CHECK_RC(OM::write(fyodor, *a_e)); + route::prefix_t src("10.10.10.10", 32); ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO); ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO); @@ -956,6 +1013,13 @@ BOOST_AUTO_TEST_CASE(test_acl) { ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules)); TRY_CHECK_RC(OM::write(fyodor, acl1)); + ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO); + ACL::l3_list acl2(acl_name); + acl2.insert(r3); + ACL::l3_list::rules_t rules2 = {r3}; + ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2)); + TRY_CHECK_RC(OM::write(fyodor, acl2)); + ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1); HW::item hw_binding(true, rc_t::OK); ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT, @@ -996,6 +1060,7 @@ BOOST_AUTO_TEST_CASE(test_acl) { TRY_CHECK(OM::remove(leo)); delete l3b; + delete a_e; HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); STRICT_ORDER_OFF(); @@ -1552,4 +1617,42 @@ BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) { TRY_CHECK(OM::remove(rene)); } +BOOST_AUTO_TEST_CASE(test_prefixes) { + route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16); + + BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::")); + + route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17); + + BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::")); + BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::")); + + route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15); + BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::")); + BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::")); + + route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16); + + BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0")); + + route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17); + + BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0")); + BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0")); + BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255")); + + route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15); + + BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0")); + BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0")); + BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255")); + + route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32); + + BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255")); + BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1")); + BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1")); + +} + BOOST_AUTO_TEST_SUITE_END()