blob: d72c4db97488615c6a5c257efdaec41203b4c1b9 [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"
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +020028#include "vom/l2_xconnect.hpp"
29#include "vom/l2_xconnect_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070030#include "vom/l3_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070031#include "vom/l3_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070032#include "vom/bridge_domain.hpp"
33#include "vom/bridge_domain_entry.hpp"
34#include "vom/bridge_domain_arp_entry.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070035#include "vom/bridge_domain_cmds.hpp"
36#include "vom/bridge_domain_entry_cmds.hpp"
37#include "vom/bridge_domain_arp_entry_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070038#include "vom/prefix.hpp"
39#include "vom/route.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070040#include "vom/route_cmds.hpp"
Neale Ranns7c03ed42018-12-27 03:21:28 -080041#include "vom/mroute_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070042#include "vom/route_domain.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070043#include "vom/route_domain_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070044#include "vom/vxlan_tunnel.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070045#include "vom/vxlan_tunnel_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070046#include "vom/sub_interface.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070047#include "vom/sub_interface_cmds.hpp"
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +010048#include "vom/acl_ethertype.hpp"
49#include "vom/acl_ethertype_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070050#include "vom/acl_list.hpp"
51#include "vom/acl_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070052#include "vom/acl_list_cmds.hpp"
53#include "vom/acl_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070054#include "vom/acl_l3_rule.hpp"
55#include "vom/acl_l2_rule.hpp"
56#include "vom/arp_proxy_config.hpp"
57#include "vom/arp_proxy_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070058#include "vom/arp_proxy_config_cmds.hpp"
59#include "vom/arp_proxy_binding_cmds.hpp"
Mohsin Kazmi12fe8782018-10-30 19:24:34 +010060#include "vom/igmp_binding.hpp"
61#include "vom/igmp_binding_cmds.hpp"
62#include "vom/igmp_listen.hpp"
63#include "vom/igmp_listen_cmds.hpp"
Mohsin Kazmie23edac2018-09-25 18:26:52 +020064#include "vom/ip_punt_redirect.hpp"
65#include "vom/ip_punt_redirect_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070066#include "vom/ip_unnumbered.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070067#include "vom/ip_unnumbered_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070068#include "vom/interface_ip6_nd.hpp"
69#include "vom/interface_span.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070070#include "vom/interface_span_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070071#include "vom/neighbour.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070072#include "vom/neighbour_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070073#include "vom/nat_static.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070074#include "vom/nat_static_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070075#include "vom/nat_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070076#include "vom/nat_binding_cmds.hpp"
Neale Ranns208c29a2018-04-11 08:08:30 -070077#include "vom/pipe.hpp"
78#include "vom/pipe_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070079
80using namespace boost;
81using namespace VOM;
82
83/**
84 * An expectation exception
85 */
86class ExpException
87{
88public:
89 ExpException(unsigned int number)
90 {
91 // a neat place to add a break point
92 std::cout << " ExpException here: " << number << std::endl;
93 }
94};
95
96class MockListener : public interface::event_listener,
97 public interface::stat_listener
98{
Mohsin Kazmi51edc3a2018-11-21 19:00:46 +010099 void handle_interface_stat(const interface& itf)
Neale Ranns812ed392017-10-16 04:20:13 -0700100 {
101 }
Neale Ranns193c47d2018-12-10 06:01:46 -0800102 void handle_interface_event(std::vector<VOM::interface::event> events)
Neale Ranns812ed392017-10-16 04:20:13 -0700103 {
104 }
105};
106
107class MockCmdQ : public HW::cmd_q
108{
109public:
110 MockCmdQ():
111 m_strict_order(true)
112 {
113 }
114 virtual ~MockCmdQ()
115 {
116 }
117 void expect(cmd *f)
118 {
119 m_exp_queue.push_back(f);
120 }
121 void enqueue(cmd *f)
122 {
123 m_act_queue.push_back(f);
124 }
125 void enqueue(std::queue<cmd*> &cmds)
126 {
127 while (cmds.size())
128 {
129 m_act_queue.push_back(cmds.front());
130 cmds.pop();
131 }
132 }
133 void enqueue(std::shared_ptr<cmd> f)
134 {
135 m_act_queue.push_back(f.get());
136 }
137
138 void dequeue(cmd *f)
139 {
140 }
141
142 void dequeue(std::shared_ptr<cmd> cmd)
143 {
144 }
145
146 void strict_order(bool on)
147 {
148 m_strict_order = on;
149 }
150
151 bool is_empty()
152 {
153 return ((0 == m_exp_queue.size()) &&
154 (0 == m_act_queue.size()));
155 }
156
157 rc_t write()
158 {
159 cmd *f_exp, *f_act;
160 rc_t rc = rc_t::OK;
161
162 while (m_act_queue.size())
163 {
164 bool matched = false;
165 auto it_exp = m_exp_queue.begin();
166 auto it_act = m_act_queue.begin();
167
168 f_act = *it_act;
169
170 std::cout << " Act: " << f_act->to_string() << std::endl;
171 while (it_exp != m_exp_queue.end())
172 {
173 f_exp = *it_exp;
174 try
175 {
176 std::cout << " Exp: " << f_exp->to_string() << std::endl;
177
178 if (typeid(*f_exp) != typeid(*f_act))
179 {
180 throw ExpException(1);
181 }
182
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700183 if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700184 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700185 rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700186 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700187 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700188 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700189 rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700190 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800191 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd))
192 {
193 rc = handle_derived<interface_cmds::vhost_create_cmd>(f_exp, f_act);
194 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100195 else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd))
196 {
197 rc = handle_derived<bond_interface_cmds::create_cmd>(f_exp, f_act);
198 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700199 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700200 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700201 rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700202 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700203 else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700204 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700205 rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700206 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800207 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd))
208 {
209 rc = handle_derived<interface_cmds::vhost_delete_cmd>(f_exp, f_act);
210 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100211 else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd))
212 {
213 rc = handle_derived<bond_interface_cmds::delete_cmd>(f_exp, f_act);
214 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700215 else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700216 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700217 rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700218 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700219 else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700220 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700221 rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700222 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700223 else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700224 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700225 rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700226 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700227 else if (typeid(*f_exp) == typeid(interface_cmds::set_tag))
Neale Ranns812ed392017-10-16 04:20:13 -0700228 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700229 rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700230 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100231 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd))
232 {
233 rc = handle_derived<bond_group_binding_cmds::bind_cmd>(f_exp, f_act);
234 }
235 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd))
236 {
237 rc = handle_derived<bond_group_binding_cmds::unbind_cmd>(f_exp, f_act);
238 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700239 else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700240 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700241 rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700242 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700243 else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700244 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700245 rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700246 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700247 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700248 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700249 rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700250 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700251 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700252 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700253 rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700254 }
Neale Ranns7c03ed42018-12-27 03:21:28 -0800255 else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::update_cmd))
256 {
257 rc = handle_derived<route::ip_mroute_cmds::update_cmd>(f_exp, f_act);
258 }
259 else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::delete_cmd))
260 {
261 rc = handle_derived<route::ip_mroute_cmds::delete_cmd>(f_exp, f_act);
262 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700263 else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700264 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700265 rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700266 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700267 else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700268 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700269 rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700270 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700271 else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700272 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700273 rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700274 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700275 else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700276 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700277 rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700278 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700279 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700280 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700281 rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700282 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700283 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700284 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700285 rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700286 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700287 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700288 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700289 rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700290 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700291 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700292 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700293 rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700294 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700295 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700296 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700297 rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700298 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700299 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700300 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700301 rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700302 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700303 else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700304 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700305 rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700306 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700307 else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700308 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700309 rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700310 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700311 else if (typeid(*f_exp) == typeid(l2_binding_cmds::set_vtr_op_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700312 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700313 rc = handle_derived<l2_binding_cmds::set_vtr_op_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700314 }
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +0200315 else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd))
316 {
317 rc = handle_derived<l2_xconnect_cmds::bind_cmd>(f_exp, f_act);
318 }
319 else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::unbind_cmd))
320 {
321 rc = handle_derived<l2_xconnect_cmds::unbind_cmd>(f_exp, f_act);
322 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700323 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700324 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700325 rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700326 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700327 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700328 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700329 rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700330 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700331 else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700332 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700333 rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700334 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700335 else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700336 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700337 rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700338 }
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +0100339 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd))
340 {
341 rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act);
342 }
Mohsin Kazmi04def742018-03-07 19:53:51 +0100343 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd))
344 {
345 rc = handle_derived<ACL::acl_ethertype_cmds::unbind_cmd>(f_exp, f_act);
346 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700347 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700348 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700349 rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700350 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700351 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700352 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700353 rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700354 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700355 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700356 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700357 rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700358 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700359 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700360 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700361 rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700362 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700363 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700364 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700365 rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700366 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700367 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700368 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700369 rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700370 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700371 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700372 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700373 rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700374 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700375 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700376 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700377 rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700378 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700379 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700380 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700381 rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700382 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700383 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700384 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700385 rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700386 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700387 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700388 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700389 rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700390 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700391 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700392 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700393 rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700394 }
Mohsin Kazmi12fe8782018-10-30 19:24:34 +0100395 else if (typeid(*f_exp) == typeid(igmp_binding_cmds::bind_cmd))
396 {
397 rc = handle_derived<igmp_binding_cmds::bind_cmd>(f_exp, f_act);
398 }
399 else if (typeid(*f_exp) == typeid(igmp_binding_cmds::unbind_cmd))
400 {
401 rc = handle_derived<igmp_binding_cmds::unbind_cmd>(f_exp, f_act);
402 }
403 else if (typeid(*f_exp) == typeid(igmp_listen_cmds::listen_cmd))
404 {
405 rc = handle_derived<igmp_listen_cmds::listen_cmd>(f_exp, f_act);
406 }
407 else if (typeid(*f_exp) == typeid(igmp_listen_cmds::unlisten_cmd))
408 {
409 rc = handle_derived<igmp_listen_cmds::unlisten_cmd>(f_exp, f_act);
410 }
Mohsin Kazmie23edac2018-09-25 18:26:52 +0200411 else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::config_cmd))
412 {
413 rc = handle_derived<ip_punt_redirect_cmds::config_cmd>(f_exp, f_act);
414 }
415 else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::unconfig_cmd))
416 {
417 rc = handle_derived<ip_punt_redirect_cmds::unconfig_cmd>(f_exp, f_act);
418 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700419 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700420 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700421 rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700422 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700423 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700424 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700425 rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700426 }
427 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd))
428 {
429 rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act);
430 }
431 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd))
432 {
433 rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act);
434 }
435 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd))
436 {
437 rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act);
438 }
439 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd))
440 {
441 rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act);
442 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700443 else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700444 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700445 rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700446 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700447 else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700448 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700449 rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700450 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700451 else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700452 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700453 rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700454 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700455 else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700456 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700457 rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700458 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700459 else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700460 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700461 rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700462 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700463 else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700464 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700465 rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700466 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700467 else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700468 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700469 rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700470 }
Neale Ranns208c29a2018-04-11 08:08:30 -0700471 else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd))
472 {
473 rc = handle_derived<pipe_cmds::create_cmd>(f_exp, f_act);
474 }
475 else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd))
476 {
477 rc = handle_derived<pipe_cmds::delete_cmd>(f_exp, f_act);
478 }
Neale Ranns812ed392017-10-16 04:20:13 -0700479 else
480 {
481 throw ExpException(2);
482 }
483
484 // if we get here then we found the match.
485 m_exp_queue.erase(it_exp);
486 m_act_queue.erase(it_act);
487 delete f_exp;
488 delete f_act;
489
490 // return any injected failures to the agent
491 if (rc_t::OK != rc && rc_t::NOOP != rc)
492 {
493 return (rc);
494 }
495
496 matched = true;
497 break;
498 }
499 catch (ExpException &e)
500 {
501 // The expected and actual do not match
502 if (m_strict_order)
503 {
504 // in strict ordering mode this is fatal, so rethrow
505 throw e;
506 }
507 else
508 {
509 // move the iterator onto the next in the expected list and
510 // check for a match
511 ++it_exp;
512 }
513 }
514 }
515
516 if (!matched)
517 throw ExpException(3);
518 }
519
520 return (rc);
521 }
522private:
523
524 template <typename T>
525 rc_t handle_derived(const cmd *f_exp, cmd *f_act)
526 {
527 const T *i_exp;
528 T *i_act;
529
530 i_exp = dynamic_cast<const T*>(f_exp);
531 i_act = dynamic_cast<T*>(f_act);
532 if (!(*i_exp == *i_act))
533 {
534 throw ExpException(4);
535 }
536 // pass the data and return code to the agent
537 i_act->item() = i_exp->item();
538
539 return (i_act->item().rc());
540 }
541
542 // The Q to push the expectations on
543 std::deque<cmd*> m_exp_queue;
544
545 // the queue to push the actual events on
546 std::deque<cmd*> m_act_queue;
547
548 // control whether the expected queue is strictly ordered.
549 bool m_strict_order;
550};
551
552class VppInit {
553public:
554 std::string name;
555 MockCmdQ *f;
556
557 VppInit()
558 : name("vpp-ut"),
559 f(new MockCmdQ())
560 {
561 HW::init(f);
562 OM::init();
563 logger().set(log_level_t::DEBUG);
564 }
565
566 ~VppInit() {
567 delete f;
568 }
569};
570
Neale Rannsd3464b52017-12-07 08:48:02 -0800571BOOST_AUTO_TEST_SUITE(vom)
Neale Ranns812ed392017-10-16 04:20:13 -0700572
573#define TRY_CHECK_RC(stmt) \
574{ \
575 try { \
576 BOOST_CHECK(rc_t::OK == stmt); \
577 } \
578 catch (ExpException &e) \
579 { \
580 BOOST_CHECK(false); \
581 } \
582 BOOST_CHECK(vi.f->is_empty()); \
583}
584
585#define TRY_CHECK(stmt) \
586{ \
587 try { \
588 stmt; \
589 } \
590 catch (ExpException &e) \
591 { \
592 BOOST_CHECK(false); \
593 } \
594 BOOST_CHECK(vi.f->is_empty()); \
595}
596
597#define ADD_EXPECT(stmt) \
598 vi.f->expect(new stmt)
599
600#define STRICT_ORDER_OFF() \
601 vi.f->strict_order(false)
602
603BOOST_AUTO_TEST_CASE(test_interface) {
604 VppInit vi;
605 const std::string go = "GeorgeOrwell";
606 const std::string js = "JohnSteinbeck";
607 rc_t rc = rc_t::OK;
608
609 /*
610 * George creates and deletes the interface
611 */
612 std::string itf1_name = "afpacket1";
613 interface itf1(itf1_name,
614 interface::type_t::AFPACKET,
615 interface::admin_state_t::UP);
616
617 /*
618 * set the expectation for a afpacket interface create.
619 * 2 is the interface handle VPP [mock] assigns
620 */
621 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700622 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700623
624 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700625 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700626
627 TRY_CHECK_RC(OM::write(go, itf1));
628
629 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700630 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
631 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700632
633 TRY_CHECK(OM::remove(go));
634
635 /*
636 * George creates the interface, then John brings it down.
637 * George's remove is a no-op, sice John also owns the interface
638 */
639 interface itf1b(itf1_name,
640 interface::type_t::AFPACKET,
641 interface::admin_state_t::DOWN);
642
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700643 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
644 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700645 TRY_CHECK_RC(OM::write(go, itf1));
646
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700647 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700648 TRY_CHECK_RC(OM::write(js, itf1b));
649
650 TRY_CHECK(OM::remove(go));
651
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700652 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700653 TRY_CHECK(OM::remove(js));
654
655 /*
656 * George adds an interface, then we flush all of Geroge's state
657 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700658 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
659 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700660 TRY_CHECK_RC(OM::write(go, itf1));
661
662 TRY_CHECK(OM::mark(go));
663
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700664 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
665 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700666 TRY_CHECK(OM::sweep(go));
667
668 /*
669 * George adds an interface. mark stale. update the same interface. sweep
670 * and expect no delete
671 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700672 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
673 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700674 TRY_CHECK_RC(OM::write(go, itf1b));
675
676 TRY_CHECK(OM::mark(go));
677
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700678 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700679 TRY_CHECK_RC(OM::write(go, itf1));
680
681 TRY_CHECK(OM::sweep(go));
682
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700683 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
684 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700685 TRY_CHECK(OM::remove(go));
686
687 /*
688 * George adds an insterface, then we mark that state. Add a second interface
689 * an flush the first that is now stale.
690 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700691 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
692 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700693 TRY_CHECK_RC(OM::write(go, itf1));
694
695 TRY_CHECK(OM::mark(go));
696
697 std::string itf2_name = "afpacket2";
Neale Ranns4ef42262018-02-20 08:10:44 -0800698 std::string itf2_tag = "uuid-of-afpacket2-interface";
Neale Ranns812ed392017-10-16 04:20:13 -0700699 interface itf2(itf2_name,
700 interface::type_t::AFPACKET,
Neale Ranns4ef42262018-02-20 08:10:44 -0800701 interface::admin_state_t::UP,
702 itf2_tag);
Neale Ranns812ed392017-10-16 04:20:13 -0700703 HW::item<handle_t> hw_ifh2(3, rc_t::OK);
704
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700705 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
Neale Ranns4ef42262018-02-20 08:10:44 -0800706 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700707 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700708 TRY_CHECK_RC(OM::write(go, itf2));
709
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700710 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
711 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700712 TRY_CHECK(OM::sweep(go));
713
714 TRY_CHECK(OM::mark(go));
715
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700716 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
717 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700718 TRY_CHECK(OM::sweep(go));
Neale Ranns4ef42262018-02-20 08:10:44 -0800719
720
721 std::string itf3_name = "/PATH/TO/vhost_user1.sock";
722 std::string itf3_tag = "uuid-of-vhost_user1-interface";
723 interface itf3(itf3_name,
724 interface::type_t::VHOST,
725 interface::admin_state_t::UP,
726 itf3_tag);
727 HW::item<handle_t> hw_ifh3(4, rc_t::OK);
728
729 ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag));
730 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
731 TRY_CHECK_RC(OM::write(go, itf3));
732
733 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
734 ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name));
735 TRY_CHECK(OM::remove(go));
Neale Ranns812ed392017-10-16 04:20:13 -0700736}
737
738BOOST_AUTO_TEST_CASE(test_bvi) {
739 VppInit vi;
740 const std::string ernest = "ErnestHemmingway";
741 const std::string graham = "GrahamGreene";
742 rc_t rc = rc_t::OK;
743 l3_binding *l3;
744
745 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
746 rc_t::OK);
747 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
748 rc_t::OK);
749
750 /*
751 * Enrest creates a BVI with address 10.10.10.10/24
752 */
753 route::prefix_t pfx_10("10.10.10.10", 24);
754
755 const std::string bvi_name = "bvi1";
756 interface itf(bvi_name,
757 interface::type_t::BVI,
758 interface::admin_state_t::UP);
759 HW::item<handle_t> hw_ifh(4, rc_t::OK);
760 HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK);
761
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700762 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh, bvi_name));
763 ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name));
764 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700765 TRY_CHECK_RC(OM::write(ernest, itf));
766
767 l3 = new l3_binding(itf, pfx_10);
768 HW::item<bool> hw_l3_bind(true, rc_t::OK);
769 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700770 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700771 TRY_CHECK_RC(OM::write(ernest, *l3));
772
773 // change the MAC address on the BVI
774 interface itf_new_mac(bvi_name,
775 interface::type_t::BVI,
776 interface::admin_state_t::UP);
777 l2_address_t l2_addr({0,1,2,3,4,5});
778 HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK);
779 itf_new_mac.set(l2_addr);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700780 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700781 TRY_CHECK_RC(OM::write(ernest, itf_new_mac));
782
783 // create/write the interface to the OM again but with an unset MAC
784 // this should not generate a MAC address update
785 TRY_CHECK_RC(OM::write(ernest, itf));
786
787 // change the MAC address on the BVI - again
788 interface itf_new_mac2(bvi_name,
789 interface::type_t::BVI,
790 interface::admin_state_t::UP);
791 l2_address_t l2_addr2({0,1,2,3,4,6});
792 HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK);
793 itf_new_mac2.set(l2_addr2);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700794 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700795 TRY_CHECK_RC(OM::write(ernest, itf_new_mac2));
796
797 delete l3;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700798 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
799 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
800 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700801 TRY_CHECK(OM::remove(ernest));
802
803 /*
804 * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain
805 */
806 route_domain rd(1);
807 HW::item<bool> hw_rd4_create(true, rc_t::OK);
808 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
809 HW::item<bool> hw_rd6_create(true, rc_t::OK);
810 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
811 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
812 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
813 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
814 HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700815 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
816 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700817 TRY_CHECK_RC(OM::write(graham, rd));
818
819 const std::string bvi2_name = "bvi2";
820 interface *itf2 = new interface(bvi2_name,
821 interface::type_t::BVI,
822 interface::admin_state_t::UP,
823 rd);
824 HW::item<handle_t> hw_ifh2(5, rc_t::OK);
825
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700826 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh2, bvi2_name));
827 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name));
828 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
829 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
830 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700831
832 TRY_CHECK_RC(OM::write(graham, *itf2));
833
834 l3 = new l3_binding(*itf2, pfx_10);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700835 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700836 TRY_CHECK_RC(OM::write(graham, *l3));
837
838 delete l3;
839 delete itf2;
840
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700841 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10));
842 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
843 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2));
844 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
845 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh2));
846 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
847 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700848 TRY_CHECK(OM::remove(graham));
849}
850
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100851BOOST_AUTO_TEST_CASE(test_bond) {
852 VppInit vi;
853 const std::string cb = "CarolBerg";
854 rc_t rc = rc_t::OK;
855
856 /*
857 * creates the interfaces
858 */
859 std::string itf1_name = "afpacket1";
860 interface itf1(itf1_name,
861 interface::type_t::AFPACKET,
862 interface::admin_state_t::UP);
863
864 HW::item<handle_t> hw_ifh(2, rc_t::OK);
865 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
866
867 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
868 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
869
870 TRY_CHECK_RC(OM::write(cb, itf1));
871
872 std::string itf2_name = "afpacket2";
873 interface itf2(itf2_name,
874 interface::type_t::AFPACKET,
875 interface::admin_state_t::UP);
876
877
878 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
879 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
880 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
881
882 TRY_CHECK_RC(OM::write(cb, itf2));
883
884 std::string bond_name = "bond";
885 bond_interface bond_itf(bond_name, interface::admin_state_t::UP,
886 bond_interface::mode_t::LACP);
887
888 HW::item<handle_t> hw_ifh3(6, rc_t::OK);
889 ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name,
890 bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO));
891 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
892
893 TRY_CHECK_RC(OM::write(cb, bond_itf));
894
895 bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE,
896 bond_member::rate_t::SLOW);
897 bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE,
898 bond_member::rate_t::SLOW);
899 bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2});
900
901 HW::item<bool> bond_hw_bind(true, rc_t::OK);
902 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1));
903 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2));
904
905 TRY_CHECK_RC(OM::write(cb, *bgb));
906
907 delete bgb;
908 delete bm2;
909 delete bm1;
910
911 STRICT_ORDER_OFF();
912 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
913 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data()));
914 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data()));
915 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
916 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
917 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
918 ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3));
919 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
920 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
921
922 TRY_CHECK(OM::remove(cb));
923}
924
Neale Ranns812ed392017-10-16 04:20:13 -0700925BOOST_AUTO_TEST_CASE(test_bridge) {
926 VppInit vi;
927 const std::string franz = "FranzKafka";
928 const std::string dante = "Dante";
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100929 const std::string jkr = "jkrowling";
Neale Ranns812ed392017-10-16 04:20:13 -0700930 rc_t rc = rc_t::OK;
931
932 /*
933 * Franz creates an interface, Bridge-domain, then binds the two
934 */
935
936 // interface create
937 std::string itf1_name = "afpacket1";
938 interface itf1(itf1_name,
939 interface::type_t::AFPACKET,
940 interface::admin_state_t::UP);
941
942 HW::item<handle_t> hw_ifh(3, rc_t::OK);
943 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
944 rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700945 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
946 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700947
948 TRY_CHECK_RC(OM::write(franz, itf1));
949
950 // bridge-domain create
951 bridge_domain bd1(33);
952
953 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -0700954 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
955 bridge_domain::learning_mode_t::ON,
956 bridge_domain::arp_term_mode_t::ON,
957 bridge_domain::flood_mode_t::ON,
958 bridge_domain::mac_age_mode_t::OFF));
Neale Ranns812ed392017-10-16 04:20:13 -0700959
960 TRY_CHECK_RC(OM::write(franz, bd1));
961
962 // L2-interface create and bind
963 // this needs to be delete'd before the flush below, since it too maintains
964 // references to the BD and Interface
965 l2_binding *l2itf = new l2_binding(itf1, bd1);
966 HW::item<bool> hw_l2_bind(true, rc_t::OK);
967
Mohsin Kazmi762d83c2018-09-27 15:00:32 +0200968 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
969 hw_ifh.data(),
970 hw_bd.data(),
971 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns812ed392017-10-16 04:20:13 -0700972 TRY_CHECK_RC(OM::write(franz, *l2itf));
973
974 /*
975 * Dante adds an interface to the same BD
976 */
977 std::string itf2_name = "afpacket2";
978 interface itf2(itf2_name,
979 interface::type_t::AFPACKET,
980 interface::admin_state_t::UP);
981
982 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700983 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
984 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700985 TRY_CHECK_RC(OM::write(dante, itf2));
986
987 // BD add is a no-op since it exists
988 TRY_CHECK_RC(OM::write(dante, bd1));
989
990 l2_binding *l2itf2 = new l2_binding(itf2, bd1);
991 HW::item<l2_binding::l2_vtr_op_t> hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK);
992 l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68);
993
Mohsin Kazmi762d83c2018-09-27 15:00:32 +0200994 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
995 hw_ifh2.data(),
996 hw_bd.data(),
997 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700998 ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68));
Neale Ranns812ed392017-10-16 04:20:13 -0700999 TRY_CHECK_RC(OM::write(dante, *l2itf2));
1000
1001 // Add some static entries to the bridge-domain
1002 HW::item<bool> hw_be1(true, rc_t::OK);
1003 mac_address_t mac1({0,1,2,3,4,5});
1004 bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001005 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
1006 false));
Neale Ranns812ed392017-10-16 04:20:13 -07001007 TRY_CHECK_RC(OM::write(dante, *be1));
1008
1009 // Add some entries to the bridge-domain ARP termination table
1010 HW::item<bool> hw_bea1(true, rc_t::OK);
1011 boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10");
1012
Neale Rannsfd920602017-11-23 12:15:00 -08001013 bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001014 ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1));
Neale Ranns812ed392017-10-16 04:20:13 -07001015 TRY_CHECK_RC(OM::write(dante, *bea1));
1016
1017 // flush Franz's state
1018 delete l2itf;
1019 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1020 rc_t::OK);
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001021 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1022 hw_ifh.data(),
1023 hw_bd.data(),
1024 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001025 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1026 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001027 TRY_CHECK(OM::remove(franz));
1028
1029 // flush Dante's state - the order the interface and BD are deleted
1030 // is an uncontrollable artifact of the C++ object destruction.
1031 delete l2itf2;
1032 delete be1;
1033 delete bea1;
1034 STRICT_ORDER_OFF();
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001035 ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
1036 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001037 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1038 hw_ifh2.data(),
1039 hw_bd.data(),
1040 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001041
1042 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001043 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1044 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001045 TRY_CHECK(OM::remove(dante));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001046
1047 // test the BVI entry in l2fib
1048 bridge_domain bd2(99);
1049
1050 HW::item<uint32_t> hw_bd2(99, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -07001051 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2,
1052 bridge_domain::learning_mode_t::ON,
1053 bridge_domain::arp_term_mode_t::ON,
1054 bridge_domain::flood_mode_t::ON,
1055 bridge_domain::mac_age_mode_t::OFF));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001056
1057 TRY_CHECK_RC(OM::write(jkr, bd2));
1058
1059 std::string itf3_name = "bvi";
1060 interface itf3(itf3_name,
1061 interface::type_t::BVI,
1062 interface::admin_state_t::UP);
1063
1064 HW::item<handle_t> hw_ifh3(5, rc_t::OK);
1065 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name));
1066 ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
1067 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
1068 TRY_CHECK_RC(OM::write(jkr, itf3));
1069
1070 l2_binding *l2itf3 = new l2_binding(itf3, bd2);
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001071 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1072 hw_ifh3.data(),
1073 hw_bd2.data(),
1074 l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001075 TRY_CHECK_RC(OM::write(jkr, *l2itf3));
1076
1077 HW::item<bool> hw_be2(true, rc_t::OK);
1078 mac_address_t mac2({0,1,2,3,4,5});
1079 bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
1080 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
1081 TRY_CHECK_RC(OM::write(jkr, *be2));
1082
1083 delete l2itf3;
1084 delete be2;
1085 STRICT_ORDER_OFF();
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001086 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1087 hw_ifh3.data(),
1088 hw_bd2.data(),
1089 l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001090 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
1091 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
1092 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3));
1093 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
1094 TRY_CHECK(OM::remove(jkr));
Neale Ranns812ed392017-10-16 04:20:13 -07001095}
1096
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +02001097BOOST_AUTO_TEST_CASE(test_l2_xconnect) {
1098 VppInit vi;
1099 const std::string nicholas = "NicholasAbercrombie";
1100 rc_t rc = rc_t::OK;
1101
1102 /*
1103 * Interface 1
1104 */
1105 std::string itf1_name = "host1";
1106 interface itf1(itf1_name,
1107 interface::type_t::AFPACKET,
1108 interface::admin_state_t::UP);
1109 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1110 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1111 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1112 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1113 TRY_CHECK_RC(OM::write(nicholas, itf1));
1114
1115 /*
1116 * Interface 2
1117 */
1118 std::string itf2_name = "host2";
1119 interface itf2(itf2_name,
1120 interface::type_t::AFPACKET,
1121 interface::admin_state_t::UP);
1122
1123 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1124 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1125 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1126 TRY_CHECK_RC(OM::write(nicholas, itf2));
1127
1128 l2_xconnect *l2_xconn = new l2_xconnect(itf1, itf2);
1129 HW::item<bool> xconnect_east(true, rc_t::OK);
1130 HW::item<bool> xconnect_west(true, rc_t::OK);
1131 HW::item<bool> xconnect_east_unbind(false, rc_t::OK);
1132 HW::item<bool> xconnect_west_unbind(false, rc_t::OK);
1133 ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_east, hw_ifh.data(), hw_ifh2.data()));
1134 ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_west, hw_ifh2.data(), hw_ifh.data()));
1135 TRY_CHECK_RC(OM::write(nicholas, *l2_xconn));
1136
1137 delete l2_xconn;
1138
1139 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1140 STRICT_ORDER_OFF();
1141 ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_east_unbind, hw_ifh.data(), hw_ifh2.data()));
1142 ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_west_unbind, hw_ifh2.data(), hw_ifh.data()));
1143 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1144 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1145 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1146 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1147
1148 TRY_CHECK(OM::remove(nicholas));
1149}
1150
Neale Ranns812ed392017-10-16 04:20:13 -07001151BOOST_AUTO_TEST_CASE(test_vxlan) {
1152 VppInit vi;
1153 const std::string franz = "FranzKafka";
1154 rc_t rc = rc_t::OK;
1155
1156 /*
1157 * Franz creates an interface, Bridge-domain, then binds the two
1158 */
1159
1160 // VXLAN create
1161 vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"),
Neale Ranns25b04942018-04-04 09:34:50 -07001162 boost::asio::ip::address::from_string("10.10.10.11"),
1163 322);
Neale Ranns812ed392017-10-16 04:20:13 -07001164
1165 vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);
1166
1167 HW::item<handle_t> hw_vxt(3, rc_t::OK);
Neale Rannscf3ecb12018-12-11 08:40:20 -08001168 ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep,
1169 handle_t::INVALID));
Neale Ranns812ed392017-10-16 04:20:13 -07001170
1171 TRY_CHECK_RC(OM::write(franz, vxt));
1172
1173 // bridge-domain create
Neale Ranns25b04942018-04-04 09:34:50 -07001174 bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
1175 bridge_domain::arp_term_mode_t::OFF,
1176 bridge_domain::flood_mode_t::OFF,
1177 bridge_domain::mac_age_mode_t::ON);
Neale Ranns812ed392017-10-16 04:20:13 -07001178
1179 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -07001180 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
1181 bridge_domain::learning_mode_t::OFF,
1182 bridge_domain::arp_term_mode_t::OFF,
1183 bridge_domain::flood_mode_t::OFF,
1184 bridge_domain::mac_age_mode_t::ON));
Neale Ranns812ed392017-10-16 04:20:13 -07001185
1186 TRY_CHECK_RC(OM::write(franz, bd1));
1187
1188 // L2-interface create and bind
1189 // this needs to be delete'd before the flush below, since it too maintains
1190 // references to the BD and Interface
1191 l2_binding *l2itf = new l2_binding(vxt, bd1);
1192 HW::item<bool> hw_l2_bind(true, rc_t::OK);
1193
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001194 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1195 hw_vxt.data(),
1196 hw_bd.data(),
1197 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns812ed392017-10-16 04:20:13 -07001198 TRY_CHECK_RC(OM::write(franz, *l2itf));
1199
1200 // flush Franz's state
1201 delete l2itf;
1202 HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP);
1203 STRICT_ORDER_OFF();
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001204 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1205 hw_vxt.data(),
1206 hw_bd.data(),
1207 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001208 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
1209 ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep));
Neale Ranns812ed392017-10-16 04:20:13 -07001210 TRY_CHECK(OM::remove(franz));
1211}
1212
1213BOOST_AUTO_TEST_CASE(test_vlan) {
1214 VppInit vi;
1215 const std::string noam = "NoamChomsky";
1216 rc_t rc = rc_t::OK;
1217
1218 std::string itf1_name = "host1";
1219 interface itf1(itf1_name,
1220 interface::type_t::AFPACKET,
1221 interface::admin_state_t::UP);
1222
1223 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001224 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001225
1226 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001227 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001228
1229 TRY_CHECK_RC(OM::write(noam, itf1));
1230
1231 sub_interface *vl33 = new sub_interface(itf1,
1232 interface::admin_state_t::UP,
1233 33);
1234
1235 HW::item<handle_t> hw_vl33(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001236 ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33));
1237 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33));
Neale Ranns812ed392017-10-16 04:20:13 -07001238
1239 TRY_CHECK_RC(OM::write(noam, *vl33));
1240
1241 delete vl33;
1242 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1243 HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001244 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33));
1245 ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down));
1246 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1247 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001248
1249 TRY_CHECK(OM::remove(noam));
1250}
1251
1252BOOST_AUTO_TEST_CASE(test_acl) {
1253 VppInit vi;
1254 const std::string fyodor = "FyodorDostoyevsky";
1255 const std::string leo = "LeoTolstoy";
1256 rc_t rc = rc_t::OK;
1257
1258 /*
1259 * Fyodor adds an ACL in the input direction
1260 */
1261 std::string itf1_name = "host1";
1262 interface itf1(itf1_name,
1263 interface::type_t::AFPACKET,
1264 interface::admin_state_t::UP);
1265 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1266 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001267 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1268 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001269 TRY_CHECK_RC(OM::write(fyodor, itf1));
1270
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001271 ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT);
1272 ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT);
1273 ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT);
1274 ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3};
1275 ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e);
1276 HW::item<bool> ae_binding(true, rc_t::OK);
1277 ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e));
1278 TRY_CHECK_RC(OM::write(fyodor, *a_e));
1279
Neale Ranns812ed392017-10-16 04:20:13 -07001280 route::prefix_t src("10.10.10.10", 32);
1281 ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO);
1282 ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO);
1283
1284 std::string acl_name = "acl1";
1285 ACL::l3_list acl1(acl_name);
1286 acl1.insert(r2);
1287 acl1.insert(r1);
1288 ACL::l3_list::rules_t rules = {r1, r2};
1289
1290 HW::item<handle_t> hw_acl(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001291 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001292 TRY_CHECK_RC(OM::write(fyodor, acl1));
1293
Mohsin Kazmid91d1402018-02-14 15:47:19 +01001294 ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO);
1295 ACL::l3_list acl2(acl_name);
1296 acl2.insert(r3);
1297 ACL::l3_list::rules_t rules2 = {r3};
1298 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2));
1299 TRY_CHECK_RC(OM::write(fyodor, acl2));
1300
Neale Ranns812ed392017-10-16 04:20:13 -07001301 ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1);
1302 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001303 ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT,
1304 hw_ifh.data(), hw_acl.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001305 TRY_CHECK_RC(OM::write(fyodor, *l3b));
1306
1307 /**
1308 * Leo adds an L2 ACL in the output direction
1309 */
1310 TRY_CHECK_RC(OM::write(leo, itf1));
1311
1312 std::string l2_acl_name = "l2_acl1";
1313 mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4});
1314 mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0});
1315 ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask);
1316 ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {});
1317
1318 ACL::l2_list l2_acl(l2_acl_name);
1319 l2_acl.insert(l2_r2);
1320 l2_acl.insert(l2_r1);
1321
1322 ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2};
1323
1324 HW::item<handle_t> l2_hw_acl(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001325 ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001326 TRY_CHECK_RC(OM::write(leo, l2_acl));
1327
1328 ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl);
1329 HW::item<bool> l2_hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001330 ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001331 hw_ifh.data(), l2_hw_acl.data()));
1332 TRY_CHECK_RC(OM::write(leo, *l2b));
1333
1334 delete l2b;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001335 ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT,
1336 hw_ifh.data(), l2_hw_acl.data()));
1337 ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl));
Neale Ranns812ed392017-10-16 04:20:13 -07001338 TRY_CHECK(OM::remove(leo));
1339
1340 delete l3b;
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001341 delete a_e;
Neale Ranns812ed392017-10-16 04:20:13 -07001342 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1343 rc_t::OK);
1344 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001345 ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001346 hw_ifh.data(), hw_acl.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001347 ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl));
Mohsin Kazmi04def742018-03-07 19:53:51 +01001348 ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001349 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1350 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001351
1352 TRY_CHECK(OM::remove(fyodor));
1353}
1354
Mohsin Kazmi12fe8782018-10-30 19:24:34 +01001355BOOST_AUTO_TEST_CASE(test_igmp) {
1356 VppInit vi;
1357 const std::string Isaiah = "IsaiahBerlin";
1358 rc_t rc = rc_t::OK;
1359
Ole Troan003d5da2018-12-18 12:23:13 +01001360 boost::asio::ip::address_v4 gaddr = boost::asio::ip::address_v4::from_string("232.0.0.1");
1361 boost::asio::ip::address_v4 saddr1 = boost::asio::ip::address_v4::from_string("192.168.0.20");
1362 boost::asio::ip::address_v4 saddr2 = boost::asio::ip::address_v4::from_string("192.168.0.30");
Mohsin Kazmi12fe8782018-10-30 19:24:34 +01001363
1364 std::string itf3_name = "host3";
1365 interface itf3(itf3_name,
1366 interface::type_t::AFPACKET,
1367 interface::admin_state_t::UP);
1368 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1369 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1370 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1371 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1372 TRY_CHECK_RC(OM::write(Isaiah, itf3));
1373
1374 igmp_binding *ib = new igmp_binding(itf3);
1375 HW::item<bool> hw_binding(true, rc_t::OK);
1376 ADD_EXPECT(igmp_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
1377 TRY_CHECK_RC(OM::write(Isaiah, *ib));
1378
1379 igmp_listen::src_addrs_t saddrs = {saddr1, saddr2};
1380
1381 igmp_listen *il = new igmp_listen(*ib, gaddr, saddrs);
1382 HW::item<bool> hw_as_listen(true, rc_t::OK);
1383 ADD_EXPECT(igmp_listen_cmds::listen_cmd(hw_as_listen, hw_ifh.data(), gaddr, saddrs));
1384 TRY_CHECK_RC(OM::write(Isaiah, *il));
1385
1386 delete il;
1387 delete ib;
1388
1389 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1390 rc_t::OK);
1391 STRICT_ORDER_OFF();
1392 ADD_EXPECT(igmp_listen_cmds::unlisten_cmd(hw_as_listen, hw_ifh.data(), gaddr));
1393 ADD_EXPECT(igmp_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1394 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1395 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1396
1397 TRY_CHECK(OM::remove(Isaiah));
1398}
1399
Neale Ranns812ed392017-10-16 04:20:13 -07001400BOOST_AUTO_TEST_CASE(test_arp_proxy) {
1401 VppInit vi;
1402 const std::string kurt = "KurtVonnegut";
1403 rc_t rc = rc_t::OK;
1404
1405 asio::ip::address_v4 low = asio::ip::address_v4::from_string("10.0.0.0");
1406 asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255");
1407
1408 arp_proxy_config ap(low, high);
1409 HW::item<bool> hw_ap_cfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001410 ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001411 TRY_CHECK_RC(OM::write(kurt, ap));
1412
1413 std::string itf3_name = "host3";
1414 interface itf3(itf3_name,
1415 interface::type_t::AFPACKET,
1416 interface::admin_state_t::UP);
1417 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1418 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001419 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1420 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001421 TRY_CHECK_RC(OM::write(kurt, itf3));
1422
Neale Ranns0053de62018-05-22 08:40:52 -07001423 arp_proxy_binding *apb = new arp_proxy_binding(itf3);
Neale Ranns812ed392017-10-16 04:20:13 -07001424 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001425 ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001426 TRY_CHECK_RC(OM::write(kurt, *apb));
1427
1428 delete apb;
1429
1430 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1431 rc_t::OK);
1432 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001433 ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1434 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1435 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1436 ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001437
1438 TRY_CHECK(OM::remove(kurt));
1439}
1440
Mohsin Kazmie23edac2018-09-25 18:26:52 +02001441BOOST_AUTO_TEST_CASE(test_ip_punt_redirect) {
1442 VppInit vi;
1443 const std::string eliot = "EliotReed";
1444 rc_t rc = rc_t::OK;
1445
1446 /*
1447 * Interface 1 is the tx interface
1448 */
1449 std::string itf1_name = "tx-itf";
1450 interface itf1(itf1_name,
1451 interface::type_t::AFPACKET,
1452 interface::admin_state_t::UP);
1453 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1454 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1455 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1456 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1457 TRY_CHECK_RC(OM::write(eliot, itf1));
1458
1459 boost::asio::ip::address addr = boost::asio::ip::address::from_string("192.168.0.20");
1460
1461 /*
1462 * Interface 2 is the rx interface
1463 */
1464 std::string itf2_name = "rx-itf";
1465 interface itf2(itf2_name,
1466 interface::type_t::AFPACKET,
1467 interface::admin_state_t::UP);
1468
1469 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1470 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1471 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1472 TRY_CHECK_RC(OM::write(eliot, itf2));
1473
1474 ip_punt_redirect *ip_punt = new ip_punt_redirect(itf2, itf1, addr);
1475 HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1476 HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
1477 ADD_EXPECT(ip_punt_redirect_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data(), addr));
1478 TRY_CHECK_RC(OM::write(eliot, *ip_punt));
1479
1480 delete ip_punt;
1481
1482 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1483 STRICT_ORDER_OFF();
1484 ADD_EXPECT(ip_punt_redirect_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data(), addr));
1485 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1486 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1487 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1488 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1489
1490 TRY_CHECK(OM::remove(eliot));
1491}
1492
Neale Ranns812ed392017-10-16 04:20:13 -07001493BOOST_AUTO_TEST_CASE(test_ip_unnumbered) {
1494 VppInit vi;
1495 const std::string eric = "EricAmbler";
1496 rc_t rc = rc_t::OK;
1497
1498 /*
1499 * Interface 1 has the L3 address
1500 */
1501 std::string itf1_name = "host1";
1502 interface itf1(itf1_name,
1503 interface::type_t::AFPACKET,
1504 interface::admin_state_t::UP);
1505 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1506 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001507 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1508 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001509 TRY_CHECK_RC(OM::write(eric, itf1));
1510
1511 route::prefix_t pfx_10("10.10.10.10", 24);
1512 l3_binding *l3 = new l3_binding(itf1, pfx_10);
1513 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1514 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001515 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001516 TRY_CHECK_RC(OM::write(eric, *l3));
1517
1518 /*
1519 * Interface 2 is unnumbered
1520 */
1521 std::string itf2_name = "host2";
1522 interface itf2(itf2_name,
1523 interface::type_t::AFPACKET,
1524 interface::admin_state_t::UP);
1525
1526 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001527 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1528 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001529 TRY_CHECK_RC(OM::write(eric, itf2));
1530
1531 ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1);
1532 HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1533 HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001534 ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001535 TRY_CHECK_RC(OM::write(eric, *ipun));
1536
1537 delete l3;
1538 delete ipun;
1539
1540 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1541 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001542 ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data()));
1543 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1544 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1545 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1546 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1547 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001548
1549 TRY_CHECK(OM::remove(eric));
1550}
1551
1552BOOST_AUTO_TEST_CASE(test_ip6nd) {
1553 VppInit vi;
1554 const std::string paulo = "PauloCoelho";
1555 rc_t rc = rc_t::OK;
1556
1557 /*
1558 * ra config
1559 */
1560 std::string itf_name = "host_ip6nd";
1561 interface itf(itf_name,
1562 interface::type_t::AFPACKET,
1563 interface::admin_state_t::UP);
1564 HW::item<handle_t> hw_ifh(3, rc_t::OK);
1565 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001566 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
1567 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001568 TRY_CHECK_RC(OM::write(paulo, itf));
1569
1570 route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128);
1571 l3_binding *l3 = new l3_binding(itf, pfx_10);
1572 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1573 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001574 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001575 TRY_CHECK_RC(OM::write(paulo, *l3));
1576
1577 ra_config ra(0, 1, 0, 4);
1578 ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra);
1579 HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK);
1580 HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK);
1581 ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra));
1582 TRY_CHECK_RC(OM::write(paulo, *ip6ra));
1583
1584 /*
1585 * ra prefix
1586 */
1587 ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800);
1588 ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx);
1589 HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK);
1590 HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK);
1591 ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx));
1592 TRY_CHECK_RC(OM::write(paulo, *ip6pfx));
1593
1594 delete ip6pfx;
1595
1596 ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx));
1597
1598 delete ip6ra;
1599 delete l3;
1600
1601 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1602
1603 STRICT_ORDER_OFF();
1604 ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001605 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1606 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1607 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001608
1609 TRY_CHECK(OM::remove(paulo));
1610}
1611
1612BOOST_AUTO_TEST_CASE(test_interface_span) {
1613 VppInit vi;
1614 const std::string elif = "ElifShafak";
1615 rc_t rc = rc_t::OK;
1616
1617 /*
1618 * Interface 1 to be mirrored
1619 */
1620 std::string itf1_name = "port-from";
1621 interface itf1(itf1_name,
1622 interface::type_t::AFPACKET,
1623 interface::admin_state_t::UP);
1624 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1625 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001626 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1627 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001628 TRY_CHECK_RC(OM::write(elif, itf1));
1629
1630 /*
1631 * Interface 2 where traffic is mirrored
1632 */
1633 std::string itf2_name = "port-to";
1634 interface itf2(itf2_name,
1635 interface::type_t::AFPACKET,
1636 interface::admin_state_t::UP);
1637
1638 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1639 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1640
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001641 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1642 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001643 TRY_CHECK_RC(OM::write(elif, itf2));
1644
1645 interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED);
1646 HW::item<bool> hw_is_cfg(true, rc_t::OK);
1647 HW::item<bool> hw_is_uncfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001648 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 -07001649 TRY_CHECK_RC(OM::write(elif, *itf_span));
1650
1651 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1652 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1653
1654 delete itf_span;
1655 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001656 ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data()));
1657 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1658 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1659 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1660 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001661
1662 TRY_CHECK(OM::remove(elif));
1663}
1664
1665BOOST_AUTO_TEST_CASE(test_routing) {
1666 VppInit vi;
1667 const std::string ian = "IanFleming";
1668 rc_t rc = rc_t::OK;
1669
1670 /*
1671 * non-default route domain
1672 */
1673 route_domain rd4(1);
1674 HW::item<bool> hw_rd4_create(true, rc_t::OK);
1675 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
1676 HW::item<bool> hw_rd6_create(true, rc_t::OK);
1677 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
1678 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
1679 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
1680 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
1681 HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001682 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
1683 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001684 TRY_CHECK_RC(OM::write(ian, rd4));
1685
1686 /*
1687 * a couple of interfaces
1688 */
1689 std::string itf1_name = "af1";
1690 interface itf1(itf1_name,
1691 interface::type_t::AFPACKET,
1692 interface::admin_state_t::UP);
1693 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1694 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1695 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001696 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1697 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001698 TRY_CHECK_RC(OM::write(ian, itf1));
1699
1700 std::string itf2_name = "af2";
1701 interface *itf2 = new interface(itf2_name,
1702 interface::type_t::AFPACKET,
1703 interface::admin_state_t::UP,
1704 rd4);
1705
1706 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1707 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1708 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001709 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1710 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1711 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
1712 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001713 TRY_CHECK_RC(OM::write(ian, *itf2));
1714
1715 /*
1716 * prefix on each interface
1717 */
1718 route::prefix_t pfx_10("10.10.10.10", 24);
1719 l3_binding *l3_10 = new l3_binding(itf1, pfx_10);
1720 HW::item<bool> hw_l3_10_bind(true, rc_t::OK);
1721 HW::item<bool> hw_l3_10_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001722 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001723 TRY_CHECK_RC(OM::write(ian, *l3_10));
1724 route::prefix_t pfx_11("11.11.11.11", 24);
1725 l3_binding *l3_11 = new l3_binding(*itf2, pfx_11);
1726 HW::item<bool> hw_l3_11_bind(true, rc_t::OK);
1727 HW::item<bool> hw_l3_11_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001728 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11));
Neale Ranns812ed392017-10-16 04:20:13 -07001729 TRY_CHECK_RC(OM::write(ian, *l3_11));
1730
1731 /*
1732 * A route via interface 1 in the default table
1733 */
1734 route::prefix_t pfx_5("5.5.5.5", 32);
Neale Ranns6ad72312019-01-10 08:56:38 -08001735 boost::asio::ip::address nh_9 = boost::asio::ip::address::from_string("10.10.10.9");
1736 route::path *path_9 = new route::path(nh_9, itf1);
Neale Ranns812ed392017-10-16 04:20:13 -07001737 boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11");
1738 route::path *path_10 = new route::path(nh_10, itf1);
1739 route::ip_route *route_5 = new route::ip_route(pfx_5);
1740 route_5->add(*path_10);
Neale Ranns6ad72312019-01-10 08:56:38 -08001741 route_5->add(*path_9);
Neale Ranns812ed392017-10-16 04:20:13 -07001742 HW::item<bool> hw_route_5(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001743 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, *path_9));
1744 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, *path_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001745 TRY_CHECK_RC(OM::write(ian, *route_5));
1746
Neale Ranns6ad72312019-01-10 08:56:38 -08001747 route_5->remove(*path_9);
1748 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5, *path_9));
1749 TRY_CHECK_RC(OM::write(ian, *route_5));
1750
1751 delete path_9;
1752
Neale Ranns812ed392017-10-16 04:20:13 -07001753 /*
1754 * A route via interface 2 in the non-default table
1755 */
1756 boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10");
1757 route::path *path_11 = new route::path(nh_11, *itf2);
Neale Ranns6ad72312019-01-10 08:56:38 -08001758 boost::asio::ip::address nh_12 = boost::asio::ip::address::from_string("11.11.11.12");
1759 route::path *path_12 = new route::path(nh_12, *itf2);
Neale Ranns812ed392017-10-16 04:20:13 -07001760 route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5);
1761 route_5_2->add(*path_11);
1762 HW::item<bool> hw_route_5_2(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001763 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, *path_11));
1764 TRY_CHECK_RC(OM::write(ian, *route_5_2));
1765
1766 route_5_2->add(*path_12);
1767 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, *path_12));
Neale Ranns812ed392017-10-16 04:20:13 -07001768 TRY_CHECK_RC(OM::write(ian, *route_5_2));
1769
1770 /*
1771 * An ARP entry for the neighbour on itf1
1772 */
1773 HW::item<bool> hw_neighbour(true, rc_t::OK);
1774 mac_address_t mac_n({0,1,2,4,5,6});
Neale Rannsfd920602017-11-23 12:15:00 -08001775 neighbour *ne = new neighbour(itf1, nh_10, mac_n);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001776 ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001777 TRY_CHECK_RC(OM::write(ian, *ne));
1778
1779 /*
1780 * A DVR route
1781 */
1782 route::prefix_t pfx_6("6.6.6.6", 32);
1783 route::path *path_l2 = new route::path(*itf2, nh_proto_t::ETHERNET);
1784 route::ip_route *route_dvr = new route::ip_route(pfx_6);
1785 route_dvr->add(*path_l2);
1786 HW::item<bool> hw_route_dvr(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001787 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, *path_l2));
Neale Ranns812ed392017-10-16 04:20:13 -07001788 TRY_CHECK_RC(OM::write(ian, *route_dvr));
1789
Neale Ranns7c03ed42018-12-27 03:21:28 -08001790 /*
1791 * a multicast route
1792 */
1793 route::mprefix_t mpfx_4(boost::asio::ip::address::from_string("232.1.1.1"), 32);
1794 route::ip_mroute *mroute_4 = new route::ip_mroute(mpfx_4);
1795
1796 route::path *mp1 = new route::path(itf1, nh_proto_t::IPV4);
1797 route::path *mp2 = new route::path(*itf2, nh_proto_t::IPV4);
1798 mroute_4->add(*mp1, route::itf_flags_t::FORWARD);
1799 mroute_4->add(*mp1, route::itf_flags_t::ACCEPT);
1800 mroute_4->add(*mp2, route::itf_flags_t::FORWARD);
1801 HW::item<bool> hw_mroute_4(true, rc_t::OK);
1802 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1803 *mp1, route::itf_flags_t::FORWARD));
1804 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1805 *mp2, route::itf_flags_t::FORWARD));
1806 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1807 *mp1, route::itf_flags_t::ACCEPT));
1808 TRY_CHECK_RC(OM::write(ian, *mroute_4));
1809
Neale Ranns812ed392017-10-16 04:20:13 -07001810 STRICT_ORDER_OFF();
1811 // delete the stack objects that hold references to others
1812 // so the OM::remove is the call that removes the last reference
1813 delete l3_11;
1814 delete l3_10;
1815 delete itf2;
1816 delete route_5;
Neale Ranns812ed392017-10-16 04:20:13 -07001817 delete route_5_2;
Neale Ranns812ed392017-10-16 04:20:13 -07001818 delete route_dvr;
Neale Ranns812ed392017-10-16 04:20:13 -07001819 delete ne;
Neale Ranns7c03ed42018-12-27 03:21:28 -08001820 delete mroute_4;
1821
1822 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1823 *mp1, route::itf_flags_t::FORWARD));
1824 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1825 *mp2, route::itf_flags_t::FORWARD));
1826 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1827 *mp1, route::itf_flags_t::ACCEPT));
1828
1829 delete mp1;
1830 delete mp2;
1831
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001832 ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
Neale Ranns6ad72312019-01-10 08:56:38 -08001833 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6, *path_l2));
1834 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_11));
1835 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_12));
1836 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5, *path_10));
1837
1838 delete path_10;
1839 delete path_11;
1840 delete path_12;
1841 delete path_l2;
1842
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001843 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10));
1844 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11));
1845 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1846 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1847 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
1848 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2));
1849 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1850 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1851 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
1852 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001853
1854 TRY_CHECK(OM::remove(ian));
1855}
1856
1857BOOST_AUTO_TEST_CASE(test_nat) {
1858 VppInit vi;
1859 const std::string gs = "GeorgeSimenon";
1860 rc_t rc = rc_t::OK;
1861
1862 /*
1863 * Inside Interface
1864 */
1865 std::string itf_in_name = "inside";
1866 interface itf_in(itf_in_name,
1867 interface::type_t::AFPACKET,
1868 interface::admin_state_t::UP);
1869 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1870 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1871 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001872 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name));
1873 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001874 TRY_CHECK_RC(OM::write(gs, itf_in));
1875
1876 /*
1877 * outside
1878 */
1879 std::string itf_out_name = "port-to";
1880 interface itf_out(itf_out_name,
1881 interface::type_t::AFPACKET,
1882 interface::admin_state_t::UP);
1883
1884 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1885 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1886 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1887
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001888 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name));
1889 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001890 TRY_CHECK_RC(OM::write(gs, itf_out));
1891
1892 /*
1893 * A NAT static mapping
1894 */
1895 boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1");
1896 boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1");
1897
1898 nat_static ns(in_addr, out_addr);
1899 HW::item<bool> hw_ns(true, rc_t::OK);
1900
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001901 ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
Neale Ranns812ed392017-10-16 04:20:13 -07001902 TRY_CHECK_RC(OM::write(gs, ns));
1903
1904 /*
1905 * bind nat inside and out
1906 */
1907 nat_binding *nb_in = new nat_binding(itf_in,
1908 direction_t::INPUT,
1909 l3_proto_t::IPV4,
1910 nat_binding::zone_t::INSIDE);
1911 HW::item<bool> hw_nb_in(true, rc_t::OK);
1912
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001913 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in,
1914 hw_ifh.data().value(),
1915 nat_binding::zone_t::INSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001916 TRY_CHECK_RC(OM::write(gs, *nb_in));
1917
1918 nat_binding *nb_out = new nat_binding(itf_out,
1919 direction_t::INPUT,
1920 l3_proto_t::IPV4,
1921 nat_binding::zone_t::OUTSIDE);
1922 HW::item<bool> hw_nb_out(true, rc_t::OK);
1923
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001924 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out,
1925 hw_ifh2.data().value(),
1926 nat_binding::zone_t::OUTSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001927 TRY_CHECK_RC(OM::write(gs, *nb_out));
1928
1929
1930 STRICT_ORDER_OFF();
1931 delete nb_in;
1932 delete nb_out;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001933 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in,
1934 hw_ifh.data().value(),
1935 nat_binding::zone_t::INSIDE));
1936 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out,
1937 hw_ifh2.data().value(),
1938 nat_binding::zone_t::OUTSIDE));
1939 ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
1940 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1941 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name));
1942 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1943 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001944
1945 TRY_CHECK(OM::remove(gs));
1946}
1947
1948BOOST_AUTO_TEST_CASE(test_interface_events) {
1949 VppInit vi;
1950 MockListener ml;
1951
1952 HW::item<bool> hw_want(true, rc_t::OK);
1953
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001954 ADD_EXPECT(interface_cmds::events_cmd(ml));
1955 cmd* itf = new interface_cmds::events_cmd(ml);
Neale Ranns812ed392017-10-16 04:20:13 -07001956
1957 HW::enqueue(itf);
1958 HW::write();
Neale Ranns812ed392017-10-16 04:20:13 -07001959}
1960
Neale Ranns352ea0c2017-11-14 11:04:28 -08001961BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
1962 VppInit vi;
1963 const std::string rene = "ReneGoscinny";
1964 rc_t rc = rc_t::OK;
1965
1966 /*
1967 * Create an interface with two IP addresses
1968 */
1969 std::string itf1_name = "host1";
1970 interface itf1(itf1_name,
1971 interface::type_t::AFPACKET,
1972 interface::admin_state_t::UP);
1973 HW::item<handle_t> hw_ifh1(2, rc_t::OK);
1974 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1975 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1976 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name));
1977 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1));
1978 TRY_CHECK_RC(OM::write(rene, itf1));
1979
1980 route::prefix_t pfx_10("10.10.10.10", 24);
1981 l3_binding *l3_1 = new l3_binding(itf1, pfx_10);
1982 HW::item<bool> hw_l3_bind1(true, rc_t::OK);
1983 HW::item<bool> hw_l3_unbind1(false, rc_t::OK);
1984 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
1985 TRY_CHECK_RC(OM::write(rene, *l3_1));
1986
1987 route::prefix_t pfx_11("10.10.11.11", 24);
1988 l3_binding *l3_2 = new l3_binding(itf1, pfx_11);
1989 HW::item<bool> hw_l3_bind2(true, rc_t::OK);
1990 HW::item<bool> hw_l3_unbind2(false, rc_t::OK);
1991 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
1992 TRY_CHECK_RC(OM::write(rene, *l3_2));
1993
1994 route_domain rd(1);
1995 HW::item<bool> hw_rd_create(true, rc_t::OK);
1996 HW::item<bool> hw_rd_delete(false, rc_t::OK);
1997 HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK);
1998 HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK);
1999 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1));
2000 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1));
2001 TRY_CHECK_RC(OM::write(rene, rd));
2002
2003 /*
2004 * update the interface to change to a new route-domain
2005 * expect that the l3-bindings are removed and readded.
2006 */
2007 interface *itf2 = new interface(itf1_name,
2008 interface::type_t::AFPACKET,
2009 interface::admin_state_t::UP,
2010 rd);
2011 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2012 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2013 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1));
2014 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1));
2015 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2016 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2017 TRY_CHECK_RC(OM::write(rene, *itf2));
2018
2019 /*
2020 * mve the interface back to the default route-domain
2021 */
2022 interface itf3(itf1_name,
2023 interface::type_t::AFPACKET,
2024 interface::admin_state_t::UP);
2025 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2026 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2027 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1));
2028 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1));
2029 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2030 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2031 TRY_CHECK_RC(OM::write(rene, itf3));
2032
2033 delete l3_1;
2034 delete l3_2;
2035 delete itf2;
2036
2037 STRICT_ORDER_OFF();
2038 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2039 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2040 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1));
2041 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name));
2042 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1));
2043 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1));
2044
2045 TRY_CHECK(OM::remove(rene));
2046}
2047
Neale Rannsd3464b52017-12-07 08:48:02 -08002048BOOST_AUTO_TEST_CASE(test_prefixes) {
2049 route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);
2050
2051 BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));
2052
2053 route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);
2054
2055 BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
2056 BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));
2057
2058 route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
2059 BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
2060 BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));
2061
2062 route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);
2063
2064 BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));
2065
2066 route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);
2067
2068 BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
2069 BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2070 BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));
2071
2072 route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);
2073
2074 BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
2075 BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2076 BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));
2077
2078 route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);
2079
2080 BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
2081 BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2082 BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2083
2084}
2085
Neale Ranns208c29a2018-04-11 08:08:30 -07002086BOOST_AUTO_TEST_CASE(test_pipes) {
2087 VppInit vi;
2088 const std::string gk = "GKChesterton";
2089
2090 const std::string pipe_name_1 = "pipe1";
2091 VOM::pipe pipe1(1, interface::admin_state_t::UP);
2092 HW::item<handle_t> hw_hdl(4, rc_t::OK);
2093 HW::item<pipe::handle_pair_t> hw_hdl_pair(std::make_pair(5,6), rc_t::OK);
2094
2095 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
2096 rc_t::OK);
2097 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
2098 rc_t::OK);
2099 ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair));
2100 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl));
2101 TRY_CHECK_RC(OM::write(gk, pipe1));
2102
2103 pipe1.set_ends(hw_hdl_pair.data());
2104
2105 // put each end of the pipe in a BD
2106 bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
2107 bridge_domain::arp_term_mode_t::OFF,
2108 bridge_domain::flood_mode_t::OFF,
2109 bridge_domain::mac_age_mode_t::ON);
2110
2111 HW::item<uint32_t> hw_bd(33, rc_t::OK);
2112 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
2113 bridge_domain::learning_mode_t::OFF,
2114 bridge_domain::arp_term_mode_t::OFF,
2115 bridge_domain::flood_mode_t::OFF,
2116 bridge_domain::mac_age_mode_t::ON));
2117
2118 TRY_CHECK_RC(OM::write(gk, bd1));
2119
2120 l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1);
2121 HW::item<bool> hw_l2_1_bind(true, rc_t::OK);
2122
2123 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind,
2124 pipe1.east()->handle(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002125 hw_bd.data(),
2126 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002127 TRY_CHECK_RC(OM::write(gk, *l2_1));
2128
2129 l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1);
2130 HW::item<bool> hw_l2_2_bind(true, rc_t::OK);
2131
2132 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind,
2133 pipe1.west()->handle(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002134 hw_bd.data(),
2135 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002136 TRY_CHECK_RC(OM::write(gk, *l2_2));
2137
2138 STRICT_ORDER_OFF();
2139
2140 delete l2_1;
2141 delete l2_2;
2142 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2143 pipe1.east()->handle(),
2144 hw_bd.data(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002145 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002146 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2147 pipe1.west()->handle(),
2148 hw_bd.data(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002149 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002150 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl));
2151 ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair));
2152 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
2153 TRY_CHECK(OM::remove(gk));
2154}
2155
Neale Ranns812ed392017-10-16 04:20:13 -07002156BOOST_AUTO_TEST_SUITE_END()