blob: 29738e2437ef93939de8462484f5a227f131e6a7 [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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 Ranns9ef1c0a2017-11-03 04:39:05 -070022#include "vom/interface_cmds.hpp"
Mohsin Kazmied76ee22018-03-02 12:31:37 +010023#include "vom/bond_interface_cmds.hpp"
24#include "vom/bond_group_binding.hpp"
25#include "vom/bond_group_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070026#include "vom/l2_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070027#include "vom/l2_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070028#include "vom/l3_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070029#include "vom/l3_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070030#include "vom/bridge_domain.hpp"
31#include "vom/bridge_domain_entry.hpp"
32#include "vom/bridge_domain_arp_entry.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070033#include "vom/bridge_domain_cmds.hpp"
34#include "vom/bridge_domain_entry_cmds.hpp"
35#include "vom/bridge_domain_arp_entry_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070036#include "vom/prefix.hpp"
37#include "vom/route.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070038#include "vom/route_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070039#include "vom/route_domain.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070040#include "vom/route_domain_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070041#include "vom/vxlan_tunnel.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070042#include "vom/vxlan_tunnel_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070043#include "vom/sub_interface.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070044#include "vom/sub_interface_cmds.hpp"
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +010045#include "vom/acl_ethertype.hpp"
46#include "vom/acl_ethertype_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070047#include "vom/acl_list.hpp"
48#include "vom/acl_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070049#include "vom/acl_list_cmds.hpp"
50#include "vom/acl_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070051#include "vom/acl_l3_rule.hpp"
52#include "vom/acl_l2_rule.hpp"
53#include "vom/arp_proxy_config.hpp"
54#include "vom/arp_proxy_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070055#include "vom/arp_proxy_config_cmds.hpp"
56#include "vom/arp_proxy_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070057#include "vom/ip_unnumbered.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070058#include "vom/ip_unnumbered_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070059#include "vom/interface_ip6_nd.hpp"
60#include "vom/interface_span.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070061#include "vom/interface_span_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070062#include "vom/neighbour.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070063#include "vom/neighbour_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070064#include "vom/nat_static.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070065#include "vom/nat_static_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070066#include "vom/nat_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070067#include "vom/nat_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070068
69using namespace boost;
70using namespace VOM;
71
72/**
73 * An expectation exception
74 */
75class ExpException
76{
77public:
78 ExpException(unsigned int number)
79 {
80 // a neat place to add a break point
81 std::cout << " ExpException here: " << number << std::endl;
82 }
83};
84
85class MockListener : public interface::event_listener,
86 public interface::stat_listener
87{
Neale Rannsa2ee0292017-11-28 22:29:13 -080088 void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd)
Neale Ranns812ed392017-10-16 04:20:13 -070089 {
90 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070091 void handle_interface_event(interface_cmds::events_cmd *cmd)
Neale Ranns812ed392017-10-16 04:20:13 -070092 {
93 }
94};
95
96class MockCmdQ : public HW::cmd_q
97{
98public:
99 MockCmdQ():
100 m_strict_order(true)
101 {
102 }
103 virtual ~MockCmdQ()
104 {
105 }
106 void expect(cmd *f)
107 {
108 m_exp_queue.push_back(f);
109 }
110 void enqueue(cmd *f)
111 {
112 m_act_queue.push_back(f);
113 }
114 void enqueue(std::queue<cmd*> &cmds)
115 {
116 while (cmds.size())
117 {
118 m_act_queue.push_back(cmds.front());
119 cmds.pop();
120 }
121 }
122 void enqueue(std::shared_ptr<cmd> f)
123 {
124 m_act_queue.push_back(f.get());
125 }
126
127 void dequeue(cmd *f)
128 {
129 }
130
131 void dequeue(std::shared_ptr<cmd> cmd)
132 {
133 }
134
135 void strict_order(bool on)
136 {
137 m_strict_order = on;
138 }
139
140 bool is_empty()
141 {
142 return ((0 == m_exp_queue.size()) &&
143 (0 == m_act_queue.size()));
144 }
145
146 rc_t write()
147 {
148 cmd *f_exp, *f_act;
149 rc_t rc = rc_t::OK;
150
151 while (m_act_queue.size())
152 {
153 bool matched = false;
154 auto it_exp = m_exp_queue.begin();
155 auto it_act = m_act_queue.begin();
156
157 f_act = *it_act;
158
159 std::cout << " Act: " << f_act->to_string() << std::endl;
160 while (it_exp != m_exp_queue.end())
161 {
162 f_exp = *it_exp;
163 try
164 {
165 std::cout << " Exp: " << f_exp->to_string() << std::endl;
166
167 if (typeid(*f_exp) != typeid(*f_act))
168 {
169 throw ExpException(1);
170 }
171
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700172 if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700173 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700174 rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700175 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700176 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700177 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700178 rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700179 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800180 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd))
181 {
182 rc = handle_derived<interface_cmds::vhost_create_cmd>(f_exp, f_act);
183 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100184 else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd))
185 {
186 rc = handle_derived<bond_interface_cmds::create_cmd>(f_exp, f_act);
187 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700188 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700189 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700190 rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700191 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700192 else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700193 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700194 rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700195 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800196 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd))
197 {
198 rc = handle_derived<interface_cmds::vhost_delete_cmd>(f_exp, f_act);
199 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100200 else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd))
201 {
202 rc = handle_derived<bond_interface_cmds::delete_cmd>(f_exp, f_act);
203 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700204 else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700205 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700206 rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700207 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700208 else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700209 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700210 rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700211 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700212 else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700213 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700214 rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700215 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700216 else if (typeid(*f_exp) == typeid(interface_cmds::set_tag))
Neale Ranns812ed392017-10-16 04:20:13 -0700217 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700218 rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700219 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100220 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd))
221 {
222 rc = handle_derived<bond_group_binding_cmds::bind_cmd>(f_exp, f_act);
223 }
224 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd))
225 {
226 rc = handle_derived<bond_group_binding_cmds::unbind_cmd>(f_exp, f_act);
227 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700228 else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700229 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700230 rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700231 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700232 else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700233 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700234 rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700235 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700236 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700237 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700238 rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700239 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700240 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700241 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700242 rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700243 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700244 else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700245 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700246 rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700247 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700248 else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700249 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700250 rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700251 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700252 else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700253 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700254 rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700255 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700256 else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700257 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700258 rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700259 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700260 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700261 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700262 rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700263 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700264 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700265 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700266 rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700267 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700268 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700269 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700270 rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700271 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700272 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700273 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700274 rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700275 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700276 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700277 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700278 rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700279 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700280 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700281 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700282 rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700283 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700284 else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700285 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700286 rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700287 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700288 else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700289 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700290 rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700291 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700292 else if (typeid(*f_exp) == typeid(l2_binding_cmds::set_vtr_op_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700293 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700294 rc = handle_derived<l2_binding_cmds::set_vtr_op_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700295 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700296 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700297 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700298 rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700299 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700300 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700301 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700302 rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700303 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700304 else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700305 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700306 rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700307 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700308 else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700309 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700310 rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700311 }
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +0100312 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd))
313 {
314 rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act);
315 }
Mohsin Kazmi04def742018-03-07 19:53:51 +0100316 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd))
317 {
318 rc = handle_derived<ACL::acl_ethertype_cmds::unbind_cmd>(f_exp, f_act);
319 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700320 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700321 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700322 rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700323 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700324 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700325 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700326 rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700327 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700328 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700329 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700330 rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700331 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700332 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700333 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700334 rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700335 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700336 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700337 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700338 rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700339 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700340 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700341 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700342 rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700343 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700344 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700345 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700346 rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700347 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700348 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700349 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700350 rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700351 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700352 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700353 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700354 rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700355 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700356 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700357 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700358 rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700359 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700360 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700361 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700362 rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700363 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700364 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700365 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700366 rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700367 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700368 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700369 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700370 rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700371 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700372 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700373 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700374 rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700375 }
376 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd))
377 {
378 rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act);
379 }
380 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd))
381 {
382 rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act);
383 }
384 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd))
385 {
386 rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act);
387 }
388 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd))
389 {
390 rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act);
391 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700392 else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700393 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700394 rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700395 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700396 else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700397 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700398 rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700399 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700400 else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700401 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700402 rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700403 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700404 else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700405 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700406 rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700407 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700408 else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700409 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700410 rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700411 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700412 else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700413 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700414 rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700415 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700416 else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700417 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700418 rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700419 }
420 else
421 {
422 throw ExpException(2);
423 }
424
425 // if we get here then we found the match.
426 m_exp_queue.erase(it_exp);
427 m_act_queue.erase(it_act);
428 delete f_exp;
429 delete f_act;
430
431 // return any injected failures to the agent
432 if (rc_t::OK != rc && rc_t::NOOP != rc)
433 {
434 return (rc);
435 }
436
437 matched = true;
438 break;
439 }
440 catch (ExpException &e)
441 {
442 // The expected and actual do not match
443 if (m_strict_order)
444 {
445 // in strict ordering mode this is fatal, so rethrow
446 throw e;
447 }
448 else
449 {
450 // move the iterator onto the next in the expected list and
451 // check for a match
452 ++it_exp;
453 }
454 }
455 }
456
457 if (!matched)
458 throw ExpException(3);
459 }
460
461 return (rc);
462 }
463private:
464
465 template <typename T>
466 rc_t handle_derived(const cmd *f_exp, cmd *f_act)
467 {
468 const T *i_exp;
469 T *i_act;
470
471 i_exp = dynamic_cast<const T*>(f_exp);
472 i_act = dynamic_cast<T*>(f_act);
473 if (!(*i_exp == *i_act))
474 {
475 throw ExpException(4);
476 }
477 // pass the data and return code to the agent
478 i_act->item() = i_exp->item();
479
480 return (i_act->item().rc());
481 }
482
483 // The Q to push the expectations on
484 std::deque<cmd*> m_exp_queue;
485
486 // the queue to push the actual events on
487 std::deque<cmd*> m_act_queue;
488
489 // control whether the expected queue is strictly ordered.
490 bool m_strict_order;
491};
492
493class VppInit {
494public:
495 std::string name;
496 MockCmdQ *f;
497
498 VppInit()
499 : name("vpp-ut"),
500 f(new MockCmdQ())
501 {
502 HW::init(f);
503 OM::init();
504 logger().set(log_level_t::DEBUG);
505 }
506
507 ~VppInit() {
508 delete f;
509 }
510};
511
Neale Rannsd3464b52017-12-07 08:48:02 -0800512BOOST_AUTO_TEST_SUITE(vom)
Neale Ranns812ed392017-10-16 04:20:13 -0700513
514#define TRY_CHECK_RC(stmt) \
515{ \
516 try { \
517 BOOST_CHECK(rc_t::OK == stmt); \
518 } \
519 catch (ExpException &e) \
520 { \
521 BOOST_CHECK(false); \
522 } \
523 BOOST_CHECK(vi.f->is_empty()); \
524}
525
526#define TRY_CHECK(stmt) \
527{ \
528 try { \
529 stmt; \
530 } \
531 catch (ExpException &e) \
532 { \
533 BOOST_CHECK(false); \
534 } \
535 BOOST_CHECK(vi.f->is_empty()); \
536}
537
538#define ADD_EXPECT(stmt) \
539 vi.f->expect(new stmt)
540
541#define STRICT_ORDER_OFF() \
542 vi.f->strict_order(false)
543
544BOOST_AUTO_TEST_CASE(test_interface) {
545 VppInit vi;
546 const std::string go = "GeorgeOrwell";
547 const std::string js = "JohnSteinbeck";
548 rc_t rc = rc_t::OK;
549
550 /*
551 * George creates and deletes the interface
552 */
553 std::string itf1_name = "afpacket1";
554 interface itf1(itf1_name,
555 interface::type_t::AFPACKET,
556 interface::admin_state_t::UP);
557
558 /*
559 * set the expectation for a afpacket interface create.
560 * 2 is the interface handle VPP [mock] assigns
561 */
562 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700563 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700564
565 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700566 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700567
568 TRY_CHECK_RC(OM::write(go, itf1));
569
570 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700571 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
572 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700573
574 TRY_CHECK(OM::remove(go));
575
576 /*
577 * George creates the interface, then John brings it down.
578 * George's remove is a no-op, sice John also owns the interface
579 */
580 interface itf1b(itf1_name,
581 interface::type_t::AFPACKET,
582 interface::admin_state_t::DOWN);
583
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700584 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
585 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700586 TRY_CHECK_RC(OM::write(go, itf1));
587
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700588 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700589 TRY_CHECK_RC(OM::write(js, itf1b));
590
591 TRY_CHECK(OM::remove(go));
592
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700593 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700594 TRY_CHECK(OM::remove(js));
595
596 /*
597 * George adds an interface, then we flush all of Geroge's state
598 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700599 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
600 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700601 TRY_CHECK_RC(OM::write(go, itf1));
602
603 TRY_CHECK(OM::mark(go));
604
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700605 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
606 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700607 TRY_CHECK(OM::sweep(go));
608
609 /*
610 * George adds an interface. mark stale. update the same interface. sweep
611 * and expect no delete
612 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700613 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
614 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700615 TRY_CHECK_RC(OM::write(go, itf1b));
616
617 TRY_CHECK(OM::mark(go));
618
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700619 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700620 TRY_CHECK_RC(OM::write(go, itf1));
621
622 TRY_CHECK(OM::sweep(go));
623
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700624 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
625 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700626 TRY_CHECK(OM::remove(go));
627
628 /*
629 * George adds an insterface, then we mark that state. Add a second interface
630 * an flush the first that is now stale.
631 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700632 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
633 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700634 TRY_CHECK_RC(OM::write(go, itf1));
635
636 TRY_CHECK(OM::mark(go));
637
638 std::string itf2_name = "afpacket2";
Neale Ranns4ef42262018-02-20 08:10:44 -0800639 std::string itf2_tag = "uuid-of-afpacket2-interface";
Neale Ranns812ed392017-10-16 04:20:13 -0700640 interface itf2(itf2_name,
641 interface::type_t::AFPACKET,
Neale Ranns4ef42262018-02-20 08:10:44 -0800642 interface::admin_state_t::UP,
643 itf2_tag);
Neale Ranns812ed392017-10-16 04:20:13 -0700644 HW::item<handle_t> hw_ifh2(3, rc_t::OK);
645
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700646 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
Neale Ranns4ef42262018-02-20 08:10:44 -0800647 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700648 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700649 TRY_CHECK_RC(OM::write(go, itf2));
650
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700651 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
652 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700653 TRY_CHECK(OM::sweep(go));
654
655 TRY_CHECK(OM::mark(go));
656
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700657 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
658 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700659 TRY_CHECK(OM::sweep(go));
Neale Ranns4ef42262018-02-20 08:10:44 -0800660
661
662 std::string itf3_name = "/PATH/TO/vhost_user1.sock";
663 std::string itf3_tag = "uuid-of-vhost_user1-interface";
664 interface itf3(itf3_name,
665 interface::type_t::VHOST,
666 interface::admin_state_t::UP,
667 itf3_tag);
668 HW::item<handle_t> hw_ifh3(4, rc_t::OK);
669
670 ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag));
671 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
672 TRY_CHECK_RC(OM::write(go, itf3));
673
674 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
675 ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name));
676 TRY_CHECK(OM::remove(go));
Neale Ranns812ed392017-10-16 04:20:13 -0700677}
678
679BOOST_AUTO_TEST_CASE(test_bvi) {
680 VppInit vi;
681 const std::string ernest = "ErnestHemmingway";
682 const std::string graham = "GrahamGreene";
683 rc_t rc = rc_t::OK;
684 l3_binding *l3;
685
686 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
687 rc_t::OK);
688 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
689 rc_t::OK);
690
691 /*
692 * Enrest creates a BVI with address 10.10.10.10/24
693 */
694 route::prefix_t pfx_10("10.10.10.10", 24);
695
696 const std::string bvi_name = "bvi1";
697 interface itf(bvi_name,
698 interface::type_t::BVI,
699 interface::admin_state_t::UP);
700 HW::item<handle_t> hw_ifh(4, rc_t::OK);
701 HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK);
702
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700703 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh, bvi_name));
704 ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name));
705 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700706 TRY_CHECK_RC(OM::write(ernest, itf));
707
708 l3 = new l3_binding(itf, pfx_10);
709 HW::item<bool> hw_l3_bind(true, rc_t::OK);
710 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700711 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700712 TRY_CHECK_RC(OM::write(ernest, *l3));
713
714 // change the MAC address on the BVI
715 interface itf_new_mac(bvi_name,
716 interface::type_t::BVI,
717 interface::admin_state_t::UP);
718 l2_address_t l2_addr({0,1,2,3,4,5});
719 HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK);
720 itf_new_mac.set(l2_addr);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700721 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700722 TRY_CHECK_RC(OM::write(ernest, itf_new_mac));
723
724 // create/write the interface to the OM again but with an unset MAC
725 // this should not generate a MAC address update
726 TRY_CHECK_RC(OM::write(ernest, itf));
727
728 // change the MAC address on the BVI - again
729 interface itf_new_mac2(bvi_name,
730 interface::type_t::BVI,
731 interface::admin_state_t::UP);
732 l2_address_t l2_addr2({0,1,2,3,4,6});
733 HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK);
734 itf_new_mac2.set(l2_addr2);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700735 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700736 TRY_CHECK_RC(OM::write(ernest, itf_new_mac2));
737
738 delete l3;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700739 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
740 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
741 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700742 TRY_CHECK(OM::remove(ernest));
743
744 /*
745 * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain
746 */
747 route_domain rd(1);
748 HW::item<bool> hw_rd4_create(true, rc_t::OK);
749 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
750 HW::item<bool> hw_rd6_create(true, rc_t::OK);
751 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
752 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
753 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
754 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
755 HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700756 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
757 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700758 TRY_CHECK_RC(OM::write(graham, rd));
759
760 const std::string bvi2_name = "bvi2";
761 interface *itf2 = new interface(bvi2_name,
762 interface::type_t::BVI,
763 interface::admin_state_t::UP,
764 rd);
765 HW::item<handle_t> hw_ifh2(5, rc_t::OK);
766
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700767 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh2, bvi2_name));
768 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name));
769 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
770 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
771 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700772
773 TRY_CHECK_RC(OM::write(graham, *itf2));
774
775 l3 = new l3_binding(*itf2, pfx_10);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700776 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700777 TRY_CHECK_RC(OM::write(graham, *l3));
778
779 delete l3;
780 delete itf2;
781
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700782 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10));
783 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
784 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2));
785 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
786 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh2));
787 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
788 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700789 TRY_CHECK(OM::remove(graham));
790}
791
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100792BOOST_AUTO_TEST_CASE(test_bond) {
793 VppInit vi;
794 const std::string cb = "CarolBerg";
795 rc_t rc = rc_t::OK;
796
797 /*
798 * creates the interfaces
799 */
800 std::string itf1_name = "afpacket1";
801 interface itf1(itf1_name,
802 interface::type_t::AFPACKET,
803 interface::admin_state_t::UP);
804
805 HW::item<handle_t> hw_ifh(2, rc_t::OK);
806 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
807
808 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
809 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
810
811 TRY_CHECK_RC(OM::write(cb, itf1));
812
813 std::string itf2_name = "afpacket2";
814 interface itf2(itf2_name,
815 interface::type_t::AFPACKET,
816 interface::admin_state_t::UP);
817
818
819 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
820 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
821 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
822
823 TRY_CHECK_RC(OM::write(cb, itf2));
824
825 std::string bond_name = "bond";
826 bond_interface bond_itf(bond_name, interface::admin_state_t::UP,
827 bond_interface::mode_t::LACP);
828
829 HW::item<handle_t> hw_ifh3(6, rc_t::OK);
830 ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name,
831 bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO));
832 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
833
834 TRY_CHECK_RC(OM::write(cb, bond_itf));
835
836 bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE,
837 bond_member::rate_t::SLOW);
838 bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE,
839 bond_member::rate_t::SLOW);
840 bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2});
841
842 HW::item<bool> bond_hw_bind(true, rc_t::OK);
843 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1));
844 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2));
845
846 TRY_CHECK_RC(OM::write(cb, *bgb));
847
848 delete bgb;
849 delete bm2;
850 delete bm1;
851
852 STRICT_ORDER_OFF();
853 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
854 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data()));
855 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data()));
856 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
857 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
858 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
859 ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3));
860 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
861 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
862
863 TRY_CHECK(OM::remove(cb));
864}
865
Neale Ranns812ed392017-10-16 04:20:13 -0700866BOOST_AUTO_TEST_CASE(test_bridge) {
867 VppInit vi;
868 const std::string franz = "FranzKafka";
869 const std::string dante = "Dante";
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100870 const std::string jkr = "jkrowling";
Neale Ranns812ed392017-10-16 04:20:13 -0700871 rc_t rc = rc_t::OK;
872
873 /*
874 * Franz creates an interface, Bridge-domain, then binds the two
875 */
876
877 // interface create
878 std::string itf1_name = "afpacket1";
879 interface itf1(itf1_name,
880 interface::type_t::AFPACKET,
881 interface::admin_state_t::UP);
882
883 HW::item<handle_t> hw_ifh(3, rc_t::OK);
884 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
885 rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700886 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
887 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700888
889 TRY_CHECK_RC(OM::write(franz, itf1));
890
891 // bridge-domain create
892 bridge_domain bd1(33);
893
894 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns10e7a9f2017-11-14 08:40:43 -0800895 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::ON));
Neale Ranns812ed392017-10-16 04:20:13 -0700896
897 TRY_CHECK_RC(OM::write(franz, bd1));
898
899 // L2-interface create and bind
900 // this needs to be delete'd before the flush below, since it too maintains
901 // references to the BD and Interface
902 l2_binding *l2itf = new l2_binding(itf1, bd1);
903 HW::item<bool> hw_l2_bind(true, rc_t::OK);
904
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700905 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false));
Neale Ranns812ed392017-10-16 04:20:13 -0700906 TRY_CHECK_RC(OM::write(franz, *l2itf));
907
908 /*
909 * Dante adds an interface to the same BD
910 */
911 std::string itf2_name = "afpacket2";
912 interface itf2(itf2_name,
913 interface::type_t::AFPACKET,
914 interface::admin_state_t::UP);
915
916 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700917 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
918 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700919 TRY_CHECK_RC(OM::write(dante, itf2));
920
921 // BD add is a no-op since it exists
922 TRY_CHECK_RC(OM::write(dante, bd1));
923
924 l2_binding *l2itf2 = new l2_binding(itf2, bd1);
925 HW::item<l2_binding::l2_vtr_op_t> hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK);
926 l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68);
927
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700928 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false));
929 ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68));
Neale Ranns812ed392017-10-16 04:20:13 -0700930 TRY_CHECK_RC(OM::write(dante, *l2itf2));
931
932 // Add some static entries to the bridge-domain
933 HW::item<bool> hw_be1(true, rc_t::OK);
934 mac_address_t mac1({0,1,2,3,4,5});
935 bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100936 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
937 false));
Neale Ranns812ed392017-10-16 04:20:13 -0700938 TRY_CHECK_RC(OM::write(dante, *be1));
939
940 // Add some entries to the bridge-domain ARP termination table
941 HW::item<bool> hw_bea1(true, rc_t::OK);
942 boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10");
943
Neale Rannsfd920602017-11-23 12:15:00 -0800944 bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700945 ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1));
Neale Ranns812ed392017-10-16 04:20:13 -0700946 TRY_CHECK_RC(OM::write(dante, *bea1));
947
948 // flush Franz's state
949 delete l2itf;
950 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
951 rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700952 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false));
953 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
954 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700955 TRY_CHECK(OM::remove(franz));
956
957 // flush Dante's state - the order the interface and BD are deleted
958 // is an uncontrollable artifact of the C++ object destruction.
959 delete l2itf2;
960 delete be1;
961 delete bea1;
962 STRICT_ORDER_OFF();
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100963 ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
964 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700965 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100966
967 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700968 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
969 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700970 TRY_CHECK(OM::remove(dante));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100971
972 // test the BVI entry in l2fib
973 bridge_domain bd2(99);
974
975 HW::item<uint32_t> hw_bd2(99, rc_t::OK);
976 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2, bridge_domain::learning_mode_t::ON));
977
978 TRY_CHECK_RC(OM::write(jkr, bd2));
979
980 std::string itf3_name = "bvi";
981 interface itf3(itf3_name,
982 interface::type_t::BVI,
983 interface::admin_state_t::UP);
984
985 HW::item<handle_t> hw_ifh3(5, rc_t::OK);
986 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name));
987 ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
988 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
989 TRY_CHECK_RC(OM::write(jkr, itf3));
990
991 l2_binding *l2itf3 = new l2_binding(itf3, bd2);
992 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
993 TRY_CHECK_RC(OM::write(jkr, *l2itf3));
994
995 HW::item<bool> hw_be2(true, rc_t::OK);
996 mac_address_t mac2({0,1,2,3,4,5});
997 bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
998 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
999 TRY_CHECK_RC(OM::write(jkr, *be2));
1000
1001 delete l2itf3;
1002 delete be2;
1003 STRICT_ORDER_OFF();
1004 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
1005 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
1006 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
1007 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3));
1008 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
1009 TRY_CHECK(OM::remove(jkr));
Neale Ranns812ed392017-10-16 04:20:13 -07001010}
1011
1012BOOST_AUTO_TEST_CASE(test_vxlan) {
1013 VppInit vi;
1014 const std::string franz = "FranzKafka";
1015 rc_t rc = rc_t::OK;
1016
1017 /*
1018 * Franz creates an interface, Bridge-domain, then binds the two
1019 */
1020
1021 // VXLAN create
1022 vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"),
1023 boost::asio::ip::address::from_string("10.10.10.11"),
1024 322);
1025
1026 vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);
1027
1028 HW::item<handle_t> hw_vxt(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001029 ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep));
Neale Ranns812ed392017-10-16 04:20:13 -07001030
1031 TRY_CHECK_RC(OM::write(franz, vxt));
1032
1033 // bridge-domain create
Neale Ranns10e7a9f2017-11-14 08:40:43 -08001034 bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF);
Neale Ranns812ed392017-10-16 04:20:13 -07001035
1036 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns10e7a9f2017-11-14 08:40:43 -08001037 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::OFF));
Neale Ranns812ed392017-10-16 04:20:13 -07001038
1039 TRY_CHECK_RC(OM::write(franz, bd1));
1040
1041 // L2-interface create and bind
1042 // this needs to be delete'd before the flush below, since it too maintains
1043 // references to the BD and Interface
1044 l2_binding *l2itf = new l2_binding(vxt, bd1);
1045 HW::item<bool> hw_l2_bind(true, rc_t::OK);
1046
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001047 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false));
Neale Ranns812ed392017-10-16 04:20:13 -07001048 TRY_CHECK_RC(OM::write(franz, *l2itf));
1049
1050 // flush Franz's state
1051 delete l2itf;
1052 HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP);
1053 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001054 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false));
1055 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
1056 ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep));
Neale Ranns812ed392017-10-16 04:20:13 -07001057 TRY_CHECK(OM::remove(franz));
1058}
1059
1060BOOST_AUTO_TEST_CASE(test_vlan) {
1061 VppInit vi;
1062 const std::string noam = "NoamChomsky";
1063 rc_t rc = rc_t::OK;
1064
1065 std::string itf1_name = "host1";
1066 interface itf1(itf1_name,
1067 interface::type_t::AFPACKET,
1068 interface::admin_state_t::UP);
1069
1070 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001071 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001072
1073 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001074 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001075
1076 TRY_CHECK_RC(OM::write(noam, itf1));
1077
1078 sub_interface *vl33 = new sub_interface(itf1,
1079 interface::admin_state_t::UP,
1080 33);
1081
1082 HW::item<handle_t> hw_vl33(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001083 ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33));
1084 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33));
Neale Ranns812ed392017-10-16 04:20:13 -07001085
1086 TRY_CHECK_RC(OM::write(noam, *vl33));
1087
1088 delete vl33;
1089 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1090 HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001091 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33));
1092 ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down));
1093 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1094 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001095
1096 TRY_CHECK(OM::remove(noam));
1097}
1098
1099BOOST_AUTO_TEST_CASE(test_acl) {
1100 VppInit vi;
1101 const std::string fyodor = "FyodorDostoyevsky";
1102 const std::string leo = "LeoTolstoy";
1103 rc_t rc = rc_t::OK;
1104
1105 /*
1106 * Fyodor adds an ACL in the input direction
1107 */
1108 std::string itf1_name = "host1";
1109 interface itf1(itf1_name,
1110 interface::type_t::AFPACKET,
1111 interface::admin_state_t::UP);
1112 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1113 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001114 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1115 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001116 TRY_CHECK_RC(OM::write(fyodor, itf1));
1117
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001118 ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT);
1119 ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT);
1120 ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT);
1121 ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3};
1122 ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e);
1123 HW::item<bool> ae_binding(true, rc_t::OK);
1124 ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e));
1125 TRY_CHECK_RC(OM::write(fyodor, *a_e));
1126
Neale Ranns812ed392017-10-16 04:20:13 -07001127 route::prefix_t src("10.10.10.10", 32);
1128 ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO);
1129 ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO);
1130
1131 std::string acl_name = "acl1";
1132 ACL::l3_list acl1(acl_name);
1133 acl1.insert(r2);
1134 acl1.insert(r1);
1135 ACL::l3_list::rules_t rules = {r1, r2};
1136
1137 HW::item<handle_t> hw_acl(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001138 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001139 TRY_CHECK_RC(OM::write(fyodor, acl1));
1140
Mohsin Kazmid91d1402018-02-14 15:47:19 +01001141 ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO);
1142 ACL::l3_list acl2(acl_name);
1143 acl2.insert(r3);
1144 ACL::l3_list::rules_t rules2 = {r3};
1145 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2));
1146 TRY_CHECK_RC(OM::write(fyodor, acl2));
1147
Neale Ranns812ed392017-10-16 04:20:13 -07001148 ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1);
1149 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001150 ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT,
1151 hw_ifh.data(), hw_acl.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001152 TRY_CHECK_RC(OM::write(fyodor, *l3b));
1153
1154 /**
1155 * Leo adds an L2 ACL in the output direction
1156 */
1157 TRY_CHECK_RC(OM::write(leo, itf1));
1158
1159 std::string l2_acl_name = "l2_acl1";
1160 mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4});
1161 mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0});
1162 ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask);
1163 ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {});
1164
1165 ACL::l2_list l2_acl(l2_acl_name);
1166 l2_acl.insert(l2_r2);
1167 l2_acl.insert(l2_r1);
1168
1169 ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2};
1170
1171 HW::item<handle_t> l2_hw_acl(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001172 ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001173 TRY_CHECK_RC(OM::write(leo, l2_acl));
1174
1175 ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl);
1176 HW::item<bool> l2_hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001177 ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001178 hw_ifh.data(), l2_hw_acl.data()));
1179 TRY_CHECK_RC(OM::write(leo, *l2b));
1180
1181 delete l2b;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001182 ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT,
1183 hw_ifh.data(), l2_hw_acl.data()));
1184 ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl));
Neale Ranns812ed392017-10-16 04:20:13 -07001185 TRY_CHECK(OM::remove(leo));
1186
1187 delete l3b;
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001188 delete a_e;
Neale Ranns812ed392017-10-16 04:20:13 -07001189 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1190 rc_t::OK);
1191 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001192 ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001193 hw_ifh.data(), hw_acl.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001194 ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl));
Mohsin Kazmi04def742018-03-07 19:53:51 +01001195 ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001196 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1197 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001198
1199 TRY_CHECK(OM::remove(fyodor));
1200}
1201
1202BOOST_AUTO_TEST_CASE(test_arp_proxy) {
1203 VppInit vi;
1204 const std::string kurt = "KurtVonnegut";
1205 rc_t rc = rc_t::OK;
1206
1207 asio::ip::address_v4 low = asio::ip::address_v4::from_string("10.0.0.0");
1208 asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255");
1209
1210 arp_proxy_config ap(low, high);
1211 HW::item<bool> hw_ap_cfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001212 ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001213 TRY_CHECK_RC(OM::write(kurt, ap));
1214
1215 std::string itf3_name = "host3";
1216 interface itf3(itf3_name,
1217 interface::type_t::AFPACKET,
1218 interface::admin_state_t::UP);
1219 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1220 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001221 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1222 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001223 TRY_CHECK_RC(OM::write(kurt, itf3));
1224
1225 arp_proxy_binding *apb = new arp_proxy_binding(itf3, ap);
1226 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001227 ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001228 TRY_CHECK_RC(OM::write(kurt, *apb));
1229
1230 delete apb;
1231
1232 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1233 rc_t::OK);
1234 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001235 ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1236 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1237 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1238 ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001239
1240 TRY_CHECK(OM::remove(kurt));
1241}
1242
1243BOOST_AUTO_TEST_CASE(test_ip_unnumbered) {
1244 VppInit vi;
1245 const std::string eric = "EricAmbler";
1246 rc_t rc = rc_t::OK;
1247
1248 /*
1249 * Interface 1 has the L3 address
1250 */
1251 std::string itf1_name = "host1";
1252 interface itf1(itf1_name,
1253 interface::type_t::AFPACKET,
1254 interface::admin_state_t::UP);
1255 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1256 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001257 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1258 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001259 TRY_CHECK_RC(OM::write(eric, itf1));
1260
1261 route::prefix_t pfx_10("10.10.10.10", 24);
1262 l3_binding *l3 = new l3_binding(itf1, pfx_10);
1263 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1264 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001265 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001266 TRY_CHECK_RC(OM::write(eric, *l3));
1267
1268 /*
1269 * Interface 2 is unnumbered
1270 */
1271 std::string itf2_name = "host2";
1272 interface itf2(itf2_name,
1273 interface::type_t::AFPACKET,
1274 interface::admin_state_t::UP);
1275
1276 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001277 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1278 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001279 TRY_CHECK_RC(OM::write(eric, itf2));
1280
1281 ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1);
1282 HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1283 HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001284 ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001285 TRY_CHECK_RC(OM::write(eric, *ipun));
1286
1287 delete l3;
1288 delete ipun;
1289
1290 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1291 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001292 ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data()));
1293 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1294 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1295 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1296 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1297 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001298
1299 TRY_CHECK(OM::remove(eric));
1300}
1301
1302BOOST_AUTO_TEST_CASE(test_ip6nd) {
1303 VppInit vi;
1304 const std::string paulo = "PauloCoelho";
1305 rc_t rc = rc_t::OK;
1306
1307 /*
1308 * ra config
1309 */
1310 std::string itf_name = "host_ip6nd";
1311 interface itf(itf_name,
1312 interface::type_t::AFPACKET,
1313 interface::admin_state_t::UP);
1314 HW::item<handle_t> hw_ifh(3, rc_t::OK);
1315 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001316 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
1317 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001318 TRY_CHECK_RC(OM::write(paulo, itf));
1319
1320 route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128);
1321 l3_binding *l3 = new l3_binding(itf, pfx_10);
1322 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1323 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001324 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001325 TRY_CHECK_RC(OM::write(paulo, *l3));
1326
1327 ra_config ra(0, 1, 0, 4);
1328 ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra);
1329 HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK);
1330 HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK);
1331 ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra));
1332 TRY_CHECK_RC(OM::write(paulo, *ip6ra));
1333
1334 /*
1335 * ra prefix
1336 */
1337 ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800);
1338 ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx);
1339 HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK);
1340 HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK);
1341 ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx));
1342 TRY_CHECK_RC(OM::write(paulo, *ip6pfx));
1343
1344 delete ip6pfx;
1345
1346 ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx));
1347
1348 delete ip6ra;
1349 delete l3;
1350
1351 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1352
1353 STRICT_ORDER_OFF();
1354 ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001355 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1356 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1357 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001358
1359 TRY_CHECK(OM::remove(paulo));
1360}
1361
1362BOOST_AUTO_TEST_CASE(test_interface_span) {
1363 VppInit vi;
1364 const std::string elif = "ElifShafak";
1365 rc_t rc = rc_t::OK;
1366
1367 /*
1368 * Interface 1 to be mirrored
1369 */
1370 std::string itf1_name = "port-from";
1371 interface itf1(itf1_name,
1372 interface::type_t::AFPACKET,
1373 interface::admin_state_t::UP);
1374 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1375 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001376 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1377 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001378 TRY_CHECK_RC(OM::write(elif, itf1));
1379
1380 /*
1381 * Interface 2 where traffic is mirrored
1382 */
1383 std::string itf2_name = "port-to";
1384 interface itf2(itf2_name,
1385 interface::type_t::AFPACKET,
1386 interface::admin_state_t::UP);
1387
1388 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1389 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1390
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001391 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1392 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001393 TRY_CHECK_RC(OM::write(elif, itf2));
1394
1395 interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED);
1396 HW::item<bool> hw_is_cfg(true, rc_t::OK);
1397 HW::item<bool> hw_is_uncfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001398 ADD_EXPECT(interface_span_cmds::config_cmd(hw_is_cfg, hw_ifh.data(), hw_ifh2.data(), interface_span::state_t::TX_RX_ENABLED));
Neale Ranns812ed392017-10-16 04:20:13 -07001399 TRY_CHECK_RC(OM::write(elif, *itf_span));
1400
1401 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1402 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1403
1404 delete itf_span;
1405 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001406 ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data()));
1407 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1408 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1409 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1410 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001411
1412 TRY_CHECK(OM::remove(elif));
1413}
1414
1415BOOST_AUTO_TEST_CASE(test_routing) {
1416 VppInit vi;
1417 const std::string ian = "IanFleming";
1418 rc_t rc = rc_t::OK;
1419
1420 /*
1421 * non-default route domain
1422 */
1423 route_domain rd4(1);
1424 HW::item<bool> hw_rd4_create(true, rc_t::OK);
1425 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
1426 HW::item<bool> hw_rd6_create(true, rc_t::OK);
1427 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
1428 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
1429 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
1430 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
1431 HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001432 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
1433 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001434 TRY_CHECK_RC(OM::write(ian, rd4));
1435
1436 /*
1437 * a couple of interfaces
1438 */
1439 std::string itf1_name = "af1";
1440 interface itf1(itf1_name,
1441 interface::type_t::AFPACKET,
1442 interface::admin_state_t::UP);
1443 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1444 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1445 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001446 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1447 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001448 TRY_CHECK_RC(OM::write(ian, itf1));
1449
1450 std::string itf2_name = "af2";
1451 interface *itf2 = new interface(itf2_name,
1452 interface::type_t::AFPACKET,
1453 interface::admin_state_t::UP,
1454 rd4);
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);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001459 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1460 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1461 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
1462 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001463 TRY_CHECK_RC(OM::write(ian, *itf2));
1464
1465 /*
1466 * prefix on each interface
1467 */
1468 route::prefix_t pfx_10("10.10.10.10", 24);
1469 l3_binding *l3_10 = new l3_binding(itf1, pfx_10);
1470 HW::item<bool> hw_l3_10_bind(true, rc_t::OK);
1471 HW::item<bool> hw_l3_10_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001472 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001473 TRY_CHECK_RC(OM::write(ian, *l3_10));
1474 route::prefix_t pfx_11("11.11.11.11", 24);
1475 l3_binding *l3_11 = new l3_binding(*itf2, pfx_11);
1476 HW::item<bool> hw_l3_11_bind(true, rc_t::OK);
1477 HW::item<bool> hw_l3_11_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001478 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11));
Neale Ranns812ed392017-10-16 04:20:13 -07001479 TRY_CHECK_RC(OM::write(ian, *l3_11));
1480
1481 /*
1482 * A route via interface 1 in the default table
1483 */
1484 route::prefix_t pfx_5("5.5.5.5", 32);
1485 boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11");
1486 route::path *path_10 = new route::path(nh_10, itf1);
1487 route::ip_route *route_5 = new route::ip_route(pfx_5);
1488 route_5->add(*path_10);
1489 HW::item<bool> hw_route_5(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001490 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, {*path_10}));
Neale Ranns812ed392017-10-16 04:20:13 -07001491 TRY_CHECK_RC(OM::write(ian, *route_5));
1492
1493 /*
1494 * A route via interface 2 in the non-default table
1495 */
1496 boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10");
1497 route::path *path_11 = new route::path(nh_11, *itf2);
1498 route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5);
1499 route_5_2->add(*path_11);
1500 HW::item<bool> hw_route_5_2(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001501 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, {*path_11}));
Neale Ranns812ed392017-10-16 04:20:13 -07001502 TRY_CHECK_RC(OM::write(ian, *route_5_2));
1503
1504 /*
1505 * An ARP entry for the neighbour on itf1
1506 */
1507 HW::item<bool> hw_neighbour(true, rc_t::OK);
1508 mac_address_t mac_n({0,1,2,4,5,6});
Neale Rannsfd920602017-11-23 12:15:00 -08001509 neighbour *ne = new neighbour(itf1, nh_10, mac_n);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001510 ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001511 TRY_CHECK_RC(OM::write(ian, *ne));
1512
1513 /*
1514 * A DVR route
1515 */
1516 route::prefix_t pfx_6("6.6.6.6", 32);
1517 route::path *path_l2 = new route::path(*itf2, nh_proto_t::ETHERNET);
1518 route::ip_route *route_dvr = new route::ip_route(pfx_6);
1519 route_dvr->add(*path_l2);
1520 HW::item<bool> hw_route_dvr(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001521 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, {*path_l2}));
Neale Ranns812ed392017-10-16 04:20:13 -07001522 TRY_CHECK_RC(OM::write(ian, *route_dvr));
1523
1524 STRICT_ORDER_OFF();
1525 // delete the stack objects that hold references to others
1526 // so the OM::remove is the call that removes the last reference
1527 delete l3_11;
1528 delete l3_10;
1529 delete itf2;
1530 delete route_5;
1531 delete path_10;
1532 delete route_5_2;
1533 delete path_11;
1534 delete route_dvr;
1535 delete path_l2;
1536 delete ne;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001537 ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
1538 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6));
1539 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5));
1540 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5));
1541 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10));
1542 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11));
1543 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1544 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1545 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
1546 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2));
1547 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1548 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1549 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
1550 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001551
1552 TRY_CHECK(OM::remove(ian));
1553}
1554
1555BOOST_AUTO_TEST_CASE(test_nat) {
1556 VppInit vi;
1557 const std::string gs = "GeorgeSimenon";
1558 rc_t rc = rc_t::OK;
1559
1560 /*
1561 * Inside Interface
1562 */
1563 std::string itf_in_name = "inside";
1564 interface itf_in(itf_in_name,
1565 interface::type_t::AFPACKET,
1566 interface::admin_state_t::UP);
1567 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1568 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1569 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001570 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name));
1571 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001572 TRY_CHECK_RC(OM::write(gs, itf_in));
1573
1574 /*
1575 * outside
1576 */
1577 std::string itf_out_name = "port-to";
1578 interface itf_out(itf_out_name,
1579 interface::type_t::AFPACKET,
1580 interface::admin_state_t::UP);
1581
1582 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1583 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1584 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1585
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001586 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name));
1587 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001588 TRY_CHECK_RC(OM::write(gs, itf_out));
1589
1590 /*
1591 * A NAT static mapping
1592 */
1593 boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1");
1594 boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1");
1595
1596 nat_static ns(in_addr, out_addr);
1597 HW::item<bool> hw_ns(true, rc_t::OK);
1598
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001599 ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
Neale Ranns812ed392017-10-16 04:20:13 -07001600 TRY_CHECK_RC(OM::write(gs, ns));
1601
1602 /*
1603 * bind nat inside and out
1604 */
1605 nat_binding *nb_in = new nat_binding(itf_in,
1606 direction_t::INPUT,
1607 l3_proto_t::IPV4,
1608 nat_binding::zone_t::INSIDE);
1609 HW::item<bool> hw_nb_in(true, rc_t::OK);
1610
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001611 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in,
1612 hw_ifh.data().value(),
1613 nat_binding::zone_t::INSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001614 TRY_CHECK_RC(OM::write(gs, *nb_in));
1615
1616 nat_binding *nb_out = new nat_binding(itf_out,
1617 direction_t::INPUT,
1618 l3_proto_t::IPV4,
1619 nat_binding::zone_t::OUTSIDE);
1620 HW::item<bool> hw_nb_out(true, rc_t::OK);
1621
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001622 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out,
1623 hw_ifh2.data().value(),
1624 nat_binding::zone_t::OUTSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001625 TRY_CHECK_RC(OM::write(gs, *nb_out));
1626
1627
1628 STRICT_ORDER_OFF();
1629 delete nb_in;
1630 delete nb_out;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001631 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in,
1632 hw_ifh.data().value(),
1633 nat_binding::zone_t::INSIDE));
1634 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out,
1635 hw_ifh2.data().value(),
1636 nat_binding::zone_t::OUTSIDE));
1637 ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
1638 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1639 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name));
1640 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1641 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001642
1643 TRY_CHECK(OM::remove(gs));
1644}
1645
1646BOOST_AUTO_TEST_CASE(test_interface_events) {
1647 VppInit vi;
1648 MockListener ml;
1649
1650 HW::item<bool> hw_want(true, rc_t::OK);
1651
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001652 ADD_EXPECT(interface_cmds::events_cmd(ml));
1653 cmd* itf = new interface_cmds::events_cmd(ml);
Neale Ranns812ed392017-10-16 04:20:13 -07001654
1655 HW::enqueue(itf);
1656 HW::write();
Neale Ranns812ed392017-10-16 04:20:13 -07001657}
1658
Neale Ranns352ea0c2017-11-14 11:04:28 -08001659BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
1660 VppInit vi;
1661 const std::string rene = "ReneGoscinny";
1662 rc_t rc = rc_t::OK;
1663
1664 /*
1665 * Create an interface with two IP addresses
1666 */
1667 std::string itf1_name = "host1";
1668 interface itf1(itf1_name,
1669 interface::type_t::AFPACKET,
1670 interface::admin_state_t::UP);
1671 HW::item<handle_t> hw_ifh1(2, rc_t::OK);
1672 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1673 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1674 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name));
1675 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1));
1676 TRY_CHECK_RC(OM::write(rene, itf1));
1677
1678 route::prefix_t pfx_10("10.10.10.10", 24);
1679 l3_binding *l3_1 = new l3_binding(itf1, pfx_10);
1680 HW::item<bool> hw_l3_bind1(true, rc_t::OK);
1681 HW::item<bool> hw_l3_unbind1(false, rc_t::OK);
1682 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
1683 TRY_CHECK_RC(OM::write(rene, *l3_1));
1684
1685 route::prefix_t pfx_11("10.10.11.11", 24);
1686 l3_binding *l3_2 = new l3_binding(itf1, pfx_11);
1687 HW::item<bool> hw_l3_bind2(true, rc_t::OK);
1688 HW::item<bool> hw_l3_unbind2(false, rc_t::OK);
1689 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
1690 TRY_CHECK_RC(OM::write(rene, *l3_2));
1691
1692 route_domain rd(1);
1693 HW::item<bool> hw_rd_create(true, rc_t::OK);
1694 HW::item<bool> hw_rd_delete(false, rc_t::OK);
1695 HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK);
1696 HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK);
1697 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1));
1698 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1));
1699 TRY_CHECK_RC(OM::write(rene, rd));
1700
1701 /*
1702 * update the interface to change to a new route-domain
1703 * expect that the l3-bindings are removed and readded.
1704 */
1705 interface *itf2 = new interface(itf1_name,
1706 interface::type_t::AFPACKET,
1707 interface::admin_state_t::UP,
1708 rd);
1709 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
1710 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
1711 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1));
1712 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1));
1713 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
1714 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
1715 TRY_CHECK_RC(OM::write(rene, *itf2));
1716
1717 /*
1718 * mve the interface back to the default route-domain
1719 */
1720 interface itf3(itf1_name,
1721 interface::type_t::AFPACKET,
1722 interface::admin_state_t::UP);
1723 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
1724 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
1725 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1));
1726 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1));
1727 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
1728 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
1729 TRY_CHECK_RC(OM::write(rene, itf3));
1730
1731 delete l3_1;
1732 delete l3_2;
1733 delete itf2;
1734
1735 STRICT_ORDER_OFF();
1736 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
1737 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
1738 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1));
1739 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name));
1740 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1));
1741 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1));
1742
1743 TRY_CHECK(OM::remove(rene));
1744}
1745
Neale Rannsd3464b52017-12-07 08:48:02 -08001746BOOST_AUTO_TEST_CASE(test_prefixes) {
1747 route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);
1748
1749 BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));
1750
1751 route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);
1752
1753 BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
1754 BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));
1755
1756 route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
1757 BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
1758 BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));
1759
1760 route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);
1761
1762 BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));
1763
1764 route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);
1765
1766 BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
1767 BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
1768 BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));
1769
1770 route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);
1771
1772 BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
1773 BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
1774 BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));
1775
1776 route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);
1777
1778 BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
1779 BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
1780 BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));
1781
1782}
1783
Neale Ranns812ed392017-10-16 04:20:13 -07001784BOOST_AUTO_TEST_SUITE_END()