blob: 26653940d2ef61a9b20d0648791692c8ecad8a5c [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
2 * Test suite for class VppOM
3 *
4 * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
5 *
6 * This program and the accompanying materials are made available under the
7 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 */
10#define BOOST_TEST_MODULE "VPP OBJECT MODEL"
11#define BOOST_TEST_DYN_LINK
12
13#include <boost/test/unit_test.hpp>
14#include <boost/assign/list_inserter.hpp>
15
16
17#include <iostream>
18#include <deque>
19
20#include "vom/om.hpp"
21#include "vom/interface.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070022#include "vom/interface_cmds.hpp"
Mohsin Kazmied76ee22018-03-02 12:31:37 +010023#include "vom/bond_interface_cmds.hpp"
24#include "vom/bond_group_binding.hpp"
25#include "vom/bond_group_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070026#include "vom/l2_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070027#include "vom/l2_binding_cmds.hpp"
Neale Ranns53322002019-02-22 02:48:25 -080028#include "vom/l2_vtr_cmds.hpp"
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +020029#include "vom/l2_xconnect.hpp"
30#include "vom/l2_xconnect_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070031#include "vom/l3_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070032#include "vom/l3_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070033#include "vom/bridge_domain.hpp"
34#include "vom/bridge_domain_entry.hpp"
35#include "vom/bridge_domain_arp_entry.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070036#include "vom/bridge_domain_cmds.hpp"
37#include "vom/bridge_domain_entry_cmds.hpp"
38#include "vom/bridge_domain_arp_entry_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070039#include "vom/prefix.hpp"
40#include "vom/route.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070041#include "vom/route_cmds.hpp"
Neale Ranns7c03ed42018-12-27 03:21:28 -080042#include "vom/mroute_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070043#include "vom/route_domain.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070044#include "vom/route_domain_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070045#include "vom/vxlan_tunnel.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070046#include "vom/vxlan_tunnel_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070047#include "vom/sub_interface.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070048#include "vom/sub_interface_cmds.hpp"
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +010049#include "vom/acl_ethertype.hpp"
50#include "vom/acl_ethertype_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070051#include "vom/acl_list.hpp"
52#include "vom/acl_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070053#include "vom/acl_list_cmds.hpp"
54#include "vom/acl_binding_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070055#include "vom/acl_l3_rule.hpp"
56#include "vom/acl_l2_rule.hpp"
57#include "vom/arp_proxy_config.hpp"
58#include "vom/arp_proxy_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070059#include "vom/arp_proxy_config_cmds.hpp"
60#include "vom/arp_proxy_binding_cmds.hpp"
Mohsin Kazmi12fe8782018-10-30 19:24:34 +010061#include "vom/igmp_binding.hpp"
62#include "vom/igmp_binding_cmds.hpp"
63#include "vom/igmp_listen.hpp"
64#include "vom/igmp_listen_cmds.hpp"
Mohsin Kazmie23edac2018-09-25 18:26:52 +020065#include "vom/ip_punt_redirect.hpp"
66#include "vom/ip_punt_redirect_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070067#include "vom/ip_unnumbered.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070068#include "vom/ip_unnumbered_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070069#include "vom/interface_ip6_nd.hpp"
70#include "vom/interface_span.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070071#include "vom/interface_span_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070072#include "vom/neighbour.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070073#include "vom/neighbour_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070074#include "vom/nat_static.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070075#include "vom/nat_static_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070076#include "vom/nat_binding.hpp"
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070077#include "vom/nat_binding_cmds.hpp"
Neale Ranns208c29a2018-04-11 08:08:30 -070078#include "vom/pipe.hpp"
79#include "vom/pipe_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070080
81using namespace boost;
82using namespace VOM;
83
84/**
85 * An expectation exception
86 */
87class ExpException
88{
89public:
90 ExpException(unsigned int number)
91 {
92 // a neat place to add a break point
93 std::cout << " ExpException here: " << number << std::endl;
94 }
95};
96
97class MockListener : public interface::event_listener,
98 public interface::stat_listener
99{
Mohsin Kazmi51edc3a2018-11-21 19:00:46 +0100100 void handle_interface_stat(const interface& itf)
Neale Ranns812ed392017-10-16 04:20:13 -0700101 {
102 }
Neale Ranns193c47d2018-12-10 06:01:46 -0800103 void handle_interface_event(std::vector<VOM::interface::event> events)
Neale Ranns812ed392017-10-16 04:20:13 -0700104 {
105 }
106};
107
108class MockCmdQ : public HW::cmd_q
109{
110public:
111 MockCmdQ():
112 m_strict_order(true)
113 {
114 }
115 virtual ~MockCmdQ()
116 {
117 }
118 void expect(cmd *f)
119 {
120 m_exp_queue.push_back(f);
121 }
122 void enqueue(cmd *f)
123 {
124 m_act_queue.push_back(f);
125 }
126 void enqueue(std::queue<cmd*> &cmds)
127 {
128 while (cmds.size())
129 {
130 m_act_queue.push_back(cmds.front());
131 cmds.pop();
132 }
133 }
134 void enqueue(std::shared_ptr<cmd> f)
135 {
136 m_act_queue.push_back(f.get());
137 }
138
139 void dequeue(cmd *f)
140 {
141 }
142
143 void dequeue(std::shared_ptr<cmd> cmd)
144 {
145 }
146
147 void strict_order(bool on)
148 {
149 m_strict_order = on;
150 }
151
152 bool is_empty()
153 {
154 return ((0 == m_exp_queue.size()) &&
155 (0 == m_act_queue.size()));
156 }
157
158 rc_t write()
159 {
160 cmd *f_exp, *f_act;
161 rc_t rc = rc_t::OK;
162
163 while (m_act_queue.size())
164 {
165 bool matched = false;
166 auto it_exp = m_exp_queue.begin();
167 auto it_act = m_act_queue.begin();
168
169 f_act = *it_act;
170
171 std::cout << " Act: " << f_act->to_string() << std::endl;
172 while (it_exp != m_exp_queue.end())
173 {
174 f_exp = *it_exp;
175 try
176 {
177 std::cout << " Exp: " << f_exp->to_string() << std::endl;
178
179 if (typeid(*f_exp) != typeid(*f_act))
180 {
181 throw ExpException(1);
182 }
183
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700184 if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700185 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700186 rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700187 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700188 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700189 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700190 rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700191 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800192 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd))
193 {
194 rc = handle_derived<interface_cmds::vhost_create_cmd>(f_exp, f_act);
195 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100196 else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd))
197 {
198 rc = handle_derived<bond_interface_cmds::create_cmd>(f_exp, f_act);
199 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700200 else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700201 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700202 rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700203 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700204 else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700205 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700206 rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700207 }
Neale Ranns4ef42262018-02-20 08:10:44 -0800208 else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd))
209 {
210 rc = handle_derived<interface_cmds::vhost_delete_cmd>(f_exp, f_act);
211 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100212 else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd))
213 {
214 rc = handle_derived<bond_interface_cmds::delete_cmd>(f_exp, f_act);
215 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700216 else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700217 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700218 rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700219 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700220 else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700221 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700222 rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700223 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700224 else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700225 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700226 rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700227 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700228 else if (typeid(*f_exp) == typeid(interface_cmds::set_tag))
Neale Ranns812ed392017-10-16 04:20:13 -0700229 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700230 rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700231 }
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100232 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd))
233 {
234 rc = handle_derived<bond_group_binding_cmds::bind_cmd>(f_exp, f_act);
235 }
236 else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd))
237 {
238 rc = handle_derived<bond_group_binding_cmds::unbind_cmd>(f_exp, f_act);
239 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700240 else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700241 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700242 rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700243 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700244 else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700245 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700246 rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700247 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700248 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700249 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700250 rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700251 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700252 else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700253 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700254 rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700255 }
Neale Ranns7c03ed42018-12-27 03:21:28 -0800256 else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::update_cmd))
257 {
258 rc = handle_derived<route::ip_mroute_cmds::update_cmd>(f_exp, f_act);
259 }
260 else if (typeid(*f_exp) == typeid(route::ip_mroute_cmds::delete_cmd))
261 {
262 rc = handle_derived<route::ip_mroute_cmds::delete_cmd>(f_exp, f_act);
263 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700264 else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700265 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700266 rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700267 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700268 else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700269 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700270 rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700271 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700272 else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700273 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700274 rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700275 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700276 else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700277 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700278 rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700279 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700280 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700281 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700282 rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700283 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700284 else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700285 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700286 rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700287 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700288 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700289 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700290 rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700291 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700292 else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700293 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700294 rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700295 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700296 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700297 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700298 rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700299 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700300 else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700301 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700302 rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700303 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700304 else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700305 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700306 rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700307 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700308 else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700309 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700310 rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700311 }
Neale Ranns53322002019-02-22 02:48:25 -0800312 else if (typeid(*f_exp) == typeid(l2_vtr_cmds::set_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700313 {
Neale Ranns53322002019-02-22 02:48:25 -0800314 rc = handle_derived<l2_vtr_cmds::set_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700315 }
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +0200316 else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd))
317 {
318 rc = handle_derived<l2_xconnect_cmds::bind_cmd>(f_exp, f_act);
319 }
320 else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::unbind_cmd))
321 {
322 rc = handle_derived<l2_xconnect_cmds::unbind_cmd>(f_exp, f_act);
323 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700324 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700325 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700326 rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700327 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700328 else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700329 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700330 rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700331 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700332 else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700333 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700334 rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700335 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700336 else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700337 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700338 rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700339 }
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +0100340 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd))
341 {
342 rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act);
343 }
Mohsin Kazmi04def742018-03-07 19:53:51 +0100344 else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd))
345 {
346 rc = handle_derived<ACL::acl_ethertype_cmds::unbind_cmd>(f_exp, f_act);
347 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700348 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700349 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700350 rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700351 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700352 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700353 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700354 rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700355 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700356 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700357 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700358 rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700359 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700360 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700361 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700362 rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700363 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700364 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700365 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700366 rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700367 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700368 else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700369 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700370 rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700371 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700372 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700373 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700374 rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700375 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700376 else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700377 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700378 rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700379 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700380 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700381 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700382 rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700383 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700384 else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700385 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700386 rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700387 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700388 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700389 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700390 rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700391 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700392 else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700393 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700394 rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700395 }
Mohsin Kazmi12fe8782018-10-30 19:24:34 +0100396 else if (typeid(*f_exp) == typeid(igmp_binding_cmds::bind_cmd))
397 {
398 rc = handle_derived<igmp_binding_cmds::bind_cmd>(f_exp, f_act);
399 }
400 else if (typeid(*f_exp) == typeid(igmp_binding_cmds::unbind_cmd))
401 {
402 rc = handle_derived<igmp_binding_cmds::unbind_cmd>(f_exp, f_act);
403 }
404 else if (typeid(*f_exp) == typeid(igmp_listen_cmds::listen_cmd))
405 {
406 rc = handle_derived<igmp_listen_cmds::listen_cmd>(f_exp, f_act);
407 }
408 else if (typeid(*f_exp) == typeid(igmp_listen_cmds::unlisten_cmd))
409 {
410 rc = handle_derived<igmp_listen_cmds::unlisten_cmd>(f_exp, f_act);
411 }
Mohsin Kazmie23edac2018-09-25 18:26:52 +0200412 else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::config_cmd))
413 {
414 rc = handle_derived<ip_punt_redirect_cmds::config_cmd>(f_exp, f_act);
415 }
416 else if (typeid(*f_exp) == typeid(ip_punt_redirect_cmds::unconfig_cmd))
417 {
418 rc = handle_derived<ip_punt_redirect_cmds::unconfig_cmd>(f_exp, f_act);
419 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700420 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700421 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700422 rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700423 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700424 else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700425 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700426 rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700427 }
428 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd))
429 {
430 rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act);
431 }
432 else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd))
433 {
434 rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act);
435 }
436 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd))
437 {
438 rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act);
439 }
440 else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd))
441 {
442 rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act);
443 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700444 else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700445 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700446 rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700447 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700448 else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700449 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700450 rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700451 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700452 else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700453 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700454 rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700455 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700456 else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700457 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700458 rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700459 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700460 else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700461 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700462 rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700463 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700464 else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700465 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700466 rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700467 }
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700468 else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd))
Neale Ranns812ed392017-10-16 04:20:13 -0700469 {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700470 rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
Neale Ranns812ed392017-10-16 04:20:13 -0700471 }
Neale Ranns208c29a2018-04-11 08:08:30 -0700472 else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd))
473 {
474 rc = handle_derived<pipe_cmds::create_cmd>(f_exp, f_act);
475 }
476 else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd))
477 {
478 rc = handle_derived<pipe_cmds::delete_cmd>(f_exp, f_act);
479 }
Neale Ranns812ed392017-10-16 04:20:13 -0700480 else
481 {
482 throw ExpException(2);
483 }
484
485 // if we get here then we found the match.
486 m_exp_queue.erase(it_exp);
487 m_act_queue.erase(it_act);
488 delete f_exp;
489 delete f_act;
490
491 // return any injected failures to the agent
492 if (rc_t::OK != rc && rc_t::NOOP != rc)
493 {
494 return (rc);
495 }
496
497 matched = true;
498 break;
499 }
500 catch (ExpException &e)
501 {
502 // The expected and actual do not match
503 if (m_strict_order)
504 {
505 // in strict ordering mode this is fatal, so rethrow
506 throw e;
507 }
508 else
509 {
510 // move the iterator onto the next in the expected list and
511 // check for a match
512 ++it_exp;
513 }
514 }
515 }
516
517 if (!matched)
518 throw ExpException(3);
519 }
520
521 return (rc);
522 }
523private:
524
525 template <typename T>
526 rc_t handle_derived(const cmd *f_exp, cmd *f_act)
527 {
528 const T *i_exp;
529 T *i_act;
530
531 i_exp = dynamic_cast<const T*>(f_exp);
532 i_act = dynamic_cast<T*>(f_act);
533 if (!(*i_exp == *i_act))
534 {
535 throw ExpException(4);
536 }
537 // pass the data and return code to the agent
538 i_act->item() = i_exp->item();
539
540 return (i_act->item().rc());
541 }
542
543 // The Q to push the expectations on
544 std::deque<cmd*> m_exp_queue;
545
546 // the queue to push the actual events on
547 std::deque<cmd*> m_act_queue;
548
549 // control whether the expected queue is strictly ordered.
550 bool m_strict_order;
551};
552
553class VppInit {
554public:
555 std::string name;
556 MockCmdQ *f;
557
558 VppInit()
559 : name("vpp-ut"),
560 f(new MockCmdQ())
561 {
562 HW::init(f);
563 OM::init();
564 logger().set(log_level_t::DEBUG);
565 }
566
567 ~VppInit() {
568 delete f;
569 }
570};
571
Neale Rannsd3464b52017-12-07 08:48:02 -0800572BOOST_AUTO_TEST_SUITE(vom)
Neale Ranns812ed392017-10-16 04:20:13 -0700573
574#define TRY_CHECK_RC(stmt) \
575{ \
576 try { \
577 BOOST_CHECK(rc_t::OK == stmt); \
578 } \
579 catch (ExpException &e) \
580 { \
581 BOOST_CHECK(false); \
582 } \
583 BOOST_CHECK(vi.f->is_empty()); \
584}
585
586#define TRY_CHECK(stmt) \
587{ \
588 try { \
589 stmt; \
590 } \
591 catch (ExpException &e) \
592 { \
593 BOOST_CHECK(false); \
594 } \
595 BOOST_CHECK(vi.f->is_empty()); \
596}
597
598#define ADD_EXPECT(stmt) \
599 vi.f->expect(new stmt)
600
601#define STRICT_ORDER_OFF() \
602 vi.f->strict_order(false)
603
604BOOST_AUTO_TEST_CASE(test_interface) {
605 VppInit vi;
606 const std::string go = "GeorgeOrwell";
607 const std::string js = "JohnSteinbeck";
608 rc_t rc = rc_t::OK;
609
610 /*
611 * George creates and deletes the interface
612 */
613 std::string itf1_name = "afpacket1";
614 interface itf1(itf1_name,
615 interface::type_t::AFPACKET,
616 interface::admin_state_t::UP);
617
618 /*
619 * set the expectation for a afpacket interface create.
620 * 2 is the interface handle VPP [mock] assigns
621 */
622 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700623 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700624
625 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700626 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700627
628 TRY_CHECK_RC(OM::write(go, itf1));
629
630 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700631 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
632 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700633
634 TRY_CHECK(OM::remove(go));
635
636 /*
637 * George creates the interface, then John brings it down.
638 * George's remove is a no-op, sice John also owns the interface
639 */
640 interface itf1b(itf1_name,
641 interface::type_t::AFPACKET,
642 interface::admin_state_t::DOWN);
643
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700644 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
645 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700646 TRY_CHECK_RC(OM::write(go, itf1));
647
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700648 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700649 TRY_CHECK_RC(OM::write(js, itf1b));
650
651 TRY_CHECK(OM::remove(go));
652
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700653 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700654 TRY_CHECK(OM::remove(js));
655
656 /*
657 * George adds an interface, then we flush all of Geroge's state
658 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700659 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
660 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700661 TRY_CHECK_RC(OM::write(go, itf1));
662
663 TRY_CHECK(OM::mark(go));
664
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700665 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
666 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700667 TRY_CHECK(OM::sweep(go));
668
669 /*
670 * George adds an interface. mark stale. update the same interface. sweep
671 * and expect no delete
672 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700673 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
674 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700675 TRY_CHECK_RC(OM::write(go, itf1b));
676
677 TRY_CHECK(OM::mark(go));
678
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700679 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700680 TRY_CHECK_RC(OM::write(go, itf1));
681
682 TRY_CHECK(OM::sweep(go));
683
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700684 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
685 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700686 TRY_CHECK(OM::remove(go));
687
688 /*
689 * George adds an insterface, then we mark that state. Add a second interface
690 * an flush the first that is now stale.
691 */
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700692 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
693 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700694 TRY_CHECK_RC(OM::write(go, itf1));
695
696 TRY_CHECK(OM::mark(go));
697
698 std::string itf2_name = "afpacket2";
Neale Ranns4ef42262018-02-20 08:10:44 -0800699 std::string itf2_tag = "uuid-of-afpacket2-interface";
Neale Ranns812ed392017-10-16 04:20:13 -0700700 interface itf2(itf2_name,
701 interface::type_t::AFPACKET,
Neale Ranns4ef42262018-02-20 08:10:44 -0800702 interface::admin_state_t::UP,
703 itf2_tag);
Neale Ranns812ed392017-10-16 04:20:13 -0700704 HW::item<handle_t> hw_ifh2(3, rc_t::OK);
705
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700706 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
Neale Ranns4ef42262018-02-20 08:10:44 -0800707 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700708 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700709 TRY_CHECK_RC(OM::write(go, itf2));
710
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700711 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
712 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700713 TRY_CHECK(OM::sweep(go));
714
715 TRY_CHECK(OM::mark(go));
716
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700717 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
718 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -0700719 TRY_CHECK(OM::sweep(go));
Neale Ranns4ef42262018-02-20 08:10:44 -0800720
721
722 std::string itf3_name = "/PATH/TO/vhost_user1.sock";
723 std::string itf3_tag = "uuid-of-vhost_user1-interface";
724 interface itf3(itf3_name,
725 interface::type_t::VHOST,
726 interface::admin_state_t::UP,
727 itf3_tag);
728 HW::item<handle_t> hw_ifh3(4, rc_t::OK);
729
730 ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag));
731 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
732 TRY_CHECK_RC(OM::write(go, itf3));
733
734 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
735 ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name));
736 TRY_CHECK(OM::remove(go));
Neale Ranns812ed392017-10-16 04:20:13 -0700737}
738
739BOOST_AUTO_TEST_CASE(test_bvi) {
740 VppInit vi;
741 const std::string ernest = "ErnestHemmingway";
742 const std::string graham = "GrahamGreene";
743 rc_t rc = rc_t::OK;
744 l3_binding *l3;
745
746 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
747 rc_t::OK);
748 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
749 rc_t::OK);
750
751 /*
752 * Enrest creates a BVI with address 10.10.10.10/24
753 */
754 route::prefix_t pfx_10("10.10.10.10", 24);
755
756 const std::string bvi_name = "bvi1";
757 interface itf(bvi_name,
758 interface::type_t::BVI,
759 interface::admin_state_t::UP);
760 HW::item<handle_t> hw_ifh(4, rc_t::OK);
761 HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK);
762
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700763 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh, bvi_name));
764 ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name));
765 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700766 TRY_CHECK_RC(OM::write(ernest, itf));
767
768 l3 = new l3_binding(itf, pfx_10);
769 HW::item<bool> hw_l3_bind(true, rc_t::OK);
770 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700771 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700772 TRY_CHECK_RC(OM::write(ernest, *l3));
773
774 // change the MAC address on the BVI
775 interface itf_new_mac(bvi_name,
776 interface::type_t::BVI,
777 interface::admin_state_t::UP);
778 l2_address_t l2_addr({0,1,2,3,4,5});
779 HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK);
780 itf_new_mac.set(l2_addr);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700781 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700782 TRY_CHECK_RC(OM::write(ernest, itf_new_mac));
783
784 // create/write the interface to the OM again but with an unset MAC
785 // this should not generate a MAC address update
786 TRY_CHECK_RC(OM::write(ernest, itf));
787
788 // change the MAC address on the BVI - again
789 interface itf_new_mac2(bvi_name,
790 interface::type_t::BVI,
791 interface::admin_state_t::UP);
792 l2_address_t l2_addr2({0,1,2,3,4,6});
793 HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK);
794 itf_new_mac2.set(l2_addr2);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700795 ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700796 TRY_CHECK_RC(OM::write(ernest, itf_new_mac2));
797
798 delete l3;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700799 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
800 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
801 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700802 TRY_CHECK(OM::remove(ernest));
803
804 /*
805 * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain
806 */
807 route_domain rd(1);
808 HW::item<bool> hw_rd4_create(true, rc_t::OK);
809 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
810 HW::item<bool> hw_rd6_create(true, rc_t::OK);
811 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
812 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
813 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
814 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
815 HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700816 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
817 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700818 TRY_CHECK_RC(OM::write(graham, rd));
819
820 const std::string bvi2_name = "bvi2";
821 interface *itf2 = new interface(bvi2_name,
822 interface::type_t::BVI,
823 interface::admin_state_t::UP,
824 rd);
825 HW::item<handle_t> hw_ifh2(5, rc_t::OK);
826
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700827 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh2, bvi2_name));
828 ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name));
829 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
830 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
831 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700832
833 TRY_CHECK_RC(OM::write(graham, *itf2));
834
835 l3 = new l3_binding(*itf2, pfx_10);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700836 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -0700837 TRY_CHECK_RC(OM::write(graham, *l3));
838
839 delete l3;
840 delete itf2;
841
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700842 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10));
843 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
844 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2));
845 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
846 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh2));
847 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
848 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -0700849 TRY_CHECK(OM::remove(graham));
850}
851
Mohsin Kazmied76ee22018-03-02 12:31:37 +0100852BOOST_AUTO_TEST_CASE(test_bond) {
853 VppInit vi;
854 const std::string cb = "CarolBerg";
855 rc_t rc = rc_t::OK;
856
857 /*
858 * creates the interfaces
859 */
860 std::string itf1_name = "afpacket1";
861 interface itf1(itf1_name,
862 interface::type_t::AFPACKET,
863 interface::admin_state_t::UP);
864
865 HW::item<handle_t> hw_ifh(2, rc_t::OK);
866 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
867
868 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
869 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
870
871 TRY_CHECK_RC(OM::write(cb, itf1));
872
873 std::string itf2_name = "afpacket2";
874 interface itf2(itf2_name,
875 interface::type_t::AFPACKET,
876 interface::admin_state_t::UP);
877
878
879 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
880 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
881 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
882
883 TRY_CHECK_RC(OM::write(cb, itf2));
884
885 std::string bond_name = "bond";
886 bond_interface bond_itf(bond_name, interface::admin_state_t::UP,
887 bond_interface::mode_t::LACP);
888
889 HW::item<handle_t> hw_ifh3(6, rc_t::OK);
890 ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name,
891 bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO));
892 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
893
894 TRY_CHECK_RC(OM::write(cb, bond_itf));
895
896 bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE,
897 bond_member::rate_t::SLOW);
898 bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE,
899 bond_member::rate_t::SLOW);
900 bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2});
901
902 HW::item<bool> bond_hw_bind(true, rc_t::OK);
903 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1));
904 ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2));
905
906 TRY_CHECK_RC(OM::write(cb, *bgb));
907
908 delete bgb;
909 delete bm2;
910 delete bm1;
911
912 STRICT_ORDER_OFF();
913 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
914 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data()));
915 ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data()));
916 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
917 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
918 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
919 ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3));
920 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
921 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
922
923 TRY_CHECK(OM::remove(cb));
924}
925
Neale Ranns812ed392017-10-16 04:20:13 -0700926BOOST_AUTO_TEST_CASE(test_bridge) {
927 VppInit vi;
928 const std::string franz = "FranzKafka";
929 const std::string dante = "Dante";
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +0100930 const std::string jkr = "jkrowling";
Neale Ranns812ed392017-10-16 04:20:13 -0700931 rc_t rc = rc_t::OK;
932
933 /*
934 * Franz creates an interface, Bridge-domain, then binds the two
935 */
936
937 // interface create
938 std::string itf1_name = "afpacket1";
939 interface itf1(itf1_name,
940 interface::type_t::AFPACKET,
941 interface::admin_state_t::UP);
942
943 HW::item<handle_t> hw_ifh(3, rc_t::OK);
944 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
945 rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700946 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
947 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -0700948
949 TRY_CHECK_RC(OM::write(franz, itf1));
950
951 // bridge-domain create
952 bridge_domain bd1(33);
953
954 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -0700955 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
956 bridge_domain::learning_mode_t::ON,
957 bridge_domain::arp_term_mode_t::ON,
958 bridge_domain::flood_mode_t::ON,
959 bridge_domain::mac_age_mode_t::OFF));
Neale Ranns812ed392017-10-16 04:20:13 -0700960
961 TRY_CHECK_RC(OM::write(franz, bd1));
962
963 // L2-interface create and bind
964 // this needs to be delete'd before the flush below, since it too maintains
965 // references to the BD and Interface
966 l2_binding *l2itf = new l2_binding(itf1, bd1);
967 HW::item<bool> hw_l2_bind(true, rc_t::OK);
968
Mohsin Kazmi762d83c2018-09-27 15:00:32 +0200969 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
970 hw_ifh.data(),
971 hw_bd.data(),
972 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns812ed392017-10-16 04:20:13 -0700973 TRY_CHECK_RC(OM::write(franz, *l2itf));
974
975 /*
976 * Dante adds an interface to the same BD
977 */
978 std::string itf2_name = "afpacket2";
979 interface itf2(itf2_name,
980 interface::type_t::AFPACKET,
981 interface::admin_state_t::UP);
982
983 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700984 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
985 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -0700986 TRY_CHECK_RC(OM::write(dante, itf2));
987
988 // BD add is a no-op since it exists
989 TRY_CHECK_RC(OM::write(dante, bd1));
990
991 l2_binding *l2itf2 = new l2_binding(itf2, bd1);
Neale Ranns53322002019-02-22 02:48:25 -0800992 HW::item<l2_vtr::option_t> hw_set_vtr(l2_vtr::option_t::POP_1, rc_t::OK);
993 l2itf2->set(l2_vtr::option_t::POP_1, 68);
Neale Ranns812ed392017-10-16 04:20:13 -0700994
Mohsin Kazmi762d83c2018-09-27 15:00:32 +0200995 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
996 hw_ifh2.data(),
997 hw_bd.data(),
998 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns53322002019-02-22 02:48:25 -0800999 ADD_EXPECT(l2_vtr_cmds::set_cmd(hw_set_vtr, hw_ifh2.data(), 68));
Neale Ranns812ed392017-10-16 04:20:13 -07001000 TRY_CHECK_RC(OM::write(dante, *l2itf2));
1001
1002 // Add some static entries to the bridge-domain
1003 HW::item<bool> hw_be1(true, rc_t::OK);
1004 mac_address_t mac1({0,1,2,3,4,5});
1005 bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001006 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
1007 false));
Neale Ranns812ed392017-10-16 04:20:13 -07001008 TRY_CHECK_RC(OM::write(dante, *be1));
1009
1010 // Add some entries to the bridge-domain ARP termination table
1011 HW::item<bool> hw_bea1(true, rc_t::OK);
1012 boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10");
1013
Neale Rannsfd920602017-11-23 12:15:00 -08001014 bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001015 ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1));
Neale Ranns812ed392017-10-16 04:20:13 -07001016 TRY_CHECK_RC(OM::write(dante, *bea1));
1017
1018 // flush Franz's state
1019 delete l2itf;
1020 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1021 rc_t::OK);
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001022 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1023 hw_ifh.data(),
1024 hw_bd.data(),
1025 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001026 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1027 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001028 TRY_CHECK(OM::remove(franz));
1029
1030 // flush Dante's state - the order the interface and BD are deleted
1031 // is an uncontrollable artifact of the C++ object destruction.
1032 delete l2itf2;
1033 delete be1;
1034 delete bea1;
1035 STRICT_ORDER_OFF();
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001036 ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
1037 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001038 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1039 hw_ifh2.data(),
1040 hw_bd.data(),
1041 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001042
1043 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001044 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1045 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001046 TRY_CHECK(OM::remove(dante));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001047
1048 // test the BVI entry in l2fib
1049 bridge_domain bd2(99);
1050
1051 HW::item<uint32_t> hw_bd2(99, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -07001052 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2,
1053 bridge_domain::learning_mode_t::ON,
1054 bridge_domain::arp_term_mode_t::ON,
1055 bridge_domain::flood_mode_t::ON,
1056 bridge_domain::mac_age_mode_t::OFF));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001057
1058 TRY_CHECK_RC(OM::write(jkr, bd2));
1059
1060 std::string itf3_name = "bvi";
1061 interface itf3(itf3_name,
1062 interface::type_t::BVI,
1063 interface::admin_state_t::UP);
1064
1065 HW::item<handle_t> hw_ifh3(5, rc_t::OK);
1066 ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name));
1067 ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
1068 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
1069 TRY_CHECK_RC(OM::write(jkr, itf3));
1070
1071 l2_binding *l2itf3 = new l2_binding(itf3, bd2);
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001072 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1073 hw_ifh3.data(),
1074 hw_bd2.data(),
1075 l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001076 TRY_CHECK_RC(OM::write(jkr, *l2itf3));
1077
1078 HW::item<bool> hw_be2(true, rc_t::OK);
1079 mac_address_t mac2({0,1,2,3,4,5});
1080 bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
1081 ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
1082 TRY_CHECK_RC(OM::write(jkr, *be2));
1083
1084 delete l2itf3;
1085 delete be2;
1086 STRICT_ORDER_OFF();
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001087 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1088 hw_ifh3.data(),
1089 hw_bd2.data(),
1090 l2_binding::l2_port_type_t::L2_PORT_TYPE_BVI));
Mohsin Kazmie2e9ce52017-12-01 15:12:57 +01001091 ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
1092 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
1093 ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3));
1094 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
1095 TRY_CHECK(OM::remove(jkr));
Neale Ranns812ed392017-10-16 04:20:13 -07001096}
1097
Mohsin Kazmi6b1cdd32018-06-29 17:04:23 +02001098BOOST_AUTO_TEST_CASE(test_l2_xconnect) {
1099 VppInit vi;
1100 const std::string nicholas = "NicholasAbercrombie";
1101 rc_t rc = rc_t::OK;
1102
1103 /*
1104 * Interface 1
1105 */
1106 std::string itf1_name = "host1";
1107 interface itf1(itf1_name,
1108 interface::type_t::AFPACKET,
1109 interface::admin_state_t::UP);
1110 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1111 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1112 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1113 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1114 TRY_CHECK_RC(OM::write(nicholas, itf1));
1115
1116 /*
1117 * Interface 2
1118 */
1119 std::string itf2_name = "host2";
1120 interface itf2(itf2_name,
1121 interface::type_t::AFPACKET,
1122 interface::admin_state_t::UP);
1123
1124 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1125 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1126 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1127 TRY_CHECK_RC(OM::write(nicholas, itf2));
1128
1129 l2_xconnect *l2_xconn = new l2_xconnect(itf1, itf2);
1130 HW::item<bool> xconnect_east(true, rc_t::OK);
1131 HW::item<bool> xconnect_west(true, rc_t::OK);
1132 HW::item<bool> xconnect_east_unbind(false, rc_t::OK);
1133 HW::item<bool> xconnect_west_unbind(false, rc_t::OK);
1134 ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_east, hw_ifh.data(), hw_ifh2.data()));
1135 ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_west, hw_ifh2.data(), hw_ifh.data()));
1136 TRY_CHECK_RC(OM::write(nicholas, *l2_xconn));
1137
1138 delete l2_xconn;
1139
1140 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1141 STRICT_ORDER_OFF();
1142 ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_east_unbind, hw_ifh.data(), hw_ifh2.data()));
1143 ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_west_unbind, hw_ifh2.data(), hw_ifh.data()));
1144 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1145 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1146 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1147 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1148
1149 TRY_CHECK(OM::remove(nicholas));
1150}
1151
Neale Ranns812ed392017-10-16 04:20:13 -07001152BOOST_AUTO_TEST_CASE(test_vxlan) {
1153 VppInit vi;
1154 const std::string franz = "FranzKafka";
1155 rc_t rc = rc_t::OK;
1156
1157 /*
1158 * Franz creates an interface, Bridge-domain, then binds the two
1159 */
1160
1161 // VXLAN create
1162 vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"),
Neale Ranns25b04942018-04-04 09:34:50 -07001163 boost::asio::ip::address::from_string("10.10.10.11"),
1164 322);
Neale Ranns812ed392017-10-16 04:20:13 -07001165
1166 vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);
1167
1168 HW::item<handle_t> hw_vxt(3, rc_t::OK);
Neale Rannscf3ecb12018-12-11 08:40:20 -08001169 ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep,
1170 handle_t::INVALID));
Neale Ranns812ed392017-10-16 04:20:13 -07001171
1172 TRY_CHECK_RC(OM::write(franz, vxt));
1173
1174 // bridge-domain create
Neale Ranns25b04942018-04-04 09:34:50 -07001175 bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
1176 bridge_domain::arp_term_mode_t::OFF,
1177 bridge_domain::flood_mode_t::OFF,
1178 bridge_domain::mac_age_mode_t::ON);
Neale Ranns812ed392017-10-16 04:20:13 -07001179
1180 HW::item<uint32_t> hw_bd(33, rc_t::OK);
Neale Ranns25b04942018-04-04 09:34:50 -07001181 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
1182 bridge_domain::learning_mode_t::OFF,
1183 bridge_domain::arp_term_mode_t::OFF,
1184 bridge_domain::flood_mode_t::OFF,
1185 bridge_domain::mac_age_mode_t::ON));
Neale Ranns812ed392017-10-16 04:20:13 -07001186
1187 TRY_CHECK_RC(OM::write(franz, bd1));
1188
1189 // L2-interface create and bind
1190 // this needs to be delete'd before the flush below, since it too maintains
1191 // references to the BD and Interface
1192 l2_binding *l2itf = new l2_binding(vxt, bd1);
1193 HW::item<bool> hw_l2_bind(true, rc_t::OK);
1194
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001195 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind,
1196 hw_vxt.data(),
1197 hw_bd.data(),
1198 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns812ed392017-10-16 04:20:13 -07001199 TRY_CHECK_RC(OM::write(franz, *l2itf));
1200
1201 // flush Franz's state
1202 delete l2itf;
1203 HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP);
1204 STRICT_ORDER_OFF();
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02001205 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind,
1206 hw_vxt.data(),
1207 hw_bd.data(),
1208 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001209 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
1210 ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep));
Neale Ranns812ed392017-10-16 04:20:13 -07001211 TRY_CHECK(OM::remove(franz));
1212}
1213
1214BOOST_AUTO_TEST_CASE(test_vlan) {
1215 VppInit vi;
1216 const std::string noam = "NoamChomsky";
1217 rc_t rc = rc_t::OK;
1218
1219 std::string itf1_name = "host1";
1220 interface itf1(itf1_name,
1221 interface::type_t::AFPACKET,
1222 interface::admin_state_t::UP);
1223
1224 HW::item<handle_t> hw_ifh(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001225 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001226
1227 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001228 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001229
1230 TRY_CHECK_RC(OM::write(noam, itf1));
1231
1232 sub_interface *vl33 = new sub_interface(itf1,
1233 interface::admin_state_t::UP,
1234 33);
1235
1236 HW::item<handle_t> hw_vl33(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001237 ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33));
1238 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33));
Neale Ranns812ed392017-10-16 04:20:13 -07001239
1240 TRY_CHECK_RC(OM::write(noam, *vl33));
1241
1242 delete vl33;
1243 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1244 HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001245 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33));
1246 ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down));
1247 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1248 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001249
1250 TRY_CHECK(OM::remove(noam));
1251}
1252
1253BOOST_AUTO_TEST_CASE(test_acl) {
1254 VppInit vi;
1255 const std::string fyodor = "FyodorDostoyevsky";
1256 const std::string leo = "LeoTolstoy";
1257 rc_t rc = rc_t::OK;
1258
1259 /*
1260 * Fyodor adds an ACL in the input direction
1261 */
1262 std::string itf1_name = "host1";
1263 interface itf1(itf1_name,
1264 interface::type_t::AFPACKET,
1265 interface::admin_state_t::UP);
1266 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1267 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001268 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1269 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001270 TRY_CHECK_RC(OM::write(fyodor, itf1));
1271
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001272 ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT);
1273 ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT);
1274 ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT);
1275 ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3};
1276 ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e);
1277 HW::item<bool> ae_binding(true, rc_t::OK);
1278 ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e));
1279 TRY_CHECK_RC(OM::write(fyodor, *a_e));
1280
Neale Ranns812ed392017-10-16 04:20:13 -07001281 route::prefix_t src("10.10.10.10", 32);
1282 ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO);
1283 ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO);
1284
1285 std::string acl_name = "acl1";
1286 ACL::l3_list acl1(acl_name);
1287 acl1.insert(r2);
1288 acl1.insert(r1);
1289 ACL::l3_list::rules_t rules = {r1, r2};
1290
1291 HW::item<handle_t> hw_acl(2, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001292 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001293 TRY_CHECK_RC(OM::write(fyodor, acl1));
1294
Mohsin Kazmid91d1402018-02-14 15:47:19 +01001295 ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO);
1296 ACL::l3_list acl2(acl_name);
1297 acl2.insert(r3);
1298 ACL::l3_list::rules_t rules2 = {r3};
1299 ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2));
1300 TRY_CHECK_RC(OM::write(fyodor, acl2));
1301
Neale Ranns812ed392017-10-16 04:20:13 -07001302 ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1);
1303 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001304 ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT,
1305 hw_ifh.data(), hw_acl.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001306 TRY_CHECK_RC(OM::write(fyodor, *l3b));
1307
1308 /**
1309 * Leo adds an L2 ACL in the output direction
1310 */
1311 TRY_CHECK_RC(OM::write(leo, itf1));
1312
1313 std::string l2_acl_name = "l2_acl1";
1314 mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4});
1315 mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0});
1316 ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask);
1317 ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {});
1318
1319 ACL::l2_list l2_acl(l2_acl_name);
1320 l2_acl.insert(l2_r2);
1321 l2_acl.insert(l2_r1);
1322
1323 ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2};
1324
1325 HW::item<handle_t> l2_hw_acl(3, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001326 ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules));
Neale Ranns812ed392017-10-16 04:20:13 -07001327 TRY_CHECK_RC(OM::write(leo, l2_acl));
1328
1329 ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl);
1330 HW::item<bool> l2_hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001331 ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001332 hw_ifh.data(), l2_hw_acl.data()));
1333 TRY_CHECK_RC(OM::write(leo, *l2b));
1334
1335 delete l2b;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001336 ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT,
1337 hw_ifh.data(), l2_hw_acl.data()));
1338 ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl));
Neale Ranns812ed392017-10-16 04:20:13 -07001339 TRY_CHECK(OM::remove(leo));
1340
1341 delete l3b;
Mohsin Kazmi49c7f0c2018-02-07 20:20:36 +01001342 delete a_e;
Neale Ranns812ed392017-10-16 04:20:13 -07001343 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1344 rc_t::OK);
1345 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001346 ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT,
Neale Ranns812ed392017-10-16 04:20:13 -07001347 hw_ifh.data(), hw_acl.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001348 ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl));
Mohsin Kazmi04def742018-03-07 19:53:51 +01001349 ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data()));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001350 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1351 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001352
1353 TRY_CHECK(OM::remove(fyodor));
1354}
1355
Mohsin Kazmi12fe8782018-10-30 19:24:34 +01001356BOOST_AUTO_TEST_CASE(test_igmp) {
1357 VppInit vi;
1358 const std::string Isaiah = "IsaiahBerlin";
1359 rc_t rc = rc_t::OK;
1360
Ole Troan003d5da2018-12-18 12:23:13 +01001361 boost::asio::ip::address_v4 gaddr = boost::asio::ip::address_v4::from_string("232.0.0.1");
1362 boost::asio::ip::address_v4 saddr1 = boost::asio::ip::address_v4::from_string("192.168.0.20");
1363 boost::asio::ip::address_v4 saddr2 = boost::asio::ip::address_v4::from_string("192.168.0.30");
Mohsin Kazmi12fe8782018-10-30 19:24:34 +01001364
1365 std::string itf3_name = "host3";
1366 interface itf3(itf3_name,
1367 interface::type_t::AFPACKET,
1368 interface::admin_state_t::UP);
1369 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1370 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1371 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1372 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1373 TRY_CHECK_RC(OM::write(Isaiah, itf3));
1374
1375 igmp_binding *ib = new igmp_binding(itf3);
1376 HW::item<bool> hw_binding(true, rc_t::OK);
1377 ADD_EXPECT(igmp_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
1378 TRY_CHECK_RC(OM::write(Isaiah, *ib));
1379
1380 igmp_listen::src_addrs_t saddrs = {saddr1, saddr2};
1381
1382 igmp_listen *il = new igmp_listen(*ib, gaddr, saddrs);
1383 HW::item<bool> hw_as_listen(true, rc_t::OK);
1384 ADD_EXPECT(igmp_listen_cmds::listen_cmd(hw_as_listen, hw_ifh.data(), gaddr, saddrs));
1385 TRY_CHECK_RC(OM::write(Isaiah, *il));
1386
1387 delete il;
1388 delete ib;
1389
1390 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1391 rc_t::OK);
1392 STRICT_ORDER_OFF();
1393 ADD_EXPECT(igmp_listen_cmds::unlisten_cmd(hw_as_listen, hw_ifh.data(), gaddr));
1394 ADD_EXPECT(igmp_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1395 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1396 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1397
1398 TRY_CHECK(OM::remove(Isaiah));
1399}
1400
Neale Ranns812ed392017-10-16 04:20:13 -07001401BOOST_AUTO_TEST_CASE(test_arp_proxy) {
1402 VppInit vi;
1403 const std::string kurt = "KurtVonnegut";
1404 rc_t rc = rc_t::OK;
1405
1406 asio::ip::address_v4 low = asio::ip::address_v4::from_string("10.0.0.0");
1407 asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255");
1408
1409 arp_proxy_config ap(low, high);
1410 HW::item<bool> hw_ap_cfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001411 ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001412 TRY_CHECK_RC(OM::write(kurt, ap));
1413
1414 std::string itf3_name = "host3";
1415 interface itf3(itf3_name,
1416 interface::type_t::AFPACKET,
1417 interface::admin_state_t::UP);
1418 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1419 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001420 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
1421 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001422 TRY_CHECK_RC(OM::write(kurt, itf3));
1423
Neale Ranns0053de62018-05-22 08:40:52 -07001424 arp_proxy_binding *apb = new arp_proxy_binding(itf3);
Neale Ranns812ed392017-10-16 04:20:13 -07001425 HW::item<bool> hw_binding(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001426 ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001427 TRY_CHECK_RC(OM::write(kurt, *apb));
1428
1429 delete apb;
1430
1431 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
1432 rc_t::OK);
1433 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001434 ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
1435 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1436 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
1437 ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high));
Neale Ranns812ed392017-10-16 04:20:13 -07001438
1439 TRY_CHECK(OM::remove(kurt));
1440}
1441
Mohsin Kazmie23edac2018-09-25 18:26:52 +02001442BOOST_AUTO_TEST_CASE(test_ip_punt_redirect) {
1443 VppInit vi;
1444 const std::string eliot = "EliotReed";
1445 rc_t rc = rc_t::OK;
1446
1447 /*
1448 * Interface 1 is the tx interface
1449 */
1450 std::string itf1_name = "tx-itf";
1451 interface itf1(itf1_name,
1452 interface::type_t::AFPACKET,
1453 interface::admin_state_t::UP);
1454 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1455 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1456 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1457 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
1458 TRY_CHECK_RC(OM::write(eliot, itf1));
1459
1460 boost::asio::ip::address addr = boost::asio::ip::address::from_string("192.168.0.20");
1461
1462 /*
1463 * Interface 2 is the rx interface
1464 */
1465 std::string itf2_name = "rx-itf";
1466 interface itf2(itf2_name,
1467 interface::type_t::AFPACKET,
1468 interface::admin_state_t::UP);
1469
1470 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1471 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1472 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
1473 TRY_CHECK_RC(OM::write(eliot, itf2));
1474
1475 ip_punt_redirect *ip_punt = new ip_punt_redirect(itf2, itf1, addr);
1476 HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1477 HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
1478 ADD_EXPECT(ip_punt_redirect_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data(), addr));
1479 TRY_CHECK_RC(OM::write(eliot, *ip_punt));
1480
1481 delete ip_punt;
1482
1483 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1484 STRICT_ORDER_OFF();
1485 ADD_EXPECT(ip_punt_redirect_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data(), addr));
1486 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1487 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1488 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1489 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1490
1491 TRY_CHECK(OM::remove(eliot));
1492}
1493
Neale Ranns812ed392017-10-16 04:20:13 -07001494BOOST_AUTO_TEST_CASE(test_ip_unnumbered) {
1495 VppInit vi;
1496 const std::string eric = "EricAmbler";
1497 rc_t rc = rc_t::OK;
1498
1499 /*
1500 * Interface 1 has the L3 address
1501 */
1502 std::string itf1_name = "host1";
1503 interface itf1(itf1_name,
1504 interface::type_t::AFPACKET,
1505 interface::admin_state_t::UP);
1506 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1507 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001508 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1509 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001510 TRY_CHECK_RC(OM::write(eric, itf1));
1511
1512 route::prefix_t pfx_10("10.10.10.10", 24);
1513 l3_binding *l3 = new l3_binding(itf1, pfx_10);
1514 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1515 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001516 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001517 TRY_CHECK_RC(OM::write(eric, *l3));
1518
1519 /*
1520 * Interface 2 is unnumbered
1521 */
1522 std::string itf2_name = "host2";
1523 interface itf2(itf2_name,
1524 interface::type_t::AFPACKET,
1525 interface::admin_state_t::UP);
1526
1527 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001528 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1529 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001530 TRY_CHECK_RC(OM::write(eric, itf2));
1531
1532 ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1);
1533 HW::item<bool> hw_ip_cfg(true, rc_t::OK);
1534 HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001535 ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data()));
Neale Ranns812ed392017-10-16 04:20:13 -07001536 TRY_CHECK_RC(OM::write(eric, *ipun));
1537
1538 delete l3;
1539 delete ipun;
1540
1541 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1542 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001543 ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data()));
1544 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1545 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
1546 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1547 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1548 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001549
1550 TRY_CHECK(OM::remove(eric));
1551}
1552
1553BOOST_AUTO_TEST_CASE(test_ip6nd) {
1554 VppInit vi;
1555 const std::string paulo = "PauloCoelho";
1556 rc_t rc = rc_t::OK;
1557
1558 /*
1559 * ra config
1560 */
1561 std::string itf_name = "host_ip6nd";
1562 interface itf(itf_name,
1563 interface::type_t::AFPACKET,
1564 interface::admin_state_t::UP);
1565 HW::item<handle_t> hw_ifh(3, rc_t::OK);
1566 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001567 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
1568 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001569 TRY_CHECK_RC(OM::write(paulo, itf));
1570
1571 route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128);
1572 l3_binding *l3 = new l3_binding(itf, pfx_10);
1573 HW::item<bool> hw_l3_bind(true, rc_t::OK);
1574 HW::item<bool> hw_l3_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001575 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001576 TRY_CHECK_RC(OM::write(paulo, *l3));
1577
1578 ra_config ra(0, 1, 0, 4);
1579 ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra);
1580 HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK);
1581 HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK);
1582 ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra));
1583 TRY_CHECK_RC(OM::write(paulo, *ip6ra));
1584
1585 /*
1586 * ra prefix
1587 */
1588 ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800);
1589 ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx);
1590 HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK);
1591 HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK);
1592 ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx));
1593 TRY_CHECK_RC(OM::write(paulo, *ip6pfx));
1594
1595 delete ip6pfx;
1596
1597 ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx));
1598
1599 delete ip6ra;
1600 delete l3;
1601
1602 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1603
1604 STRICT_ORDER_OFF();
1605 ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra));
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001606 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
1607 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1608 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001609
1610 TRY_CHECK(OM::remove(paulo));
1611}
1612
1613BOOST_AUTO_TEST_CASE(test_interface_span) {
1614 VppInit vi;
1615 const std::string elif = "ElifShafak";
1616 rc_t rc = rc_t::OK;
1617
1618 /*
1619 * Interface 1 to be mirrored
1620 */
1621 std::string itf1_name = "port-from";
1622 interface itf1(itf1_name,
1623 interface::type_t::AFPACKET,
1624 interface::admin_state_t::UP);
1625 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1626 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001627 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1628 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001629 TRY_CHECK_RC(OM::write(elif, itf1));
1630
1631 /*
1632 * Interface 2 where traffic is mirrored
1633 */
1634 std::string itf2_name = "port-to";
1635 interface itf2(itf2_name,
1636 interface::type_t::AFPACKET,
1637 interface::admin_state_t::UP);
1638
1639 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1640 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1641
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001642 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1643 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001644 TRY_CHECK_RC(OM::write(elif, itf2));
1645
1646 interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED);
1647 HW::item<bool> hw_is_cfg(true, rc_t::OK);
1648 HW::item<bool> hw_is_uncfg(true, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001649 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 -07001650 TRY_CHECK_RC(OM::write(elif, *itf_span));
1651
1652 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1653 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1654
1655 delete itf_span;
1656 STRICT_ORDER_OFF();
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001657 ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data()));
1658 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1659 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1660 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1661 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001662
1663 TRY_CHECK(OM::remove(elif));
1664}
1665
1666BOOST_AUTO_TEST_CASE(test_routing) {
1667 VppInit vi;
1668 const std::string ian = "IanFleming";
1669 rc_t rc = rc_t::OK;
1670
1671 /*
1672 * non-default route domain
1673 */
1674 route_domain rd4(1);
1675 HW::item<bool> hw_rd4_create(true, rc_t::OK);
1676 HW::item<bool> hw_rd4_delete(false, rc_t::OK);
1677 HW::item<bool> hw_rd6_create(true, rc_t::OK);
1678 HW::item<bool> hw_rd6_delete(false, rc_t::OK);
1679 HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
1680 HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
1681 HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
1682 HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001683 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
1684 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001685 TRY_CHECK_RC(OM::write(ian, rd4));
1686
1687 /*
1688 * a couple of interfaces
1689 */
1690 std::string itf1_name = "af1";
1691 interface itf1(itf1_name,
1692 interface::type_t::AFPACKET,
1693 interface::admin_state_t::UP);
1694 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1695 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1696 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001697 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
1698 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001699 TRY_CHECK_RC(OM::write(ian, itf1));
1700
1701 std::string itf2_name = "af2";
1702 interface *itf2 = new interface(itf2_name,
1703 interface::type_t::AFPACKET,
1704 interface::admin_state_t::UP,
1705 rd4);
1706
1707 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1708 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1709 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001710 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
1711 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
1712 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
1713 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001714 TRY_CHECK_RC(OM::write(ian, *itf2));
1715
1716 /*
1717 * prefix on each interface
1718 */
1719 route::prefix_t pfx_10("10.10.10.10", 24);
1720 l3_binding *l3_10 = new l3_binding(itf1, pfx_10);
1721 HW::item<bool> hw_l3_10_bind(true, rc_t::OK);
1722 HW::item<bool> hw_l3_10_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001723 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001724 TRY_CHECK_RC(OM::write(ian, *l3_10));
1725 route::prefix_t pfx_11("11.11.11.11", 24);
1726 l3_binding *l3_11 = new l3_binding(*itf2, pfx_11);
1727 HW::item<bool> hw_l3_11_bind(true, rc_t::OK);
1728 HW::item<bool> hw_l3_11_unbind(false, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001729 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11));
Neale Ranns812ed392017-10-16 04:20:13 -07001730 TRY_CHECK_RC(OM::write(ian, *l3_11));
1731
1732 /*
1733 * A route via interface 1 in the default table
1734 */
1735 route::prefix_t pfx_5("5.5.5.5", 32);
Neale Ranns6ad72312019-01-10 08:56:38 -08001736 boost::asio::ip::address nh_9 = boost::asio::ip::address::from_string("10.10.10.9");
1737 route::path *path_9 = new route::path(nh_9, itf1);
Neale Ranns812ed392017-10-16 04:20:13 -07001738 boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11");
1739 route::path *path_10 = new route::path(nh_10, itf1);
1740 route::ip_route *route_5 = new route::ip_route(pfx_5);
1741 route_5->add(*path_10);
Neale Ranns6ad72312019-01-10 08:56:38 -08001742 route_5->add(*path_9);
Neale Ranns812ed392017-10-16 04:20:13 -07001743 HW::item<bool> hw_route_5(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001744 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, *path_9));
1745 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, *path_10));
Neale Ranns812ed392017-10-16 04:20:13 -07001746 TRY_CHECK_RC(OM::write(ian, *route_5));
1747
Neale Ranns6ad72312019-01-10 08:56:38 -08001748 route_5->remove(*path_9);
1749 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5, *path_9));
1750 TRY_CHECK_RC(OM::write(ian, *route_5));
1751
1752 delete path_9;
1753
Neale Ranns812ed392017-10-16 04:20:13 -07001754 /*
1755 * A route via interface 2 in the non-default table
1756 */
1757 boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10");
1758 route::path *path_11 = new route::path(nh_11, *itf2);
Neale Ranns6ad72312019-01-10 08:56:38 -08001759 boost::asio::ip::address nh_12 = boost::asio::ip::address::from_string("11.11.11.12");
1760 route::path *path_12 = new route::path(nh_12, *itf2);
Neale Ranns812ed392017-10-16 04:20:13 -07001761 route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5);
1762 route_5_2->add(*path_11);
1763 HW::item<bool> hw_route_5_2(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001764 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, *path_11));
1765 TRY_CHECK_RC(OM::write(ian, *route_5_2));
1766
1767 route_5_2->add(*path_12);
1768 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, *path_12));
Neale Ranns812ed392017-10-16 04:20:13 -07001769 TRY_CHECK_RC(OM::write(ian, *route_5_2));
1770
1771 /*
1772 * An ARP entry for the neighbour on itf1
1773 */
1774 HW::item<bool> hw_neighbour(true, rc_t::OK);
1775 mac_address_t mac_n({0,1,2,4,5,6});
Neale Rannsfd920602017-11-23 12:15:00 -08001776 neighbour *ne = new neighbour(itf1, nh_10, mac_n);
Neale Ranns6fef74a2019-02-12 06:18:30 -08001777 ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(),
1778 mac_n, nh_10,
1779 neighbour::flags_t::STATIC));
Neale Ranns812ed392017-10-16 04:20:13 -07001780 TRY_CHECK_RC(OM::write(ian, *ne));
1781
1782 /*
1783 * A DVR route
1784 */
1785 route::prefix_t pfx_6("6.6.6.6", 32);
1786 route::path *path_l2 = new route::path(*itf2, nh_proto_t::ETHERNET);
1787 route::ip_route *route_dvr = new route::ip_route(pfx_6);
1788 route_dvr->add(*path_l2);
1789 HW::item<bool> hw_route_dvr(true, rc_t::OK);
Neale Ranns6ad72312019-01-10 08:56:38 -08001790 ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, *path_l2));
Neale Ranns812ed392017-10-16 04:20:13 -07001791 TRY_CHECK_RC(OM::write(ian, *route_dvr));
1792
Neale Ranns7c03ed42018-12-27 03:21:28 -08001793 /*
1794 * a multicast route
1795 */
1796 route::mprefix_t mpfx_4(boost::asio::ip::address::from_string("232.1.1.1"), 32);
1797 route::ip_mroute *mroute_4 = new route::ip_mroute(mpfx_4);
1798
1799 route::path *mp1 = new route::path(itf1, nh_proto_t::IPV4);
1800 route::path *mp2 = new route::path(*itf2, nh_proto_t::IPV4);
1801 mroute_4->add(*mp1, route::itf_flags_t::FORWARD);
1802 mroute_4->add(*mp1, route::itf_flags_t::ACCEPT);
1803 mroute_4->add(*mp2, route::itf_flags_t::FORWARD);
1804 HW::item<bool> hw_mroute_4(true, rc_t::OK);
1805 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1806 *mp1, route::itf_flags_t::FORWARD));
1807 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1808 *mp2, route::itf_flags_t::FORWARD));
1809 ADD_EXPECT(route::ip_mroute_cmds::update_cmd(hw_mroute_4, 0, mpfx_4,
1810 *mp1, route::itf_flags_t::ACCEPT));
1811 TRY_CHECK_RC(OM::write(ian, *mroute_4));
1812
Neale Ranns812ed392017-10-16 04:20:13 -07001813 STRICT_ORDER_OFF();
1814 // delete the stack objects that hold references to others
1815 // so the OM::remove is the call that removes the last reference
1816 delete l3_11;
1817 delete l3_10;
1818 delete itf2;
1819 delete route_5;
Neale Ranns812ed392017-10-16 04:20:13 -07001820 delete route_5_2;
Neale Ranns812ed392017-10-16 04:20:13 -07001821 delete route_dvr;
Neale Ranns812ed392017-10-16 04:20:13 -07001822 delete ne;
Neale Ranns7c03ed42018-12-27 03:21:28 -08001823 delete mroute_4;
1824
1825 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1826 *mp1, route::itf_flags_t::FORWARD));
1827 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1828 *mp2, route::itf_flags_t::FORWARD));
1829 ADD_EXPECT(route::ip_mroute_cmds::delete_cmd(hw_mroute_4, 0, mpfx_4,
1830 *mp1, route::itf_flags_t::ACCEPT));
1831
1832 delete mp1;
1833 delete mp2;
1834
Neale Ranns6fef74a2019-02-12 06:18:30 -08001835 ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(),
1836 mac_n, nh_10,
1837 neighbour::flags_t::STATIC));
Neale Ranns6ad72312019-01-10 08:56:38 -08001838 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6, *path_l2));
1839 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_11));
1840 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5, *path_12));
1841 ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5, *path_10));
1842
1843 delete path_10;
1844 delete path_11;
1845 delete path_12;
1846 delete path_l2;
1847
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001848 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10));
1849 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11));
1850 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1851 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
1852 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
1853 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2));
1854 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1855 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
1856 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
1857 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
Neale Ranns812ed392017-10-16 04:20:13 -07001858
1859 TRY_CHECK(OM::remove(ian));
1860}
1861
1862BOOST_AUTO_TEST_CASE(test_nat) {
1863 VppInit vi;
1864 const std::string gs = "GeorgeSimenon";
1865 rc_t rc = rc_t::OK;
1866
1867 /*
1868 * Inside Interface
1869 */
1870 std::string itf_in_name = "inside";
1871 interface itf_in(itf_in_name,
1872 interface::type_t::AFPACKET,
1873 interface::admin_state_t::UP);
1874 HW::item<handle_t> hw_ifh(2, rc_t::OK);
1875 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1876 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001877 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name));
1878 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
Neale Ranns812ed392017-10-16 04:20:13 -07001879 TRY_CHECK_RC(OM::write(gs, itf_in));
1880
1881 /*
1882 * outside
1883 */
1884 std::string itf_out_name = "port-to";
1885 interface itf_out(itf_out_name,
1886 interface::type_t::AFPACKET,
1887 interface::admin_state_t::UP);
1888
1889 HW::item<handle_t> hw_ifh2(4, rc_t::OK);
1890 HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
1891 HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
1892
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001893 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name));
1894 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
Neale Ranns812ed392017-10-16 04:20:13 -07001895 TRY_CHECK_RC(OM::write(gs, itf_out));
1896
1897 /*
1898 * A NAT static mapping
1899 */
1900 boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1");
1901 boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1");
1902
1903 nat_static ns(in_addr, out_addr);
1904 HW::item<bool> hw_ns(true, rc_t::OK);
1905
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001906 ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
Neale Ranns812ed392017-10-16 04:20:13 -07001907 TRY_CHECK_RC(OM::write(gs, ns));
1908
1909 /*
1910 * bind nat inside and out
1911 */
1912 nat_binding *nb_in = new nat_binding(itf_in,
1913 direction_t::INPUT,
1914 l3_proto_t::IPV4,
1915 nat_binding::zone_t::INSIDE);
1916 HW::item<bool> hw_nb_in(true, rc_t::OK);
1917
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001918 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in,
1919 hw_ifh.data().value(),
1920 nat_binding::zone_t::INSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001921 TRY_CHECK_RC(OM::write(gs, *nb_in));
1922
1923 nat_binding *nb_out = new nat_binding(itf_out,
1924 direction_t::INPUT,
1925 l3_proto_t::IPV4,
1926 nat_binding::zone_t::OUTSIDE);
1927 HW::item<bool> hw_nb_out(true, rc_t::OK);
1928
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001929 ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out,
1930 hw_ifh2.data().value(),
1931 nat_binding::zone_t::OUTSIDE));
Neale Ranns812ed392017-10-16 04:20:13 -07001932 TRY_CHECK_RC(OM::write(gs, *nb_out));
1933
1934
1935 STRICT_ORDER_OFF();
1936 delete nb_in;
1937 delete nb_out;
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001938 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in,
1939 hw_ifh.data().value(),
1940 nat_binding::zone_t::INSIDE));
1941 ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out,
1942 hw_ifh2.data().value(),
1943 nat_binding::zone_t::OUTSIDE));
1944 ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
1945 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
1946 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name));
1947 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
1948 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name));
Neale Ranns812ed392017-10-16 04:20:13 -07001949
1950 TRY_CHECK(OM::remove(gs));
1951}
1952
1953BOOST_AUTO_TEST_CASE(test_interface_events) {
1954 VppInit vi;
1955 MockListener ml;
1956
1957 HW::item<bool> hw_want(true, rc_t::OK);
1958
Neale Ranns9ef1c0a2017-11-03 04:39:05 -07001959 ADD_EXPECT(interface_cmds::events_cmd(ml));
1960 cmd* itf = new interface_cmds::events_cmd(ml);
Neale Ranns812ed392017-10-16 04:20:13 -07001961
1962 HW::enqueue(itf);
1963 HW::write();
Neale Ranns812ed392017-10-16 04:20:13 -07001964}
1965
Neale Ranns352ea0c2017-11-14 11:04:28 -08001966BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
1967 VppInit vi;
1968 const std::string rene = "ReneGoscinny";
1969 rc_t rc = rc_t::OK;
1970
1971 /*
1972 * Create an interface with two IP addresses
1973 */
1974 std::string itf1_name = "host1";
1975 interface itf1(itf1_name,
1976 interface::type_t::AFPACKET,
1977 interface::admin_state_t::UP);
1978 HW::item<handle_t> hw_ifh1(2, rc_t::OK);
1979 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
1980 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
1981 ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name));
1982 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1));
1983 TRY_CHECK_RC(OM::write(rene, itf1));
1984
1985 route::prefix_t pfx_10("10.10.10.10", 24);
1986 l3_binding *l3_1 = new l3_binding(itf1, pfx_10);
1987 HW::item<bool> hw_l3_bind1(true, rc_t::OK);
1988 HW::item<bool> hw_l3_unbind1(false, rc_t::OK);
1989 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
1990 TRY_CHECK_RC(OM::write(rene, *l3_1));
1991
1992 route::prefix_t pfx_11("10.10.11.11", 24);
1993 l3_binding *l3_2 = new l3_binding(itf1, pfx_11);
1994 HW::item<bool> hw_l3_bind2(true, rc_t::OK);
1995 HW::item<bool> hw_l3_unbind2(false, rc_t::OK);
1996 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
1997 TRY_CHECK_RC(OM::write(rene, *l3_2));
1998
1999 route_domain rd(1);
2000 HW::item<bool> hw_rd_create(true, rc_t::OK);
2001 HW::item<bool> hw_rd_delete(false, rc_t::OK);
2002 HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK);
2003 HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK);
2004 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1));
2005 ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1));
2006 TRY_CHECK_RC(OM::write(rene, rd));
2007
2008 /*
2009 * update the interface to change to a new route-domain
2010 * expect that the l3-bindings are removed and readded.
2011 */
2012 interface *itf2 = new interface(itf1_name,
2013 interface::type_t::AFPACKET,
2014 interface::admin_state_t::UP,
2015 rd);
2016 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2017 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2018 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1));
2019 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1));
2020 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2021 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2022 TRY_CHECK_RC(OM::write(rene, *itf2));
2023
2024 /*
2025 * mve the interface back to the default route-domain
2026 */
2027 interface itf3(itf1_name,
2028 interface::type_t::AFPACKET,
2029 interface::admin_state_t::UP);
2030 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2031 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2032 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1));
2033 ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1));
2034 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
2035 ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
2036 TRY_CHECK_RC(OM::write(rene, itf3));
2037
2038 delete l3_1;
2039 delete l3_2;
2040 delete itf2;
2041
2042 STRICT_ORDER_OFF();
2043 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
2044 ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
2045 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1));
2046 ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name));
2047 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1));
2048 ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1));
2049
2050 TRY_CHECK(OM::remove(rene));
2051}
2052
Neale Rannsd3464b52017-12-07 08:48:02 -08002053BOOST_AUTO_TEST_CASE(test_prefixes) {
2054 route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);
2055
2056 BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));
2057
2058 route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);
2059
2060 BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
2061 BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));
2062
2063 route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
2064 BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
2065 BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));
2066
2067 route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);
2068
2069 BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));
2070
2071 route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);
2072
2073 BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
2074 BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2075 BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));
2076
2077 route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);
2078
2079 BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
2080 BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
2081 BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));
2082
2083 route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);
2084
2085 BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
2086 BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2087 BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));
2088
2089}
2090
Neale Ranns208c29a2018-04-11 08:08:30 -07002091BOOST_AUTO_TEST_CASE(test_pipes) {
2092 VppInit vi;
2093 const std::string gk = "GKChesterton";
2094
2095 const std::string pipe_name_1 = "pipe1";
2096 VOM::pipe pipe1(1, interface::admin_state_t::UP);
2097 HW::item<handle_t> hw_hdl(4, rc_t::OK);
2098 HW::item<pipe::handle_pair_t> hw_hdl_pair(std::make_pair(5,6), rc_t::OK);
2099
2100 HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
2101 rc_t::OK);
2102 HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
2103 rc_t::OK);
2104 ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair));
2105 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl));
2106 TRY_CHECK_RC(OM::write(gk, pipe1));
2107
2108 pipe1.set_ends(hw_hdl_pair.data());
2109
2110 // put each end of the pipe in a BD
2111 bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
2112 bridge_domain::arp_term_mode_t::OFF,
2113 bridge_domain::flood_mode_t::OFF,
2114 bridge_domain::mac_age_mode_t::ON);
2115
2116 HW::item<uint32_t> hw_bd(33, rc_t::OK);
2117 ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
2118 bridge_domain::learning_mode_t::OFF,
2119 bridge_domain::arp_term_mode_t::OFF,
2120 bridge_domain::flood_mode_t::OFF,
2121 bridge_domain::mac_age_mode_t::ON));
2122
2123 TRY_CHECK_RC(OM::write(gk, bd1));
2124
2125 l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1);
2126 HW::item<bool> hw_l2_1_bind(true, rc_t::OK);
2127
2128 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind,
2129 pipe1.east()->handle(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002130 hw_bd.data(),
2131 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002132 TRY_CHECK_RC(OM::write(gk, *l2_1));
2133
2134 l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1);
2135 HW::item<bool> hw_l2_2_bind(true, rc_t::OK);
2136
2137 ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind,
2138 pipe1.west()->handle(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002139 hw_bd.data(),
2140 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002141 TRY_CHECK_RC(OM::write(gk, *l2_2));
2142
2143 STRICT_ORDER_OFF();
2144
2145 delete l2_1;
2146 delete l2_2;
2147 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2148 pipe1.east()->handle(),
2149 hw_bd.data(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002150 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002151 ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
2152 pipe1.west()->handle(),
2153 hw_bd.data(),
Mohsin Kazmi762d83c2018-09-27 15:00:32 +02002154 l2_binding::l2_port_type_t::L2_PORT_TYPE_NORMAL));
Neale Ranns208c29a2018-04-11 08:08:30 -07002155 ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl));
2156 ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair));
2157 ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
2158 TRY_CHECK(OM::remove(gk));
2159}
2160
Neale Ranns812ed392017-10-16 04:20:13 -07002161BOOST_AUTO_TEST_SUITE_END()