Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Test suite for class VppOM |
| 3 | * |
| 4 | * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved. |
| 5 | * |
| 6 | * This program and the accompanying materials are made available under the |
| 7 | * terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 8 | * and is available at http://www.eclipse.org/legal/epl-v10.html |
| 9 | */ |
| 10 | #define BOOST_TEST_MODULE "VPP OBJECT MODEL" |
| 11 | #define BOOST_TEST_DYN_LINK |
| 12 | |
| 13 | #include <boost/test/unit_test.hpp> |
| 14 | #include <boost/assign/list_inserter.hpp> |
| 15 | |
| 16 | |
| 17 | #include <iostream> |
| 18 | #include <deque> |
| 19 | |
| 20 | #include "vom/om.hpp" |
| 21 | #include "vom/interface.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 22 | #include "vom/interface_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 23 | #include "vom/l2_binding.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 24 | #include "vom/l2_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 25 | #include "vom/l3_binding.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 26 | #include "vom/l3_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 27 | #include "vom/bridge_domain.hpp" |
| 28 | #include "vom/bridge_domain_entry.hpp" |
| 29 | #include "vom/bridge_domain_arp_entry.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 30 | #include "vom/bridge_domain_cmds.hpp" |
| 31 | #include "vom/bridge_domain_entry_cmds.hpp" |
| 32 | #include "vom/bridge_domain_arp_entry_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 33 | #include "vom/prefix.hpp" |
| 34 | #include "vom/route.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 35 | #include "vom/route_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 36 | #include "vom/route_domain.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 37 | #include "vom/route_domain_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 38 | #include "vom/vxlan_tunnel.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 39 | #include "vom/vxlan_tunnel_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 40 | #include "vom/sub_interface.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 41 | #include "vom/sub_interface_cmds.hpp" |
Mohsin Kazmi | 49c7f0c | 2018-02-07 20:20:36 +0100 | [diff] [blame] | 42 | #include "vom/acl_ethertype.hpp" |
| 43 | #include "vom/acl_ethertype_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 44 | #include "vom/acl_list.hpp" |
| 45 | #include "vom/acl_binding.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 46 | #include "vom/acl_list_cmds.hpp" |
| 47 | #include "vom/acl_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 48 | #include "vom/acl_l3_rule.hpp" |
| 49 | #include "vom/acl_l2_rule.hpp" |
| 50 | #include "vom/arp_proxy_config.hpp" |
| 51 | #include "vom/arp_proxy_binding.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 52 | #include "vom/arp_proxy_config_cmds.hpp" |
| 53 | #include "vom/arp_proxy_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 54 | #include "vom/ip_unnumbered.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 55 | #include "vom/ip_unnumbered_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 56 | #include "vom/interface_ip6_nd.hpp" |
| 57 | #include "vom/interface_span.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 58 | #include "vom/interface_span_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 59 | #include "vom/neighbour.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 60 | #include "vom/neighbour_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 61 | #include "vom/nat_static.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 62 | #include "vom/nat_static_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 63 | #include "vom/nat_binding.hpp" |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 64 | #include "vom/nat_binding_cmds.hpp" |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 65 | |
| 66 | using namespace boost; |
| 67 | using namespace VOM; |
| 68 | |
| 69 | /** |
| 70 | * An expectation exception |
| 71 | */ |
| 72 | class ExpException |
| 73 | { |
| 74 | public: |
| 75 | ExpException(unsigned int number) |
| 76 | { |
| 77 | // a neat place to add a break point |
| 78 | std::cout << " ExpException here: " << number << std::endl; |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | class MockListener : public interface::event_listener, |
| 83 | public interface::stat_listener |
| 84 | { |
Neale Ranns | a2ee029 | 2017-11-28 22:29:13 -0800 | [diff] [blame] | 85 | void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 86 | { |
| 87 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 88 | void handle_interface_event(interface_cmds::events_cmd *cmd) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 89 | { |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | class MockCmdQ : public HW::cmd_q |
| 94 | { |
| 95 | public: |
| 96 | MockCmdQ(): |
| 97 | m_strict_order(true) |
| 98 | { |
| 99 | } |
| 100 | virtual ~MockCmdQ() |
| 101 | { |
| 102 | } |
| 103 | void expect(cmd *f) |
| 104 | { |
| 105 | m_exp_queue.push_back(f); |
| 106 | } |
| 107 | void enqueue(cmd *f) |
| 108 | { |
| 109 | m_act_queue.push_back(f); |
| 110 | } |
| 111 | void enqueue(std::queue<cmd*> &cmds) |
| 112 | { |
| 113 | while (cmds.size()) |
| 114 | { |
| 115 | m_act_queue.push_back(cmds.front()); |
| 116 | cmds.pop(); |
| 117 | } |
| 118 | } |
| 119 | void enqueue(std::shared_ptr<cmd> f) |
| 120 | { |
| 121 | m_act_queue.push_back(f.get()); |
| 122 | } |
| 123 | |
| 124 | void dequeue(cmd *f) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | void dequeue(std::shared_ptr<cmd> cmd) |
| 129 | { |
| 130 | } |
| 131 | |
| 132 | void strict_order(bool on) |
| 133 | { |
| 134 | m_strict_order = on; |
| 135 | } |
| 136 | |
| 137 | bool is_empty() |
| 138 | { |
| 139 | return ((0 == m_exp_queue.size()) && |
| 140 | (0 == m_act_queue.size())); |
| 141 | } |
| 142 | |
| 143 | rc_t write() |
| 144 | { |
| 145 | cmd *f_exp, *f_act; |
| 146 | rc_t rc = rc_t::OK; |
| 147 | |
| 148 | while (m_act_queue.size()) |
| 149 | { |
| 150 | bool matched = false; |
| 151 | auto it_exp = m_exp_queue.begin(); |
| 152 | auto it_act = m_act_queue.begin(); |
| 153 | |
| 154 | f_act = *it_act; |
| 155 | |
| 156 | std::cout << " Act: " << f_act->to_string() << std::endl; |
| 157 | while (it_exp != m_exp_queue.end()) |
| 158 | { |
| 159 | f_exp = *it_exp; |
| 160 | try |
| 161 | { |
| 162 | std::cout << " Exp: " << f_exp->to_string() << std::endl; |
| 163 | |
| 164 | if (typeid(*f_exp) != typeid(*f_act)) |
| 165 | { |
| 166 | throw ExpException(1); |
| 167 | } |
| 168 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 169 | if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 170 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 171 | rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 172 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 173 | else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 174 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 175 | rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 176 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 177 | else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 178 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 179 | rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 180 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 181 | else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 182 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 183 | rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 184 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 185 | else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 186 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 187 | rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 188 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 189 | else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 190 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 191 | rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 192 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 193 | else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 194 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 195 | rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 196 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 197 | else if (typeid(*f_exp) == typeid(interface_cmds::set_tag)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 198 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 199 | rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 200 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 201 | else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 202 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 203 | rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 204 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 205 | else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 206 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 207 | rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 208 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 209 | else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 210 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 211 | rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 212 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 213 | else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 214 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 215 | rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 216 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 217 | else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 218 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 219 | rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 220 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 221 | else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 222 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 223 | rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 224 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 225 | else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 226 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 227 | rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 228 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 229 | else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 230 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 231 | rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 232 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 233 | else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 234 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 235 | rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 236 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 237 | else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 238 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 239 | rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 240 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 241 | else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 242 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 243 | rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 244 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 245 | else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 246 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 247 | rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 248 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 249 | else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 250 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 251 | rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 252 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 253 | else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 254 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 255 | rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 256 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 257 | else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 258 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 259 | rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 260 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 261 | else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 262 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 263 | rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 264 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 265 | else if (typeid(*f_exp) == typeid(l2_binding_cmds::set_vtr_op_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 266 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 267 | rc = handle_derived<l2_binding_cmds::set_vtr_op_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 268 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 269 | else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 270 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 271 | rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 272 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 273 | else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 274 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 275 | rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 276 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 277 | else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 278 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 279 | rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 280 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 281 | else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 282 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 283 | rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 284 | } |
Mohsin Kazmi | 49c7f0c | 2018-02-07 20:20:36 +0100 | [diff] [blame] | 285 | else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd)) |
| 286 | { |
| 287 | rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act); |
| 288 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 289 | else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 290 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 291 | rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 292 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 293 | else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 294 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 295 | rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 296 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 297 | else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 298 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 299 | rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 300 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 301 | else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 302 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 303 | rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 304 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 305 | else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 306 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 307 | rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 308 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 309 | else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 310 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 311 | rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 312 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 313 | else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 314 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 315 | rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 316 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 317 | else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 318 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 319 | rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 320 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 321 | else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 322 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 323 | rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 324 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 325 | else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 326 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 327 | rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 328 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 329 | else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 330 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 331 | rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 332 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 333 | else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 334 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 335 | rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 336 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 337 | else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 338 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 339 | rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 340 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 341 | else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 342 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 343 | rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 344 | } |
| 345 | else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd)) |
| 346 | { |
| 347 | rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act); |
| 348 | } |
| 349 | else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd)) |
| 350 | { |
| 351 | rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act); |
| 352 | } |
| 353 | else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd)) |
| 354 | { |
| 355 | rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act); |
| 356 | } |
| 357 | else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd)) |
| 358 | { |
| 359 | rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act); |
| 360 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 361 | else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 362 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 363 | rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 364 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 365 | else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 366 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 367 | rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 368 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 369 | else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 370 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 371 | rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 372 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 373 | else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 374 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 375 | rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 376 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 377 | else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 378 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 379 | rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 380 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 381 | else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 382 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 383 | rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 384 | } |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 385 | else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd)) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 386 | { |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 387 | rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 388 | } |
| 389 | else |
| 390 | { |
| 391 | throw ExpException(2); |
| 392 | } |
| 393 | |
| 394 | // if we get here then we found the match. |
| 395 | m_exp_queue.erase(it_exp); |
| 396 | m_act_queue.erase(it_act); |
| 397 | delete f_exp; |
| 398 | delete f_act; |
| 399 | |
| 400 | // return any injected failures to the agent |
| 401 | if (rc_t::OK != rc && rc_t::NOOP != rc) |
| 402 | { |
| 403 | return (rc); |
| 404 | } |
| 405 | |
| 406 | matched = true; |
| 407 | break; |
| 408 | } |
| 409 | catch (ExpException &e) |
| 410 | { |
| 411 | // The expected and actual do not match |
| 412 | if (m_strict_order) |
| 413 | { |
| 414 | // in strict ordering mode this is fatal, so rethrow |
| 415 | throw e; |
| 416 | } |
| 417 | else |
| 418 | { |
| 419 | // move the iterator onto the next in the expected list and |
| 420 | // check for a match |
| 421 | ++it_exp; |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | if (!matched) |
| 427 | throw ExpException(3); |
| 428 | } |
| 429 | |
| 430 | return (rc); |
| 431 | } |
| 432 | private: |
| 433 | |
| 434 | template <typename T> |
| 435 | rc_t handle_derived(const cmd *f_exp, cmd *f_act) |
| 436 | { |
| 437 | const T *i_exp; |
| 438 | T *i_act; |
| 439 | |
| 440 | i_exp = dynamic_cast<const T*>(f_exp); |
| 441 | i_act = dynamic_cast<T*>(f_act); |
| 442 | if (!(*i_exp == *i_act)) |
| 443 | { |
| 444 | throw ExpException(4); |
| 445 | } |
| 446 | // pass the data and return code to the agent |
| 447 | i_act->item() = i_exp->item(); |
| 448 | |
| 449 | return (i_act->item().rc()); |
| 450 | } |
| 451 | |
| 452 | // The Q to push the expectations on |
| 453 | std::deque<cmd*> m_exp_queue; |
| 454 | |
| 455 | // the queue to push the actual events on |
| 456 | std::deque<cmd*> m_act_queue; |
| 457 | |
| 458 | // control whether the expected queue is strictly ordered. |
| 459 | bool m_strict_order; |
| 460 | }; |
| 461 | |
| 462 | class VppInit { |
| 463 | public: |
| 464 | std::string name; |
| 465 | MockCmdQ *f; |
| 466 | |
| 467 | VppInit() |
| 468 | : name("vpp-ut"), |
| 469 | f(new MockCmdQ()) |
| 470 | { |
| 471 | HW::init(f); |
| 472 | OM::init(); |
| 473 | logger().set(log_level_t::DEBUG); |
| 474 | } |
| 475 | |
| 476 | ~VppInit() { |
| 477 | delete f; |
| 478 | } |
| 479 | }; |
| 480 | |
Neale Ranns | d3464b5 | 2017-12-07 08:48:02 -0800 | [diff] [blame] | 481 | BOOST_AUTO_TEST_SUITE(vom) |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 482 | |
| 483 | #define TRY_CHECK_RC(stmt) \ |
| 484 | { \ |
| 485 | try { \ |
| 486 | BOOST_CHECK(rc_t::OK == stmt); \ |
| 487 | } \ |
| 488 | catch (ExpException &e) \ |
| 489 | { \ |
| 490 | BOOST_CHECK(false); \ |
| 491 | } \ |
| 492 | BOOST_CHECK(vi.f->is_empty()); \ |
| 493 | } |
| 494 | |
| 495 | #define TRY_CHECK(stmt) \ |
| 496 | { \ |
| 497 | try { \ |
| 498 | stmt; \ |
| 499 | } \ |
| 500 | catch (ExpException &e) \ |
| 501 | { \ |
| 502 | BOOST_CHECK(false); \ |
| 503 | } \ |
| 504 | BOOST_CHECK(vi.f->is_empty()); \ |
| 505 | } |
| 506 | |
| 507 | #define ADD_EXPECT(stmt) \ |
| 508 | vi.f->expect(new stmt) |
| 509 | |
| 510 | #define STRICT_ORDER_OFF() \ |
| 511 | vi.f->strict_order(false) |
| 512 | |
| 513 | BOOST_AUTO_TEST_CASE(test_interface) { |
| 514 | VppInit vi; |
| 515 | const std::string go = "GeorgeOrwell"; |
| 516 | const std::string js = "JohnSteinbeck"; |
| 517 | rc_t rc = rc_t::OK; |
| 518 | |
| 519 | /* |
| 520 | * George creates and deletes the interface |
| 521 | */ |
| 522 | std::string itf1_name = "afpacket1"; |
| 523 | interface itf1(itf1_name, |
| 524 | interface::type_t::AFPACKET, |
| 525 | interface::admin_state_t::UP); |
| 526 | |
| 527 | /* |
| 528 | * set the expectation for a afpacket interface create. |
| 529 | * 2 is the interface handle VPP [mock] assigns |
| 530 | */ |
| 531 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 532 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 533 | |
| 534 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 535 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 536 | |
| 537 | TRY_CHECK_RC(OM::write(go, itf1)); |
| 538 | |
| 539 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 540 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 541 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 542 | |
| 543 | TRY_CHECK(OM::remove(go)); |
| 544 | |
| 545 | /* |
| 546 | * George creates the interface, then John brings it down. |
| 547 | * George's remove is a no-op, sice John also owns the interface |
| 548 | */ |
| 549 | interface itf1b(itf1_name, |
| 550 | interface::type_t::AFPACKET, |
| 551 | interface::admin_state_t::DOWN); |
| 552 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 553 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 554 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 555 | TRY_CHECK_RC(OM::write(go, itf1)); |
| 556 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 557 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 558 | TRY_CHECK_RC(OM::write(js, itf1b)); |
| 559 | |
| 560 | TRY_CHECK(OM::remove(go)); |
| 561 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 562 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 563 | TRY_CHECK(OM::remove(js)); |
| 564 | |
| 565 | /* |
| 566 | * George adds an interface, then we flush all of Geroge's state |
| 567 | */ |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 568 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 569 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 570 | TRY_CHECK_RC(OM::write(go, itf1)); |
| 571 | |
| 572 | TRY_CHECK(OM::mark(go)); |
| 573 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 574 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 575 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 576 | TRY_CHECK(OM::sweep(go)); |
| 577 | |
| 578 | /* |
| 579 | * George adds an interface. mark stale. update the same interface. sweep |
| 580 | * and expect no delete |
| 581 | */ |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 582 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 583 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 584 | TRY_CHECK_RC(OM::write(go, itf1b)); |
| 585 | |
| 586 | TRY_CHECK(OM::mark(go)); |
| 587 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 588 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 589 | TRY_CHECK_RC(OM::write(go, itf1)); |
| 590 | |
| 591 | TRY_CHECK(OM::sweep(go)); |
| 592 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 593 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 594 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 595 | TRY_CHECK(OM::remove(go)); |
| 596 | |
| 597 | /* |
| 598 | * George adds an insterface, then we mark that state. Add a second interface |
| 599 | * an flush the first that is now stale. |
| 600 | */ |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 601 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 602 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 603 | TRY_CHECK_RC(OM::write(go, itf1)); |
| 604 | |
| 605 | TRY_CHECK(OM::mark(go)); |
| 606 | |
| 607 | std::string itf2_name = "afpacket2"; |
| 608 | interface itf2(itf2_name, |
| 609 | interface::type_t::AFPACKET, |
| 610 | interface::admin_state_t::UP); |
| 611 | HW::item<handle_t> hw_ifh2(3, rc_t::OK); |
| 612 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 613 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); |
| 614 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 615 | TRY_CHECK_RC(OM::write(go, itf2)); |
| 616 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 617 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 618 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 619 | TRY_CHECK(OM::sweep(go)); |
| 620 | |
| 621 | TRY_CHECK(OM::mark(go)); |
| 622 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 623 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); |
| 624 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 625 | TRY_CHECK(OM::sweep(go)); |
| 626 | } |
| 627 | |
| 628 | BOOST_AUTO_TEST_CASE(test_bvi) { |
| 629 | VppInit vi; |
| 630 | const std::string ernest = "ErnestHemmingway"; |
| 631 | const std::string graham = "GrahamGreene"; |
| 632 | rc_t rc = rc_t::OK; |
| 633 | l3_binding *l3; |
| 634 | |
| 635 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, |
| 636 | rc_t::OK); |
| 637 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, |
| 638 | rc_t::OK); |
| 639 | |
| 640 | /* |
| 641 | * Enrest creates a BVI with address 10.10.10.10/24 |
| 642 | */ |
| 643 | route::prefix_t pfx_10("10.10.10.10", 24); |
| 644 | |
| 645 | const std::string bvi_name = "bvi1"; |
| 646 | interface itf(bvi_name, |
| 647 | interface::type_t::BVI, |
| 648 | interface::admin_state_t::UP); |
| 649 | HW::item<handle_t> hw_ifh(4, rc_t::OK); |
| 650 | HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK); |
| 651 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 652 | ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh, bvi_name)); |
| 653 | ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name)); |
| 654 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 655 | TRY_CHECK_RC(OM::write(ernest, itf)); |
| 656 | |
| 657 | l3 = new l3_binding(itf, pfx_10); |
| 658 | HW::item<bool> hw_l3_bind(true, rc_t::OK); |
| 659 | HW::item<bool> hw_l3_unbind(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 660 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 661 | TRY_CHECK_RC(OM::write(ernest, *l3)); |
| 662 | |
| 663 | // change the MAC address on the BVI |
| 664 | interface itf_new_mac(bvi_name, |
| 665 | interface::type_t::BVI, |
| 666 | interface::admin_state_t::UP); |
| 667 | l2_address_t l2_addr({0,1,2,3,4,5}); |
| 668 | HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK); |
| 669 | itf_new_mac.set(l2_addr); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 670 | ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 671 | TRY_CHECK_RC(OM::write(ernest, itf_new_mac)); |
| 672 | |
| 673 | // create/write the interface to the OM again but with an unset MAC |
| 674 | // this should not generate a MAC address update |
| 675 | TRY_CHECK_RC(OM::write(ernest, itf)); |
| 676 | |
| 677 | // change the MAC address on the BVI - again |
| 678 | interface itf_new_mac2(bvi_name, |
| 679 | interface::type_t::BVI, |
| 680 | interface::admin_state_t::UP); |
| 681 | l2_address_t l2_addr2({0,1,2,3,4,6}); |
| 682 | HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK); |
| 683 | itf_new_mac2.set(l2_addr2); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 684 | ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 685 | TRY_CHECK_RC(OM::write(ernest, itf_new_mac2)); |
| 686 | |
| 687 | delete l3; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 688 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10)); |
| 689 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 690 | ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 691 | TRY_CHECK(OM::remove(ernest)); |
| 692 | |
| 693 | /* |
| 694 | * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain |
| 695 | */ |
| 696 | route_domain rd(1); |
| 697 | HW::item<bool> hw_rd4_create(true, rc_t::OK); |
| 698 | HW::item<bool> hw_rd4_delete(false, rc_t::OK); |
| 699 | HW::item<bool> hw_rd6_create(true, rc_t::OK); |
| 700 | HW::item<bool> hw_rd6_delete(false, rc_t::OK); |
| 701 | HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK); |
| 702 | HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK); |
| 703 | HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK); |
| 704 | HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 705 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1)); |
| 706 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 707 | TRY_CHECK_RC(OM::write(graham, rd)); |
| 708 | |
| 709 | const std::string bvi2_name = "bvi2"; |
| 710 | interface *itf2 = new interface(bvi2_name, |
| 711 | interface::type_t::BVI, |
| 712 | interface::admin_state_t::UP, |
| 713 | rd); |
| 714 | HW::item<handle_t> hw_ifh2(5, rc_t::OK); |
| 715 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 716 | ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh2, bvi2_name)); |
| 717 | ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name)); |
| 718 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); |
| 719 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2)); |
| 720 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 721 | |
| 722 | TRY_CHECK_RC(OM::write(graham, *itf2)); |
| 723 | |
| 724 | l3 = new l3_binding(*itf2, pfx_10); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 725 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 726 | TRY_CHECK_RC(OM::write(graham, *l3)); |
| 727 | |
| 728 | delete l3; |
| 729 | delete itf2; |
| 730 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 731 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10)); |
| 732 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2)); |
| 733 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2)); |
| 734 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); |
| 735 | ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh2)); |
| 736 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1)); |
| 737 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 738 | TRY_CHECK(OM::remove(graham)); |
| 739 | } |
| 740 | |
| 741 | BOOST_AUTO_TEST_CASE(test_bridge) { |
| 742 | VppInit vi; |
| 743 | const std::string franz = "FranzKafka"; |
| 744 | const std::string dante = "Dante"; |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 745 | const std::string jkr = "jkrowling"; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 746 | rc_t rc = rc_t::OK; |
| 747 | |
| 748 | /* |
| 749 | * Franz creates an interface, Bridge-domain, then binds the two |
| 750 | */ |
| 751 | |
| 752 | // interface create |
| 753 | std::string itf1_name = "afpacket1"; |
| 754 | interface itf1(itf1_name, |
| 755 | interface::type_t::AFPACKET, |
| 756 | interface::admin_state_t::UP); |
| 757 | |
| 758 | HW::item<handle_t> hw_ifh(3, rc_t::OK); |
| 759 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, |
| 760 | rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 761 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 762 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 763 | |
| 764 | TRY_CHECK_RC(OM::write(franz, itf1)); |
| 765 | |
| 766 | // bridge-domain create |
| 767 | bridge_domain bd1(33); |
| 768 | |
| 769 | HW::item<uint32_t> hw_bd(33, rc_t::OK); |
Neale Ranns | 10e7a9f | 2017-11-14 08:40:43 -0800 | [diff] [blame] | 770 | ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::ON)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 771 | |
| 772 | TRY_CHECK_RC(OM::write(franz, bd1)); |
| 773 | |
| 774 | // L2-interface create and bind |
| 775 | // this needs to be delete'd before the flush below, since it too maintains |
| 776 | // references to the BD and Interface |
| 777 | l2_binding *l2itf = new l2_binding(itf1, bd1); |
| 778 | HW::item<bool> hw_l2_bind(true, rc_t::OK); |
| 779 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 780 | ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 781 | TRY_CHECK_RC(OM::write(franz, *l2itf)); |
| 782 | |
| 783 | /* |
| 784 | * Dante adds an interface to the same BD |
| 785 | */ |
| 786 | std::string itf2_name = "afpacket2"; |
| 787 | interface itf2(itf2_name, |
| 788 | interface::type_t::AFPACKET, |
| 789 | interface::admin_state_t::UP); |
| 790 | |
| 791 | HW::item<handle_t> hw_ifh2(4, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 792 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); |
| 793 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 794 | TRY_CHECK_RC(OM::write(dante, itf2)); |
| 795 | |
| 796 | // BD add is a no-op since it exists |
| 797 | TRY_CHECK_RC(OM::write(dante, bd1)); |
| 798 | |
| 799 | l2_binding *l2itf2 = new l2_binding(itf2, bd1); |
| 800 | HW::item<l2_binding::l2_vtr_op_t> hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK); |
| 801 | l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68); |
| 802 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 803 | ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false)); |
| 804 | ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 805 | TRY_CHECK_RC(OM::write(dante, *l2itf2)); |
| 806 | |
| 807 | // Add some static entries to the bridge-domain |
| 808 | HW::item<bool> hw_be1(true, rc_t::OK); |
| 809 | mac_address_t mac1({0,1,2,3,4,5}); |
| 810 | bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2); |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 811 | ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(), |
| 812 | false)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 813 | TRY_CHECK_RC(OM::write(dante, *be1)); |
| 814 | |
| 815 | // Add some entries to the bridge-domain ARP termination table |
| 816 | HW::item<bool> hw_bea1(true, rc_t::OK); |
| 817 | boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10"); |
| 818 | |
Neale Ranns | fd92060 | 2017-11-23 12:15:00 -0800 | [diff] [blame] | 819 | bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 820 | ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 821 | TRY_CHECK_RC(OM::write(dante, *bea1)); |
| 822 | |
| 823 | // flush Franz's state |
| 824 | delete l2itf; |
| 825 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, |
| 826 | rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 827 | ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false)); |
| 828 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 829 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 830 | TRY_CHECK(OM::remove(franz)); |
| 831 | |
| 832 | // flush Dante's state - the order the interface and BD are deleted |
| 833 | // is an uncontrollable artifact of the C++ object destruction. |
| 834 | delete l2itf2; |
| 835 | delete be1; |
| 836 | delete bea1; |
| 837 | STRICT_ORDER_OFF(); |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 838 | ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1)); |
| 839 | ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false)); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 840 | ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false)); |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 841 | |
| 842 | ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 843 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); |
| 844 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 845 | TRY_CHECK(OM::remove(dante)); |
Mohsin Kazmi | e2e9ce5 | 2017-12-01 15:12:57 +0100 | [diff] [blame] | 846 | |
| 847 | // test the BVI entry in l2fib |
| 848 | bridge_domain bd2(99); |
| 849 | |
| 850 | HW::item<uint32_t> hw_bd2(99, rc_t::OK); |
| 851 | ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2, bridge_domain::learning_mode_t::ON)); |
| 852 | |
| 853 | TRY_CHECK_RC(OM::write(jkr, bd2)); |
| 854 | |
| 855 | std::string itf3_name = "bvi"; |
| 856 | interface itf3(itf3_name, |
| 857 | interface::type_t::BVI, |
| 858 | interface::admin_state_t::UP); |
| 859 | |
| 860 | HW::item<handle_t> hw_ifh3(5, rc_t::OK); |
| 861 | ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name)); |
| 862 | ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name)); |
| 863 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3)); |
| 864 | TRY_CHECK_RC(OM::write(jkr, itf3)); |
| 865 | |
| 866 | l2_binding *l2itf3 = new l2_binding(itf3, bd2); |
| 867 | ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true)); |
| 868 | TRY_CHECK_RC(OM::write(jkr, *l2itf3)); |
| 869 | |
| 870 | HW::item<bool> hw_be2(true, rc_t::OK); |
| 871 | mac_address_t mac2({0,1,2,3,4,5}); |
| 872 | bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3); |
| 873 | ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true)); |
| 874 | TRY_CHECK_RC(OM::write(jkr, *be2)); |
| 875 | |
| 876 | delete l2itf3; |
| 877 | delete be2; |
| 878 | STRICT_ORDER_OFF(); |
| 879 | ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true)); |
| 880 | ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true)); |
| 881 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3)); |
| 882 | ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3)); |
| 883 | ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2)); |
| 884 | TRY_CHECK(OM::remove(jkr)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | BOOST_AUTO_TEST_CASE(test_vxlan) { |
| 888 | VppInit vi; |
| 889 | const std::string franz = "FranzKafka"; |
| 890 | rc_t rc = rc_t::OK; |
| 891 | |
| 892 | /* |
| 893 | * Franz creates an interface, Bridge-domain, then binds the two |
| 894 | */ |
| 895 | |
| 896 | // VXLAN create |
| 897 | vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"), |
| 898 | boost::asio::ip::address::from_string("10.10.10.11"), |
| 899 | 322); |
| 900 | |
| 901 | vxlan_tunnel vxt(ep.src, ep.dst, ep.vni); |
| 902 | |
| 903 | HW::item<handle_t> hw_vxt(3, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 904 | ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 905 | |
| 906 | TRY_CHECK_RC(OM::write(franz, vxt)); |
| 907 | |
| 908 | // bridge-domain create |
Neale Ranns | 10e7a9f | 2017-11-14 08:40:43 -0800 | [diff] [blame] | 909 | bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 910 | |
| 911 | HW::item<uint32_t> hw_bd(33, rc_t::OK); |
Neale Ranns | 10e7a9f | 2017-11-14 08:40:43 -0800 | [diff] [blame] | 912 | ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::OFF)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 913 | |
| 914 | TRY_CHECK_RC(OM::write(franz, bd1)); |
| 915 | |
| 916 | // L2-interface create and bind |
| 917 | // this needs to be delete'd before the flush below, since it too maintains |
| 918 | // references to the BD and Interface |
| 919 | l2_binding *l2itf = new l2_binding(vxt, bd1); |
| 920 | HW::item<bool> hw_l2_bind(true, rc_t::OK); |
| 921 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 922 | ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 923 | TRY_CHECK_RC(OM::write(franz, *l2itf)); |
| 924 | |
| 925 | // flush Franz's state |
| 926 | delete l2itf; |
| 927 | HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP); |
| 928 | STRICT_ORDER_OFF(); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 929 | ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false)); |
| 930 | ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); |
| 931 | ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 932 | TRY_CHECK(OM::remove(franz)); |
| 933 | } |
| 934 | |
| 935 | BOOST_AUTO_TEST_CASE(test_vlan) { |
| 936 | VppInit vi; |
| 937 | const std::string noam = "NoamChomsky"; |
| 938 | rc_t rc = rc_t::OK; |
| 939 | |
| 940 | std::string itf1_name = "host1"; |
| 941 | interface itf1(itf1_name, |
| 942 | interface::type_t::AFPACKET, |
| 943 | interface::admin_state_t::UP); |
| 944 | |
| 945 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 946 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 947 | |
| 948 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 949 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 950 | |
| 951 | TRY_CHECK_RC(OM::write(noam, itf1)); |
| 952 | |
| 953 | sub_interface *vl33 = new sub_interface(itf1, |
| 954 | interface::admin_state_t::UP, |
| 955 | 33); |
| 956 | |
| 957 | HW::item<handle_t> hw_vl33(3, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 958 | ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33)); |
| 959 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 960 | |
| 961 | TRY_CHECK_RC(OM::write(noam, *vl33)); |
| 962 | |
| 963 | delete vl33; |
| 964 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
| 965 | HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 966 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33)); |
| 967 | ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down)); |
| 968 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 969 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 970 | |
| 971 | TRY_CHECK(OM::remove(noam)); |
| 972 | } |
| 973 | |
| 974 | BOOST_AUTO_TEST_CASE(test_acl) { |
| 975 | VppInit vi; |
| 976 | const std::string fyodor = "FyodorDostoyevsky"; |
| 977 | const std::string leo = "LeoTolstoy"; |
| 978 | rc_t rc = rc_t::OK; |
| 979 | |
| 980 | /* |
| 981 | * Fyodor adds an ACL in the input direction |
| 982 | */ |
| 983 | std::string itf1_name = "host1"; |
| 984 | interface itf1(itf1_name, |
| 985 | interface::type_t::AFPACKET, |
| 986 | interface::admin_state_t::UP); |
| 987 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 988 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 989 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 990 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 991 | TRY_CHECK_RC(OM::write(fyodor, itf1)); |
| 992 | |
Mohsin Kazmi | 49c7f0c | 2018-02-07 20:20:36 +0100 | [diff] [blame] | 993 | ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT); |
| 994 | ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT); |
| 995 | ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT); |
| 996 | ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3}; |
| 997 | ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e); |
| 998 | HW::item<bool> ae_binding(true, rc_t::OK); |
| 999 | ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e)); |
| 1000 | TRY_CHECK_RC(OM::write(fyodor, *a_e)); |
| 1001 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1002 | route::prefix_t src("10.10.10.10", 32); |
| 1003 | ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO); |
| 1004 | ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO); |
| 1005 | |
| 1006 | std::string acl_name = "acl1"; |
| 1007 | ACL::l3_list acl1(acl_name); |
| 1008 | acl1.insert(r2); |
| 1009 | acl1.insert(r1); |
| 1010 | ACL::l3_list::rules_t rules = {r1, r2}; |
| 1011 | |
| 1012 | HW::item<handle_t> hw_acl(2, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1013 | ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1014 | TRY_CHECK_RC(OM::write(fyodor, acl1)); |
| 1015 | |
Mohsin Kazmi | d91d140 | 2018-02-14 15:47:19 +0100 | [diff] [blame] | 1016 | ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO); |
| 1017 | ACL::l3_list acl2(acl_name); |
| 1018 | acl2.insert(r3); |
| 1019 | ACL::l3_list::rules_t rules2 = {r3}; |
| 1020 | ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2)); |
| 1021 | TRY_CHECK_RC(OM::write(fyodor, acl2)); |
| 1022 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1023 | ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1); |
| 1024 | HW::item<bool> hw_binding(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1025 | ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT, |
| 1026 | hw_ifh.data(), hw_acl.data())); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1027 | TRY_CHECK_RC(OM::write(fyodor, *l3b)); |
| 1028 | |
| 1029 | /** |
| 1030 | * Leo adds an L2 ACL in the output direction |
| 1031 | */ |
| 1032 | TRY_CHECK_RC(OM::write(leo, itf1)); |
| 1033 | |
| 1034 | std::string l2_acl_name = "l2_acl1"; |
| 1035 | mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4}); |
| 1036 | mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0}); |
| 1037 | ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask); |
| 1038 | ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {}); |
| 1039 | |
| 1040 | ACL::l2_list l2_acl(l2_acl_name); |
| 1041 | l2_acl.insert(l2_r2); |
| 1042 | l2_acl.insert(l2_r1); |
| 1043 | |
| 1044 | ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2}; |
| 1045 | |
| 1046 | HW::item<handle_t> l2_hw_acl(3, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1047 | ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1048 | TRY_CHECK_RC(OM::write(leo, l2_acl)); |
| 1049 | |
| 1050 | ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl); |
| 1051 | HW::item<bool> l2_hw_binding(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1052 | ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT, |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1053 | hw_ifh.data(), l2_hw_acl.data())); |
| 1054 | TRY_CHECK_RC(OM::write(leo, *l2b)); |
| 1055 | |
| 1056 | delete l2b; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1057 | ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT, |
| 1058 | hw_ifh.data(), l2_hw_acl.data())); |
| 1059 | ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1060 | TRY_CHECK(OM::remove(leo)); |
| 1061 | |
| 1062 | delete l3b; |
Mohsin Kazmi | 49c7f0c | 2018-02-07 20:20:36 +0100 | [diff] [blame] | 1063 | delete a_e; |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1064 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, |
| 1065 | rc_t::OK); |
| 1066 | STRICT_ORDER_OFF(); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1067 | ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT, |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1068 | hw_ifh.data(), hw_acl.data())); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1069 | ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl)); |
| 1070 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1071 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1072 | |
| 1073 | TRY_CHECK(OM::remove(fyodor)); |
| 1074 | } |
| 1075 | |
| 1076 | BOOST_AUTO_TEST_CASE(test_arp_proxy) { |
| 1077 | VppInit vi; |
| 1078 | const std::string kurt = "KurtVonnegut"; |
| 1079 | rc_t rc = rc_t::OK; |
| 1080 | |
| 1081 | asio::ip::address_v4 low = asio::ip::address_v4::from_string("10.0.0.0"); |
| 1082 | asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255"); |
| 1083 | |
| 1084 | arp_proxy_config ap(low, high); |
| 1085 | HW::item<bool> hw_ap_cfg(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1086 | ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1087 | TRY_CHECK_RC(OM::write(kurt, ap)); |
| 1088 | |
| 1089 | std::string itf3_name = "host3"; |
| 1090 | interface itf3(itf3_name, |
| 1091 | interface::type_t::AFPACKET, |
| 1092 | interface::admin_state_t::UP); |
| 1093 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 1094 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1095 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name)); |
| 1096 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1097 | TRY_CHECK_RC(OM::write(kurt, itf3)); |
| 1098 | |
| 1099 | arp_proxy_binding *apb = new arp_proxy_binding(itf3, ap); |
| 1100 | HW::item<bool> hw_binding(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1101 | ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data())); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1102 | TRY_CHECK_RC(OM::write(kurt, *apb)); |
| 1103 | |
| 1104 | delete apb; |
| 1105 | |
| 1106 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, |
| 1107 | rc_t::OK); |
| 1108 | STRICT_ORDER_OFF(); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1109 | ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data())); |
| 1110 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1111 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name)); |
| 1112 | ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1113 | |
| 1114 | TRY_CHECK(OM::remove(kurt)); |
| 1115 | } |
| 1116 | |
| 1117 | BOOST_AUTO_TEST_CASE(test_ip_unnumbered) { |
| 1118 | VppInit vi; |
| 1119 | const std::string eric = "EricAmbler"; |
| 1120 | rc_t rc = rc_t::OK; |
| 1121 | |
| 1122 | /* |
| 1123 | * Interface 1 has the L3 address |
| 1124 | */ |
| 1125 | std::string itf1_name = "host1"; |
| 1126 | interface itf1(itf1_name, |
| 1127 | interface::type_t::AFPACKET, |
| 1128 | interface::admin_state_t::UP); |
| 1129 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 1130 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1131 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 1132 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1133 | TRY_CHECK_RC(OM::write(eric, itf1)); |
| 1134 | |
| 1135 | route::prefix_t pfx_10("10.10.10.10", 24); |
| 1136 | l3_binding *l3 = new l3_binding(itf1, pfx_10); |
| 1137 | HW::item<bool> hw_l3_bind(true, rc_t::OK); |
| 1138 | HW::item<bool> hw_l3_unbind(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1139 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1140 | TRY_CHECK_RC(OM::write(eric, *l3)); |
| 1141 | |
| 1142 | /* |
| 1143 | * Interface 2 is unnumbered |
| 1144 | */ |
| 1145 | std::string itf2_name = "host2"; |
| 1146 | interface itf2(itf2_name, |
| 1147 | interface::type_t::AFPACKET, |
| 1148 | interface::admin_state_t::UP); |
| 1149 | |
| 1150 | HW::item<handle_t> hw_ifh2(4, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1151 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); |
| 1152 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1153 | TRY_CHECK_RC(OM::write(eric, itf2)); |
| 1154 | |
| 1155 | ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1); |
| 1156 | HW::item<bool> hw_ip_cfg(true, rc_t::OK); |
| 1157 | HW::item<bool> hw_ip_uncfg(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1158 | ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data())); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1159 | TRY_CHECK_RC(OM::write(eric, *ipun)); |
| 1160 | |
| 1161 | delete l3; |
| 1162 | delete ipun; |
| 1163 | |
| 1164 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
| 1165 | STRICT_ORDER_OFF(); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1166 | ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data())); |
| 1167 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10)); |
| 1168 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); |
| 1169 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); |
| 1170 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1171 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1172 | |
| 1173 | TRY_CHECK(OM::remove(eric)); |
| 1174 | } |
| 1175 | |
| 1176 | BOOST_AUTO_TEST_CASE(test_ip6nd) { |
| 1177 | VppInit vi; |
| 1178 | const std::string paulo = "PauloCoelho"; |
| 1179 | rc_t rc = rc_t::OK; |
| 1180 | |
| 1181 | /* |
| 1182 | * ra config |
| 1183 | */ |
| 1184 | std::string itf_name = "host_ip6nd"; |
| 1185 | interface itf(itf_name, |
| 1186 | interface::type_t::AFPACKET, |
| 1187 | interface::admin_state_t::UP); |
| 1188 | HW::item<handle_t> hw_ifh(3, rc_t::OK); |
| 1189 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1190 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name)); |
| 1191 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1192 | TRY_CHECK_RC(OM::write(paulo, itf)); |
| 1193 | |
| 1194 | route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128); |
| 1195 | l3_binding *l3 = new l3_binding(itf, pfx_10); |
| 1196 | HW::item<bool> hw_l3_bind(true, rc_t::OK); |
| 1197 | HW::item<bool> hw_l3_unbind(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1198 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1199 | TRY_CHECK_RC(OM::write(paulo, *l3)); |
| 1200 | |
| 1201 | ra_config ra(0, 1, 0, 4); |
| 1202 | ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra); |
| 1203 | HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK); |
| 1204 | HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK); |
| 1205 | ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra)); |
| 1206 | TRY_CHECK_RC(OM::write(paulo, *ip6ra)); |
| 1207 | |
| 1208 | /* |
| 1209 | * ra prefix |
| 1210 | */ |
| 1211 | ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800); |
| 1212 | ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx); |
| 1213 | HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK); |
| 1214 | HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK); |
| 1215 | ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx)); |
| 1216 | TRY_CHECK_RC(OM::write(paulo, *ip6pfx)); |
| 1217 | |
| 1218 | delete ip6pfx; |
| 1219 | |
| 1220 | ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx)); |
| 1221 | |
| 1222 | delete ip6ra; |
| 1223 | delete l3; |
| 1224 | |
| 1225 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
| 1226 | |
| 1227 | STRICT_ORDER_OFF(); |
| 1228 | ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra)); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1229 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10)); |
| 1230 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1231 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1232 | |
| 1233 | TRY_CHECK(OM::remove(paulo)); |
| 1234 | } |
| 1235 | |
| 1236 | BOOST_AUTO_TEST_CASE(test_interface_span) { |
| 1237 | VppInit vi; |
| 1238 | const std::string elif = "ElifShafak"; |
| 1239 | rc_t rc = rc_t::OK; |
| 1240 | |
| 1241 | /* |
| 1242 | * Interface 1 to be mirrored |
| 1243 | */ |
| 1244 | std::string itf1_name = "port-from"; |
| 1245 | interface itf1(itf1_name, |
| 1246 | interface::type_t::AFPACKET, |
| 1247 | interface::admin_state_t::UP); |
| 1248 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 1249 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1250 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 1251 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1252 | TRY_CHECK_RC(OM::write(elif, itf1)); |
| 1253 | |
| 1254 | /* |
| 1255 | * Interface 2 where traffic is mirrored |
| 1256 | */ |
| 1257 | std::string itf2_name = "port-to"; |
| 1258 | interface itf2(itf2_name, |
| 1259 | interface::type_t::AFPACKET, |
| 1260 | interface::admin_state_t::UP); |
| 1261 | |
| 1262 | HW::item<handle_t> hw_ifh2(4, rc_t::OK); |
| 1263 | HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK); |
| 1264 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1265 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); |
| 1266 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1267 | TRY_CHECK_RC(OM::write(elif, itf2)); |
| 1268 | |
| 1269 | interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED); |
| 1270 | HW::item<bool> hw_is_cfg(true, rc_t::OK); |
| 1271 | HW::item<bool> hw_is_uncfg(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1272 | ADD_EXPECT(interface_span_cmds::config_cmd(hw_is_cfg, hw_ifh.data(), hw_ifh2.data(), interface_span::state_t::TX_RX_ENABLED)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1273 | TRY_CHECK_RC(OM::write(elif, *itf_span)); |
| 1274 | |
| 1275 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
| 1276 | HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK); |
| 1277 | |
| 1278 | delete itf_span; |
| 1279 | STRICT_ORDER_OFF(); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1280 | ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data())); |
| 1281 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1282 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
| 1283 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2)); |
| 1284 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1285 | |
| 1286 | TRY_CHECK(OM::remove(elif)); |
| 1287 | } |
| 1288 | |
| 1289 | BOOST_AUTO_TEST_CASE(test_routing) { |
| 1290 | VppInit vi; |
| 1291 | const std::string ian = "IanFleming"; |
| 1292 | rc_t rc = rc_t::OK; |
| 1293 | |
| 1294 | /* |
| 1295 | * non-default route domain |
| 1296 | */ |
| 1297 | route_domain rd4(1); |
| 1298 | HW::item<bool> hw_rd4_create(true, rc_t::OK); |
| 1299 | HW::item<bool> hw_rd4_delete(false, rc_t::OK); |
| 1300 | HW::item<bool> hw_rd6_create(true, rc_t::OK); |
| 1301 | HW::item<bool> hw_rd6_delete(false, rc_t::OK); |
| 1302 | HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK); |
| 1303 | HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK); |
| 1304 | HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK); |
| 1305 | HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1306 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1)); |
| 1307 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1308 | TRY_CHECK_RC(OM::write(ian, rd4)); |
| 1309 | |
| 1310 | /* |
| 1311 | * a couple of interfaces |
| 1312 | */ |
| 1313 | std::string itf1_name = "af1"; |
| 1314 | interface itf1(itf1_name, |
| 1315 | interface::type_t::AFPACKET, |
| 1316 | interface::admin_state_t::UP); |
| 1317 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 1318 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
| 1319 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1320 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); |
| 1321 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1322 | TRY_CHECK_RC(OM::write(ian, itf1)); |
| 1323 | |
| 1324 | std::string itf2_name = "af2"; |
| 1325 | interface *itf2 = new interface(itf2_name, |
| 1326 | interface::type_t::AFPACKET, |
| 1327 | interface::admin_state_t::UP, |
| 1328 | rd4); |
| 1329 | |
| 1330 | HW::item<handle_t> hw_ifh2(4, rc_t::OK); |
| 1331 | HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK); |
| 1332 | HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1333 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); |
| 1334 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2)); |
| 1335 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2)); |
| 1336 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1337 | TRY_CHECK_RC(OM::write(ian, *itf2)); |
| 1338 | |
| 1339 | /* |
| 1340 | * prefix on each interface |
| 1341 | */ |
| 1342 | route::prefix_t pfx_10("10.10.10.10", 24); |
| 1343 | l3_binding *l3_10 = new l3_binding(itf1, pfx_10); |
| 1344 | HW::item<bool> hw_l3_10_bind(true, rc_t::OK); |
| 1345 | HW::item<bool> hw_l3_10_unbind(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1346 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1347 | TRY_CHECK_RC(OM::write(ian, *l3_10)); |
| 1348 | route::prefix_t pfx_11("11.11.11.11", 24); |
| 1349 | l3_binding *l3_11 = new l3_binding(*itf2, pfx_11); |
| 1350 | HW::item<bool> hw_l3_11_bind(true, rc_t::OK); |
| 1351 | HW::item<bool> hw_l3_11_unbind(false, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1352 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1353 | TRY_CHECK_RC(OM::write(ian, *l3_11)); |
| 1354 | |
| 1355 | /* |
| 1356 | * A route via interface 1 in the default table |
| 1357 | */ |
| 1358 | route::prefix_t pfx_5("5.5.5.5", 32); |
| 1359 | boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11"); |
| 1360 | route::path *path_10 = new route::path(nh_10, itf1); |
| 1361 | route::ip_route *route_5 = new route::ip_route(pfx_5); |
| 1362 | route_5->add(*path_10); |
| 1363 | HW::item<bool> hw_route_5(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1364 | ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, {*path_10})); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1365 | TRY_CHECK_RC(OM::write(ian, *route_5)); |
| 1366 | |
| 1367 | /* |
| 1368 | * A route via interface 2 in the non-default table |
| 1369 | */ |
| 1370 | boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10"); |
| 1371 | route::path *path_11 = new route::path(nh_11, *itf2); |
| 1372 | route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5); |
| 1373 | route_5_2->add(*path_11); |
| 1374 | HW::item<bool> hw_route_5_2(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1375 | ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, {*path_11})); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1376 | TRY_CHECK_RC(OM::write(ian, *route_5_2)); |
| 1377 | |
| 1378 | /* |
| 1379 | * An ARP entry for the neighbour on itf1 |
| 1380 | */ |
| 1381 | HW::item<bool> hw_neighbour(true, rc_t::OK); |
| 1382 | mac_address_t mac_n({0,1,2,4,5,6}); |
Neale Ranns | fd92060 | 2017-11-23 12:15:00 -0800 | [diff] [blame] | 1383 | neighbour *ne = new neighbour(itf1, nh_10, mac_n); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1384 | ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1385 | TRY_CHECK_RC(OM::write(ian, *ne)); |
| 1386 | |
| 1387 | /* |
| 1388 | * A DVR route |
| 1389 | */ |
| 1390 | route::prefix_t pfx_6("6.6.6.6", 32); |
| 1391 | route::path *path_l2 = new route::path(*itf2, nh_proto_t::ETHERNET); |
| 1392 | route::ip_route *route_dvr = new route::ip_route(pfx_6); |
| 1393 | route_dvr->add(*path_l2); |
| 1394 | HW::item<bool> hw_route_dvr(true, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1395 | ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, {*path_l2})); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1396 | TRY_CHECK_RC(OM::write(ian, *route_dvr)); |
| 1397 | |
| 1398 | STRICT_ORDER_OFF(); |
| 1399 | // delete the stack objects that hold references to others |
| 1400 | // so the OM::remove is the call that removes the last reference |
| 1401 | delete l3_11; |
| 1402 | delete l3_10; |
| 1403 | delete itf2; |
| 1404 | delete route_5; |
| 1405 | delete path_10; |
| 1406 | delete route_5_2; |
| 1407 | delete path_11; |
| 1408 | delete route_dvr; |
| 1409 | delete path_l2; |
| 1410 | delete ne; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1411 | ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10)); |
| 1412 | ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6)); |
| 1413 | ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5)); |
| 1414 | ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5)); |
| 1415 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10)); |
| 1416 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11)); |
| 1417 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1418 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); |
| 1419 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2)); |
| 1420 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2)); |
| 1421 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2)); |
| 1422 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); |
| 1423 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1)); |
| 1424 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1425 | |
| 1426 | TRY_CHECK(OM::remove(ian)); |
| 1427 | } |
| 1428 | |
| 1429 | BOOST_AUTO_TEST_CASE(test_nat) { |
| 1430 | VppInit vi; |
| 1431 | const std::string gs = "GeorgeSimenon"; |
| 1432 | rc_t rc = rc_t::OK; |
| 1433 | |
| 1434 | /* |
| 1435 | * Inside Interface |
| 1436 | */ |
| 1437 | std::string itf_in_name = "inside"; |
| 1438 | interface itf_in(itf_in_name, |
| 1439 | interface::type_t::AFPACKET, |
| 1440 | interface::admin_state_t::UP); |
| 1441 | HW::item<handle_t> hw_ifh(2, rc_t::OK); |
| 1442 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
| 1443 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1444 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name)); |
| 1445 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1446 | TRY_CHECK_RC(OM::write(gs, itf_in)); |
| 1447 | |
| 1448 | /* |
| 1449 | * outside |
| 1450 | */ |
| 1451 | std::string itf_out_name = "port-to"; |
| 1452 | interface itf_out(itf_out_name, |
| 1453 | interface::type_t::AFPACKET, |
| 1454 | interface::admin_state_t::UP); |
| 1455 | |
| 1456 | HW::item<handle_t> hw_ifh2(4, rc_t::OK); |
| 1457 | HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK); |
| 1458 | HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK); |
| 1459 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1460 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name)); |
| 1461 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1462 | TRY_CHECK_RC(OM::write(gs, itf_out)); |
| 1463 | |
| 1464 | /* |
| 1465 | * A NAT static mapping |
| 1466 | */ |
| 1467 | boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1"); |
| 1468 | boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1"); |
| 1469 | |
| 1470 | nat_static ns(in_addr, out_addr); |
| 1471 | HW::item<bool> hw_ns(true, rc_t::OK); |
| 1472 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1473 | ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1474 | TRY_CHECK_RC(OM::write(gs, ns)); |
| 1475 | |
| 1476 | /* |
| 1477 | * bind nat inside and out |
| 1478 | */ |
| 1479 | nat_binding *nb_in = new nat_binding(itf_in, |
| 1480 | direction_t::INPUT, |
| 1481 | l3_proto_t::IPV4, |
| 1482 | nat_binding::zone_t::INSIDE); |
| 1483 | HW::item<bool> hw_nb_in(true, rc_t::OK); |
| 1484 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1485 | ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in, |
| 1486 | hw_ifh.data().value(), |
| 1487 | nat_binding::zone_t::INSIDE)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1488 | TRY_CHECK_RC(OM::write(gs, *nb_in)); |
| 1489 | |
| 1490 | nat_binding *nb_out = new nat_binding(itf_out, |
| 1491 | direction_t::INPUT, |
| 1492 | l3_proto_t::IPV4, |
| 1493 | nat_binding::zone_t::OUTSIDE); |
| 1494 | HW::item<bool> hw_nb_out(true, rc_t::OK); |
| 1495 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1496 | ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out, |
| 1497 | hw_ifh2.data().value(), |
| 1498 | nat_binding::zone_t::OUTSIDE)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1499 | TRY_CHECK_RC(OM::write(gs, *nb_out)); |
| 1500 | |
| 1501 | |
| 1502 | STRICT_ORDER_OFF(); |
| 1503 | delete nb_in; |
| 1504 | delete nb_out; |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1505 | ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in, |
| 1506 | hw_ifh.data().value(), |
| 1507 | nat_binding::zone_t::INSIDE)); |
| 1508 | ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out, |
| 1509 | hw_ifh2.data().value(), |
| 1510 | nat_binding::zone_t::OUTSIDE)); |
| 1511 | ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr)); |
| 1512 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); |
| 1513 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name)); |
| 1514 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2)); |
| 1515 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name)); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1516 | |
| 1517 | TRY_CHECK(OM::remove(gs)); |
| 1518 | } |
| 1519 | |
| 1520 | BOOST_AUTO_TEST_CASE(test_interface_events) { |
| 1521 | VppInit vi; |
| 1522 | MockListener ml; |
| 1523 | |
| 1524 | HW::item<bool> hw_want(true, rc_t::OK); |
| 1525 | |
Neale Ranns | 9ef1c0a | 2017-11-03 04:39:05 -0700 | [diff] [blame] | 1526 | ADD_EXPECT(interface_cmds::events_cmd(ml)); |
| 1527 | cmd* itf = new interface_cmds::events_cmd(ml); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1528 | |
| 1529 | HW::enqueue(itf); |
| 1530 | HW::write(); |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1531 | } |
| 1532 | |
Neale Ranns | 352ea0c | 2017-11-14 11:04:28 -0800 | [diff] [blame] | 1533 | BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) { |
| 1534 | VppInit vi; |
| 1535 | const std::string rene = "ReneGoscinny"; |
| 1536 | rc_t rc = rc_t::OK; |
| 1537 | |
| 1538 | /* |
| 1539 | * Create an interface with two IP addresses |
| 1540 | */ |
| 1541 | std::string itf1_name = "host1"; |
| 1542 | interface itf1(itf1_name, |
| 1543 | interface::type_t::AFPACKET, |
| 1544 | interface::admin_state_t::UP); |
| 1545 | HW::item<handle_t> hw_ifh1(2, rc_t::OK); |
| 1546 | HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK); |
| 1547 | HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); |
| 1548 | ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name)); |
| 1549 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1)); |
| 1550 | TRY_CHECK_RC(OM::write(rene, itf1)); |
| 1551 | |
| 1552 | route::prefix_t pfx_10("10.10.10.10", 24); |
| 1553 | l3_binding *l3_1 = new l3_binding(itf1, pfx_10); |
| 1554 | HW::item<bool> hw_l3_bind1(true, rc_t::OK); |
| 1555 | HW::item<bool> hw_l3_unbind1(false, rc_t::OK); |
| 1556 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10)); |
| 1557 | TRY_CHECK_RC(OM::write(rene, *l3_1)); |
| 1558 | |
| 1559 | route::prefix_t pfx_11("10.10.11.11", 24); |
| 1560 | l3_binding *l3_2 = new l3_binding(itf1, pfx_11); |
| 1561 | HW::item<bool> hw_l3_bind2(true, rc_t::OK); |
| 1562 | HW::item<bool> hw_l3_unbind2(false, rc_t::OK); |
| 1563 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11)); |
| 1564 | TRY_CHECK_RC(OM::write(rene, *l3_2)); |
| 1565 | |
| 1566 | route_domain rd(1); |
| 1567 | HW::item<bool> hw_rd_create(true, rc_t::OK); |
| 1568 | HW::item<bool> hw_rd_delete(false, rc_t::OK); |
| 1569 | HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK); |
| 1570 | HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK); |
| 1571 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1)); |
| 1572 | ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1)); |
| 1573 | TRY_CHECK_RC(OM::write(rene, rd)); |
| 1574 | |
| 1575 | /* |
| 1576 | * update the interface to change to a new route-domain |
| 1577 | * expect that the l3-bindings are removed and readded. |
| 1578 | */ |
| 1579 | interface *itf2 = new interface(itf1_name, |
| 1580 | interface::type_t::AFPACKET, |
| 1581 | interface::admin_state_t::UP, |
| 1582 | rd); |
| 1583 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10)); |
| 1584 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11)); |
| 1585 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1)); |
| 1586 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1)); |
| 1587 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10)); |
| 1588 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11)); |
| 1589 | TRY_CHECK_RC(OM::write(rene, *itf2)); |
| 1590 | |
| 1591 | /* |
| 1592 | * mve the interface back to the default route-domain |
| 1593 | */ |
| 1594 | interface itf3(itf1_name, |
| 1595 | interface::type_t::AFPACKET, |
| 1596 | interface::admin_state_t::UP); |
| 1597 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10)); |
| 1598 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11)); |
| 1599 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1)); |
| 1600 | ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1)); |
| 1601 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10)); |
| 1602 | ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11)); |
| 1603 | TRY_CHECK_RC(OM::write(rene, itf3)); |
| 1604 | |
| 1605 | delete l3_1; |
| 1606 | delete l3_2; |
| 1607 | delete itf2; |
| 1608 | |
| 1609 | STRICT_ORDER_OFF(); |
| 1610 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10)); |
| 1611 | ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11)); |
| 1612 | ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1)); |
| 1613 | ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name)); |
| 1614 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1)); |
| 1615 | ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1)); |
| 1616 | |
| 1617 | TRY_CHECK(OM::remove(rene)); |
| 1618 | } |
| 1619 | |
Neale Ranns | d3464b5 | 2017-12-07 08:48:02 -0800 | [diff] [blame] | 1620 | BOOST_AUTO_TEST_CASE(test_prefixes) { |
| 1621 | route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16); |
| 1622 | |
| 1623 | BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::")); |
| 1624 | |
| 1625 | route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17); |
| 1626 | |
| 1627 | BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::")); |
| 1628 | BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::")); |
| 1629 | |
| 1630 | route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15); |
| 1631 | BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::")); |
| 1632 | BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::")); |
| 1633 | |
| 1634 | route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16); |
| 1635 | |
| 1636 | BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0")); |
| 1637 | |
| 1638 | route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17); |
| 1639 | |
| 1640 | BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0")); |
| 1641 | BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0")); |
| 1642 | BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255")); |
| 1643 | |
| 1644 | route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15); |
| 1645 | |
| 1646 | BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0")); |
| 1647 | BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0")); |
| 1648 | BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255")); |
| 1649 | |
| 1650 | route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32); |
| 1651 | |
| 1652 | BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255")); |
| 1653 | BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1")); |
| 1654 | BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1")); |
| 1655 | |
| 1656 | } |
| 1657 | |
Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame] | 1658 | BOOST_AUTO_TEST_SUITE_END() |