blob: 604cb80c93660d1d6fb3df09737611d7232c0def [file] [log] [blame]
Steven9cd2d7a2017-12-20 12:43:01 -08001/*
2 *------------------------------------------------------------------
3 * Copyright (c) 2017 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
16 */
17
18#include <stdint.h>
19#include <vlib/vlib.h>
20#include <vlib/unix/unix.h>
21#include <vnet/ethernet/ethernet.h>
22#include <vnet/bonding/node.h>
Steven Luong0f09a822019-08-07 12:20:22 -070023#include <vpp/stats/stat_segment.h>
Steven9cd2d7a2017-12-20 12:43:01 -080024
25void
26bond_disable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif)
27{
Steven9f781d82018-06-05 11:09:32 -070028 bond_main_t *bm = &bond_main;
Steven9cd2d7a2017-12-20 12:43:01 -080029 bond_if_t *bif;
30 int i;
31 uword p;
Steven9f781d82018-06-05 11:09:32 -070032 u8 switching_active = 0;
Steven9cd2d7a2017-12-20 12:43:01 -080033
34 bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
Stevena005e7f2018-03-22 17:46:58 -070035 clib_spinlock_lock_if_init (&bif->lockp);
Steven9cd2d7a2017-12-20 12:43:01 -080036 vec_foreach_index (i, bif->active_slaves)
37 {
38 p = *vec_elt_at_index (bif->active_slaves, i);
39 if (p == sif->sw_if_index)
40 {
Steven Luonga1876b82019-08-20 16:58:00 -070041 if ((bif->mode == BOND_MODE_ACTIVE_BACKUP) && (i == 0) &&
42 (vec_len (bif->active_slaves) > 1))
43 /* deleting the active slave for active-backup */
44 switching_active = 1;
Steven9cd2d7a2017-12-20 12:43:01 -080045 vec_del1 (bif->active_slaves, i);
46 hash_unset (bif->active_slave_by_sw_if_index, sif->sw_if_index);
Zhiyong Yang751e3f32019-06-26 05:49:14 -040047 if (sif->lacp_enabled && bif->numa_only)
48 {
49 /* For lacp mode, if we check it is a slave on local numa node,
50 bif->n_numa_slaves should be decreased by 1 becasue the first
51 bif->n_numa_slaves are all slaves on local numa node */
52 if (i < bif->n_numa_slaves)
53 {
54 bif->n_numa_slaves--;
55 ASSERT (bif->n_numa_slaves >= 0);
56 }
57 }
Steven9cd2d7a2017-12-20 12:43:01 -080058 break;
59 }
60 }
Zhiyong Yang6865d3c2019-05-15 04:25:20 -040061
62 /* We get a new slave just becoming active */
Steven Luonga1876b82019-08-20 16:58:00 -070063 if (switching_active)
64 vlib_process_signal_event (bm->vlib_main, bond_process_node.index,
65 BOND_SEND_GARP_NA, bif->hw_if_index);
Stevena005e7f2018-03-22 17:46:58 -070066 clib_spinlock_unlock_if_init (&bif->lockp);
Zhiyong Yang6865d3c2019-05-15 04:25:20 -040067
Steven Luong0f09a822019-08-07 12:20:22 -070068 if (bif->mode == BOND_MODE_LACP)
69 stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
70 [sif->sw_if_index], sif->actor.state);
Steven9cd2d7a2017-12-20 12:43:01 -080071}
72
Steven Luonga1876b82019-08-20 16:58:00 -070073/*
74 * return 1 if s2 is preferred.
75 * return -1 if s1 is preferred.
76 */
77static int
78bond_slave_sort (void *a1, void *a2)
79{
80 u32 *s1 = a1;
81 u32 *s2 = a2;
82 slave_if_t *sif1 = bond_get_slave_by_sw_if_index (*s1);
83 slave_if_t *sif2 = bond_get_slave_by_sw_if_index (*s2);
84 bond_if_t *bif;
85
86 ASSERT (sif1);
87 ASSERT (sif2);
88 /*
89 * sort entries according to preference rules:
90 * 1. biggest weight
91 * 2. numa-node
92 * 3. current active slave (to prevent churning)
93 * 4. lowest sw_if_index (for deterministic behavior)
94 *
95 */
96 if (sif2->weight > sif1->weight)
97 return 1;
98 if (sif2->weight < sif1->weight)
99 return -1;
100 else
101 {
102 if (sif2->is_local_numa > sif1->is_local_numa)
103 return 1;
104 if (sif2->is_local_numa < sif1->is_local_numa)
105 return -1;
106 else
107 {
108 bif = bond_get_master_by_dev_instance (sif1->bif_dev_instance);
109 /* Favor the current active slave to avoid churning */
110 if (bif->active_slaves[0] == sif2->sw_if_index)
111 return 1;
112 if (bif->active_slaves[0] == sif1->sw_if_index)
113 return -1;
114 /* go for the tiebreaker as the last resort */
115 if (sif1->sw_if_index > sif2->sw_if_index)
116 return 1;
117 if (sif1->sw_if_index < sif2->sw_if_index)
118 return -1;
119 else
120 ASSERT (0);
121 }
122 }
123 return 0;
124}
125
126static void
127bond_sort_slaves (bond_if_t * bif)
128{
129 bond_main_t *bm = &bond_main;
130 u32 old_active = bif->active_slaves[0];
131
132 vec_sort_with_function (bif->active_slaves, bond_slave_sort);
133 if (old_active != bif->active_slaves[0])
134 vlib_process_signal_event (bm->vlib_main, bond_process_node.index,
135 BOND_SEND_GARP_NA, bif->hw_if_index);
136}
137
Steven9cd2d7a2017-12-20 12:43:01 -0800138void
139bond_enable_collecting_distributing (vlib_main_t * vm, slave_if_t * sif)
140{
141 bond_if_t *bif;
Steven9f781d82018-06-05 11:09:32 -0700142 bond_main_t *bm = &bond_main;
Zhiyong Yang6865d3c2019-05-15 04:25:20 -0400143 vnet_main_t *vnm = vnet_get_main ();
144 vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index);
Steven9cd2d7a2017-12-20 12:43:01 -0800145
146 bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
Stevena005e7f2018-03-22 17:46:58 -0700147 clib_spinlock_lock_if_init (&bif->lockp);
Steven9cd2d7a2017-12-20 12:43:01 -0800148 if (!hash_get (bif->active_slave_by_sw_if_index, sif->sw_if_index))
149 {
150 hash_set (bif->active_slave_by_sw_if_index, sif->sw_if_index,
151 sif->sw_if_index);
Zhiyong Yang751e3f32019-06-26 05:49:14 -0400152
153 if ((sif->lacp_enabled && bif->numa_only)
154 && (vm->numa_node == hw->numa_node))
155 {
156 vec_insert_elts (bif->active_slaves, &sif->sw_if_index, 1,
157 bif->n_numa_slaves);
158 bif->n_numa_slaves++;
159 }
160 else
Steven Luonga1876b82019-08-20 16:58:00 -0700161 vec_add1 (bif->active_slaves, sif->sw_if_index);
Steven9f781d82018-06-05 11:09:32 -0700162
Steven Luonga1876b82019-08-20 16:58:00 -0700163 sif->is_local_numa = (vm->numa_node == hw->numa_node) ? 1 : 0;
164 if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
Zhiyong Yang6865d3c2019-05-15 04:25:20 -0400165 {
Steven Luonga1876b82019-08-20 16:58:00 -0700166 if (vec_len (bif->active_slaves) == 1)
167 /* First slave becomes active? */
168 vlib_process_signal_event (bm->vlib_main, bond_process_node.index,
169 BOND_SEND_GARP_NA, bif->hw_if_index);
170 else
171 bond_sort_slaves (bif);
Zhiyong Yang6865d3c2019-05-15 04:25:20 -0400172 }
Steven9cd2d7a2017-12-20 12:43:01 -0800173 }
Stevena005e7f2018-03-22 17:46:58 -0700174 clib_spinlock_unlock_if_init (&bif->lockp);
Zhiyong Yang6865d3c2019-05-15 04:25:20 -0400175
Steven Luong0f09a822019-08-07 12:20:22 -0700176 if (bif->mode == BOND_MODE_LACP)
177 stat_segment_set_state_counter (bm->stats[bif->sw_if_index]
178 [sif->sw_if_index], sif->actor.state);
Steven9cd2d7a2017-12-20 12:43:01 -0800179}
180
181int
182bond_dump_ifs (bond_interface_details_t ** out_bondifs)
183{
184 vnet_main_t *vnm = vnet_get_main ();
185 bond_main_t *bm = &bond_main;
186 bond_if_t *bif;
187 vnet_hw_interface_t *hi;
188 bond_interface_details_t *r_bondifs = NULL;
189 bond_interface_details_t *bondif = NULL;
190
191 /* *INDENT-OFF* */
192 pool_foreach (bif, bm->interfaces,
193 vec_add2(r_bondifs, bondif, 1);
Dave Barachb7b92992018-10-17 10:38:51 -0400194 clib_memset (bondif, 0, sizeof (*bondif));
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500195 bondif->id = bif->id;
Steven9cd2d7a2017-12-20 12:43:01 -0800196 bondif->sw_if_index = bif->sw_if_index;
197 hi = vnet_get_hw_interface (vnm, bif->hw_if_index);
198 clib_memcpy(bondif->interface_name, hi->name,
199 MIN (ARRAY_LEN (bondif->interface_name) - 1,
Benoît Ganne5c828bc2019-09-27 18:08:22 +0200200 vec_len ((const char *) hi->name)));
201 /* enforce by memset() above */
202 ASSERT(0 == bondif->interface_name[ARRAY_LEN (bondif->interface_name) - 1]);
Steven9cd2d7a2017-12-20 12:43:01 -0800203 bondif->mode = bif->mode;
204 bondif->lb = bif->lb;
Zhiyong Yang751e3f32019-06-26 05:49:14 -0400205 bondif->numa_only = bif->numa_only;
Steven9cd2d7a2017-12-20 12:43:01 -0800206 bondif->active_slaves = vec_len (bif->active_slaves);
207 bondif->slaves = vec_len (bif->slaves);
208 );
209 /* *INDENT-ON* */
210
211 *out_bondifs = r_bondifs;
212
213 return 0;
214}
215
216int
217bond_dump_slave_ifs (slave_interface_details_t ** out_slaveifs,
218 u32 bond_sw_if_index)
219{
220 vnet_main_t *vnm = vnet_get_main ();
221 bond_if_t *bif;
222 vnet_hw_interface_t *hi;
223 vnet_sw_interface_t *sw;
224 slave_interface_details_t *r_slaveifs = NULL;
225 slave_interface_details_t *slaveif = NULL;
226 u32 *sw_if_index = NULL;
227 slave_if_t *sif;
228
229 bif = bond_get_master_by_sw_if_index (bond_sw_if_index);
230 if (!bif)
231 return 1;
232
233 vec_foreach (sw_if_index, bif->slaves)
234 {
235 vec_add2 (r_slaveifs, slaveif, 1);
Dave Barachb7b92992018-10-17 10:38:51 -0400236 clib_memset (slaveif, 0, sizeof (*slaveif));
Steven9cd2d7a2017-12-20 12:43:01 -0800237 sif = bond_get_slave_by_sw_if_index (*sw_if_index);
238 if (sif)
239 {
240 sw = vnet_get_sw_interface (vnm, sif->sw_if_index);
241 hi = vnet_get_hw_interface (vnm, sw->hw_if_index);
242 clib_memcpy (slaveif->interface_name, hi->name,
243 MIN (ARRAY_LEN (slaveif->interface_name) - 1,
Benoît Ganne5c828bc2019-09-27 18:08:22 +0200244 vec_len ((const char *) hi->name)));
245 /* enforce by memset() above */
246 ASSERT (0 ==
247 slaveif->interface_name[ARRAY_LEN (slaveif->interface_name) -
248 1]);
Steven9cd2d7a2017-12-20 12:43:01 -0800249 slaveif->sw_if_index = sif->sw_if_index;
250 slaveif->is_passive = sif->is_passive;
251 slaveif->is_long_timeout = sif->is_long_timeout;
Steven Luonga1876b82019-08-20 16:58:00 -0700252 slaveif->is_local_numa = sif->is_local_numa;
253 slaveif->weight = sif->weight;
Steven9cd2d7a2017-12-20 12:43:01 -0800254 }
255 }
256 *out_slaveifs = r_slaveifs;
257
258 return 0;
259}
260
261static void
262bond_delete_neighbor (vlib_main_t * vm, bond_if_t * bif, slave_if_t * sif)
263{
264 bond_main_t *bm = &bond_main;
265 vnet_main_t *vnm = vnet_get_main ();
266 int i;
Stevence2db6a2018-04-23 17:06:24 -0700267 vnet_hw_interface_t *sif_hw;
Steven4f8863b2018-04-12 19:36:19 -0700268
269 sif_hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index);
Steven9cd2d7a2017-12-20 12:43:01 -0800270
271 bif->port_number_bitmap =
272 clib_bitmap_set (bif->port_number_bitmap,
273 ntohs (sif->actor_admin.port_number) - 1, 0);
Steven0d883012018-05-11 11:06:23 -0700274 bm->slave_by_sw_if_index[sif->sw_if_index] = 0;
Steven9cd2d7a2017-12-20 12:43:01 -0800275 vec_free (sif->last_marker_pkt);
276 vec_free (sif->last_rx_pkt);
277 vec_foreach_index (i, bif->slaves)
278 {
279 uword p = *vec_elt_at_index (bif->slaves, i);
280 if (p == sif->sw_if_index)
281 {
282 vec_del1 (bif->slaves, i);
283 break;
284 }
285 }
286
287 bond_disable_collecting_distributing (vm, sif);
288
Steven5967baf2018-09-24 21:09:36 -0700289 vnet_feature_enable_disable ("device-input", "bond-input",
290 sif_hw->hw_if_index, 0, 0, 0);
291
Steven9cd2d7a2017-12-20 12:43:01 -0800292 /* Put back the old mac */
Steven4f8863b2018-04-12 19:36:19 -0700293 vnet_hw_interface_change_mac_address (vnm, sif_hw->hw_if_index,
Steven9cd2d7a2017-12-20 12:43:01 -0800294 sif->persistent_hw_address);
295
Steven9cd2d7a2017-12-20 12:43:01 -0800296 if ((bif->mode == BOND_MODE_LACP) && bm->lacp_enable_disable)
297 (*bm->lacp_enable_disable) (vm, bif, sif, 0);
Steven5967baf2018-09-24 21:09:36 -0700298
Steven Luong0f09a822019-08-07 12:20:22 -0700299 if (bif->mode == BOND_MODE_LACP)
300 stat_segment_deregister_state_counter
301 (bm->stats[bif->sw_if_index][sif->sw_if_index]);
302
Steven5967baf2018-09-24 21:09:36 -0700303 pool_put (bm->neighbors, sif);
Steven9cd2d7a2017-12-20 12:43:01 -0800304}
305
306int
307bond_delete_if (vlib_main_t * vm, u32 sw_if_index)
308{
309 bond_main_t *bm = &bond_main;
310 vnet_main_t *vnm = vnet_get_main ();
311 bond_if_t *bif;
312 slave_if_t *sif;
313 vnet_hw_interface_t *hw;
314 u32 *sif_sw_if_index;
Steven70488ab2018-03-28 17:59:00 -0700315 u32 **s_list = 0;
316 u32 i;
Steven9cd2d7a2017-12-20 12:43:01 -0800317
318 hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
319 if (hw == NULL || bond_dev_class.index != hw->dev_class_index)
320 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
321
322 bif = bond_get_master_by_dev_instance (hw->dev_instance);
323
324 vec_foreach (sif_sw_if_index, bif->slaves)
325 {
Steven70488ab2018-03-28 17:59:00 -0700326 vec_add1 (s_list, sif_sw_if_index);
Steven9cd2d7a2017-12-20 12:43:01 -0800327 }
328
Steven70488ab2018-03-28 17:59:00 -0700329 for (i = 0; i < vec_len (s_list); i++)
330 {
331 sif_sw_if_index = s_list[i];
332 sif = bond_get_slave_by_sw_if_index (*sif_sw_if_index);
333 if (sif)
334 bond_delete_neighbor (vm, bif, sif);
335 }
336
337 if (s_list)
338 vec_free (s_list);
339
Steven9cd2d7a2017-12-20 12:43:01 -0800340 /* bring down the interface */
341 vnet_hw_interface_set_flags (vnm, bif->hw_if_index, 0);
342 vnet_sw_interface_set_flags (vnm, bif->sw_if_index, 0);
343
344 ethernet_delete_interface (vnm, bif->hw_if_index);
345
346 clib_bitmap_free (bif->port_number_bitmap);
347 hash_unset (bm->bond_by_sw_if_index, bif->sw_if_index);
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500348 hash_unset (bm->id_used, bif->id);
Dave Barachb7b92992018-10-17 10:38:51 -0400349 clib_memset (bif, 0, sizeof (*bif));
Steven9cd2d7a2017-12-20 12:43:01 -0800350 pool_put (bm->interfaces, bif);
351
352 return 0;
353}
354
355void
356bond_create_if (vlib_main_t * vm, bond_create_if_args_t * args)
357{
358 bond_main_t *bm = &bond_main;
359 vnet_main_t *vnm = vnet_get_main ();
360 vnet_sw_interface_t *sw;
361 bond_if_t *bif;
362
363 if ((args->mode == BOND_MODE_LACP) && bm->lacp_plugin_loaded == 0)
364 {
365 args->rv = VNET_API_ERROR_FEATURE_DISABLED;
366 args->error = clib_error_return (0, "LACP plugin is not loaded");
367 return;
368 }
369 if (args->mode > BOND_MODE_LACP || args->mode < BOND_MODE_ROUND_ROBIN)
370 {
371 args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
372 args->error = clib_error_return (0, "Invalid mode");
373 return;
374 }
375 if (args->lb > BOND_LB_L23)
376 {
377 args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
378 args->error = clib_error_return (0, "Invalid load-balance");
379 return;
380 }
381 pool_get (bm->interfaces, bif);
Dave Barachb7b92992018-10-17 10:38:51 -0400382 clib_memset (bif, 0, sizeof (*bif));
Steven9cd2d7a2017-12-20 12:43:01 -0800383 bif->dev_instance = bif - bm->interfaces;
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500384 bif->id = args->id;
Steven9cd2d7a2017-12-20 12:43:01 -0800385 bif->lb = args->lb;
386 bif->mode = args->mode;
387
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500388 // Adjust requested interface id
389 if (bif->id == ~0)
390 bif->id = bif->dev_instance;
391 if (hash_get (bm->id_used, bif->id))
392 {
393 args->rv = VNET_API_ERROR_INSTANCE_IN_USE;
394 pool_put (bm->interfaces, bif);
395 return;
396 }
397 hash_set (bm->id_used, bif->id, 1);
398
Steven9cd2d7a2017-12-20 12:43:01 -0800399 // Special load-balance mode used for rr and bc
400 if (bif->mode == BOND_MODE_ROUND_ROBIN)
401 bif->lb = BOND_LB_RR;
402 else if (bif->mode == BOND_MODE_BROADCAST)
403 bif->lb = BOND_LB_BC;
Steven318de5d2018-10-06 22:30:50 -0700404 else if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
405 bif->lb = BOND_LB_AB;
Steven9cd2d7a2017-12-20 12:43:01 -0800406
407 bif->use_custom_mac = args->hw_addr_set;
408 if (!args->hw_addr_set)
409 {
410 f64 now = vlib_time_now (vm);
411 u32 rnd;
412 rnd = (u32) (now * 1e6);
413 rnd = random_u32 (&rnd);
414
415 memcpy (args->hw_addr + 2, &rnd, sizeof (rnd));
416 args->hw_addr[0] = 2;
417 args->hw_addr[1] = 0xfe;
418 }
419 memcpy (bif->hw_address, args->hw_addr, 6);
420 args->error = ethernet_register_interface
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500421 (vnm, bond_dev_class.index, bif->dev_instance /* device instance */ ,
Steven9cd2d7a2017-12-20 12:43:01 -0800422 bif->hw_address /* ethernet address */ ,
423 &bif->hw_if_index, 0 /* flag change */ );
424
425 if (args->error)
426 {
427 args->rv = VNET_API_ERROR_INVALID_REGISTRATION;
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500428 hash_unset (bm->id_used, bif->id);
Steven9cd2d7a2017-12-20 12:43:01 -0800429 pool_put (bm->interfaces, bif);
430 return;
431 }
432
433 sw = vnet_get_hw_sw_interface (vnm, bif->hw_if_index);
434 bif->sw_if_index = sw->sw_if_index;
435 bif->group = bif->sw_if_index;
Zhiyong Yang751e3f32019-06-26 05:49:14 -0400436 bif->numa_only = args->numa_only;
Stevena005e7f2018-03-22 17:46:58 -0700437 if (vlib_get_thread_main ()->n_vlib_mains > 1)
438 clib_spinlock_init (&bif->lockp);
Steven9cd2d7a2017-12-20 12:43:01 -0800439
440 vnet_hw_interface_set_flags (vnm, bif->hw_if_index,
441 VNET_HW_INTERFACE_FLAG_LINK_UP);
442
443 hash_set (bm->bond_by_sw_if_index, bif->sw_if_index, bif->dev_instance);
444
445 // for return
446 args->sw_if_index = bif->sw_if_index;
Mohsin Kazmi8c1280f2019-07-01 11:08:20 +0200447 args->rv = 0;
Steven9cd2d7a2017-12-20 12:43:01 -0800448}
449
450static clib_error_t *
451bond_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
452 vlib_cli_command_t * cmd)
453{
454 unformat_input_t _line_input, *line_input = &_line_input;
455 bond_create_if_args_t args = { 0 };
456 u8 mode_is_set = 0;
457
458 /* Get a line of input. */
459 if (!unformat_user (input, unformat_line_input, line_input))
460 return clib_error_return (0, "Missing required arguments.");
461
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500462 args.id = ~0;
Steven9cd2d7a2017-12-20 12:43:01 -0800463 args.mode = -1;
464 args.lb = BOND_LB_L2;
Mohsin Kazmi8c1280f2019-07-01 11:08:20 +0200465 args.rv = -1;
Steven9cd2d7a2017-12-20 12:43:01 -0800466 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
467 {
468 if (unformat (line_input, "mode %U", unformat_bond_mode, &args.mode))
469 mode_is_set = 1;
470 else if (((args.mode == BOND_MODE_LACP) || (args.mode == BOND_MODE_XOR))
471 && unformat (line_input, "load-balance %U",
472 unformat_bond_load_balance, &args.lb))
473 ;
474 else if (unformat (line_input, "hw-addr %U",
475 unformat_ethernet_address, args.hw_addr))
476 args.hw_addr_set = 1;
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500477 else if (unformat (line_input, "id %u", &args.id))
478 ;
Zhiyong Yang751e3f32019-06-26 05:49:14 -0400479 else if (unformat (line_input, "numa-only"))
480 {
481 if (args.mode == BOND_MODE_LACP)
482 args.numa_only = 1;
483 else
484 return clib_error_return (0,
485 "Only lacp mode supports numa-only so far!");
486 }
Steven9cd2d7a2017-12-20 12:43:01 -0800487 else
488 return clib_error_return (0, "unknown input `%U'",
489 format_unformat_error, input);
490 }
491 unformat_free (line_input);
492
493 if (mode_is_set == 0)
494 return clib_error_return (0, "Missing bond mode");
495
496 bond_create_if (vm, &args);
497
Mohsin Kazmi8c1280f2019-07-01 11:08:20 +0200498 if (!args.rv)
499 vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
500 vnet_get_main (), args.sw_if_index);
501
Steven9cd2d7a2017-12-20 12:43:01 -0800502 return args.error;
503}
504
505/* *INDENT-OFF* */
506VLIB_CLI_COMMAND (bond_create_command, static) = {
507 .path = "create bond",
508 .short_help = "create bond mode {round-robin | active-backup | broadcast | "
Zhiyong Yanga58fec12019-07-21 21:51:21 -0400509 "{lacp | xor} [load-balance { l2 | l23 | l34 } [numa-only]]} [hw-addr <mac-address>] "
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500510 "[id <if-id>]",
Steven9cd2d7a2017-12-20 12:43:01 -0800511 .function = bond_create_command_fn,
512};
513/* *INDENT-ON* */
514
515static clib_error_t *
516bond_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
517 vlib_cli_command_t * cmd)
518{
519 unformat_input_t _line_input, *line_input = &_line_input;
520 u32 sw_if_index = ~0;
521 vnet_main_t *vnm = vnet_get_main ();
522 int rv;
523
524 /* Get a line of input. */
525 if (!unformat_user (input, unformat_line_input, line_input))
526 return clib_error_return (0, "Missing <interface>");
527
528 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
529 {
530 if (unformat (line_input, "sw_if_index %d", &sw_if_index))
531 ;
532 else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
533 vnm, &sw_if_index))
534 ;
535 else
536 return clib_error_return (0, "unknown input `%U'",
537 format_unformat_error, input);
538 }
539 unformat_free (line_input);
540
541 if (sw_if_index == ~0)
542 return clib_error_return (0,
543 "please specify interface name or sw_if_index");
544
545 rv = bond_delete_if (vm, sw_if_index);
546 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
547 return clib_error_return (0, "not a bond interface");
548 else if (rv != 0)
549 return clib_error_return (0, "error on deleting bond interface");
550
551 return 0;
552}
553
554/* *INDENT-OFF* */
555VLIB_CLI_COMMAND (bond_delete__command, static) =
556{
557 .path = "delete bond",
558 .short_help = "delete bond {<interface> | sw_if_index <sw_idx>}",
559 .function = bond_delete_command_fn,
560};
561/* *INDENT-ON* */
562
563void
564bond_enslave (vlib_main_t * vm, bond_enslave_args_t * args)
565{
566 bond_main_t *bm = &bond_main;
567 vnet_main_t *vnm = vnet_get_main ();
568 bond_if_t *bif;
569 slave_if_t *sif;
570 vnet_interface_main_t *im = &vnm->interface_main;
Steven4f8863b2018-04-12 19:36:19 -0700571 vnet_hw_interface_t *bif_hw, *sif_hw;
Steven9cd2d7a2017-12-20 12:43:01 -0800572 vnet_sw_interface_t *sw;
Stevenc4e99c52018-09-27 20:06:26 -0700573 u32 thread_index;
574 u32 sif_if_index;
Steven9cd2d7a2017-12-20 12:43:01 -0800575
576 bif = bond_get_master_by_sw_if_index (args->group);
577 if (!bif)
578 {
579 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
580 args->error = clib_error_return (0, "bond interface not found");
581 return;
582 }
583 // make sure the interface is not already enslaved
584 if (bond_get_slave_by_sw_if_index (args->slave))
585 {
586 args->rv = VNET_API_ERROR_VALUE_EXIST;
587 args->error = clib_error_return (0, "interface was already enslaved");
588 return;
589 }
Steven4f8863b2018-04-12 19:36:19 -0700590 sif_hw = vnet_get_sup_hw_interface (vnm, args->slave);
591 if (sif_hw->dev_class_index == bond_dev_class.index)
Steven9cd2d7a2017-12-20 12:43:01 -0800592 {
593 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
594 args->error =
595 clib_error_return (0, "bond interface cannot be enslaved");
596 return;
597 }
Steven Luong0f09a822019-08-07 12:20:22 -0700598 if (bif->mode == BOND_MODE_LACP)
599 {
600 u8 *name = format (0, "/if/lacp/%u/%u/state", bif->sw_if_index,
601 args->slave);
602
603 vec_validate (bm->stats, bif->sw_if_index);
604 vec_validate (bm->stats[bif->sw_if_index], args->slave);
605
606 args->error = stat_segment_register_state_counter
607 (name, &bm->stats[bif->sw_if_index][args->slave]);
608 vec_free (name);
609 if (args->error != 0)
610 {
611 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
612 return;
613 }
614 }
615
Steven9cd2d7a2017-12-20 12:43:01 -0800616 pool_get (bm->neighbors, sif);
Dave Barachb7b92992018-10-17 10:38:51 -0400617 clib_memset (sif, 0, sizeof (*sif));
Steven9cd2d7a2017-12-20 12:43:01 -0800618 sw = pool_elt_at_index (im->sw_interfaces, args->slave);
Steven Luongbac326c2019-08-05 09:47:58 -0700619 /* port_enabled is both admin up and hw link up */
620 sif->port_enabled = vnet_sw_interface_is_up (vnm, sw->sw_if_index);
Steven9cd2d7a2017-12-20 12:43:01 -0800621 sif->sw_if_index = sw->sw_if_index;
622 sif->hw_if_index = sw->hw_if_index;
623 sif->packet_template_index = (u8) ~ 0;
624 sif->is_passive = args->is_passive;
625 sif->group = args->group;
626 sif->bif_dev_instance = bif->dev_instance;
627 sif->mode = bif->mode;
628
629 sif->is_long_timeout = args->is_long_timeout;
630 if (args->is_long_timeout)
631 sif->ttl_in_seconds = LACP_LONG_TIMOUT_TIME;
632 else
633 sif->ttl_in_seconds = LACP_SHORT_TIMOUT_TIME;
634
Steven0d883012018-05-11 11:06:23 -0700635 vec_validate_aligned (bm->slave_by_sw_if_index, sif->sw_if_index,
636 CLIB_CACHE_LINE_BYTES);
637 /*
638 * sif - bm->neighbors may be 0
639 * Left shift it by 1 bit to distinguish the valid entry that we actually
640 * store from the null entries
641 */
642 bm->slave_by_sw_if_index[sif->sw_if_index] =
643 (uword) (((sif - bm->neighbors) << 1) | 1);
Steven9cd2d7a2017-12-20 12:43:01 -0800644 vec_add1 (bif->slaves, sif->sw_if_index);
645
Steven4f8863b2018-04-12 19:36:19 -0700646 sif_hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index);
647
Steven9cd2d7a2017-12-20 12:43:01 -0800648 /* Save the old mac */
Steven4f8863b2018-04-12 19:36:19 -0700649 memcpy (sif->persistent_hw_address, sif_hw->hw_address, 6);
650 bif_hw = vnet_get_sup_hw_interface (vnm, bif->sw_if_index);
Steven9cd2d7a2017-12-20 12:43:01 -0800651 if (bif->use_custom_mac)
652 {
Steven4f8863b2018-04-12 19:36:19 -0700653 vnet_hw_interface_change_mac_address (vnm, sif_hw->hw_if_index,
Steven9cd2d7a2017-12-20 12:43:01 -0800654 bif->hw_address);
655 }
656 else
657 {
658 // bond interface gets the mac address from the first slave
659 if (vec_len (bif->slaves) == 1)
660 {
Steven4f8863b2018-04-12 19:36:19 -0700661 memcpy (bif->hw_address, sif_hw->hw_address, 6);
662 vnet_hw_interface_change_mac_address (vnm, bif_hw->hw_if_index,
663 sif_hw->hw_address);
Steven9cd2d7a2017-12-20 12:43:01 -0800664 }
665 else
666 {
667 // subsequent slaves gets the mac address of the bond interface
Steven4f8863b2018-04-12 19:36:19 -0700668 vnet_hw_interface_change_mac_address (vnm, sif_hw->hw_if_index,
Steven9cd2d7a2017-12-20 12:43:01 -0800669 bif->hw_address);
670 }
671 }
672
Steven4f8863b2018-04-12 19:36:19 -0700673 if (bif_hw->l2_if_count)
674 {
675 ethernet_set_flags (vnm, sif_hw->hw_if_index,
676 ETHERNET_INTERFACE_FLAG_ACCEPT_ALL);
677 /* ensure all packets go to ethernet-input */
678 ethernet_set_rx_redirect (vnm, sif_hw, 1);
679 }
680
Stevene43278f2019-01-17 15:11:29 -0800681 if (bif->mode == BOND_MODE_LACP)
Steven9cd2d7a2017-12-20 12:43:01 -0800682 {
Stevene43278f2019-01-17 15:11:29 -0800683 if (bm->lacp_enable_disable)
684 (*bm->lacp_enable_disable) (vm, bif, sif, 1);
Steven9cd2d7a2017-12-20 12:43:01 -0800685 }
Steven Luongbac326c2019-08-05 09:47:58 -0700686 else if (sif->port_enabled)
Steven9cd2d7a2017-12-20 12:43:01 -0800687 {
688 bond_enable_collecting_distributing (vm, sif);
689 }
690
Stevenc4e99c52018-09-27 20:06:26 -0700691 vec_foreach_index (thread_index, bm->per_thread_data)
692 {
693 bond_per_thread_data_t *ptd = vec_elt_at_index (bm->per_thread_data,
694 thread_index);
695
Damjan Marion69fdfee2018-10-06 14:33:18 +0200696 vec_validate_aligned (ptd->per_port_queue, vec_len (bif->slaves) - 1,
Stevenc4e99c52018-09-27 20:06:26 -0700697 CLIB_CACHE_LINE_BYTES);
698
699 vec_foreach_index (sif_if_index, ptd->per_port_queue)
700 {
701 ptd->per_port_queue[sif_if_index].n_buffers = 0;
702 }
703 }
704
Steven9cd2d7a2017-12-20 12:43:01 -0800705 args->rv = vnet_feature_enable_disable ("device-input", "bond-input",
Steven4f8863b2018-04-12 19:36:19 -0700706 sif_hw->hw_if_index, 1, 0, 0);
Steven9cd2d7a2017-12-20 12:43:01 -0800707
708 if (args->rv)
709 {
710 args->error =
711 clib_error_return (0,
712 "Error encountered on input feature arc enable");
713 }
714}
715
716static clib_error_t *
717enslave_interface_command_fn (vlib_main_t * vm, unformat_input_t * input,
718 vlib_cli_command_t * cmd)
719{
720 bond_enslave_args_t args = { 0 };
721 unformat_input_t _line_input, *line_input = &_line_input;
722 vnet_main_t *vnm = vnet_get_main ();
723
724 /* Get a line of input. */
725 if (!unformat_user (input, unformat_line_input, line_input))
726 return clib_error_return (0, "Missing required arguments.");
727
728 args.slave = ~0;
729 args.group = ~0;
730 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
731 {
Stevenb3caf552018-03-27 15:04:47 -0700732 if (unformat (line_input, "%U %U",
733 unformat_vnet_sw_interface, vnm, &args.group,
Steven9cd2d7a2017-12-20 12:43:01 -0800734 unformat_vnet_sw_interface, vnm, &args.slave))
735 ;
Steven9cd2d7a2017-12-20 12:43:01 -0800736 else if (unformat (line_input, "passive"))
737 args.is_passive = 1;
738 else if (unformat (line_input, "long-timeout"))
739 args.is_long_timeout = 1;
740 else
741 {
742 args.error = clib_error_return (0, "unknown input `%U'",
743 format_unformat_error, input);
744 break;
745 }
746 }
747 unformat_free (line_input);
748
749 if (args.error)
750 return args.error;
751 if (args.group == ~0)
752 return clib_error_return (0, "Missing bond interface");
753 if (args.slave == ~0)
Stevenb3caf552018-03-27 15:04:47 -0700754 return clib_error_return (0, "please specify valid slave interface name");
Steven9cd2d7a2017-12-20 12:43:01 -0800755
756 bond_enslave (vm, &args);
757
758 return args.error;
759}
760
761/* *INDENT-OFF* */
762VLIB_CLI_COMMAND (enslave_interface_command, static) = {
Stevenb3caf552018-03-27 15:04:47 -0700763 .path = "bond add",
764 .short_help = "bond add <BondEthernetx> <slave-interface> "
765 "[passive] [long-timeout]",
Steven9cd2d7a2017-12-20 12:43:01 -0800766 .function = enslave_interface_command_fn,
767};
768/* *INDENT-ON* */
769
770void
771bond_detach_slave (vlib_main_t * vm, bond_detach_slave_args_t * args)
772{
773 bond_if_t *bif;
774 slave_if_t *sif;
775
776 sif = bond_get_slave_by_sw_if_index (args->slave);
777 if (!sif)
778 {
779 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
780 args->error = clib_error_return (0, "interface was not enslaved");
781 return;
782 }
783 bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
784 bond_delete_neighbor (vm, bif, sif);
785}
786
787static clib_error_t *
788detach_interface_command_fn (vlib_main_t * vm, unformat_input_t * input,
789 vlib_cli_command_t * cmd)
790{
791 bond_detach_slave_args_t args = { 0 };
792 unformat_input_t _line_input, *line_input = &_line_input;
793 vnet_main_t *vnm = vnet_get_main ();
794
795 /* Get a line of input. */
796 if (!unformat_user (input, unformat_line_input, line_input))
797 return clib_error_return (0, "Missing required arguments.");
798
799 args.slave = ~0;
800 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
801 {
Stevenb3caf552018-03-27 15:04:47 -0700802 if (unformat (line_input, "%U",
Steven9cd2d7a2017-12-20 12:43:01 -0800803 unformat_vnet_sw_interface, vnm, &args.slave))
804 ;
805 else
806 {
807 args.error = clib_error_return (0, "unknown input `%U'",
808 format_unformat_error, input);
809 break;
810 }
811 }
812 unformat_free (line_input);
813
814 if (args.error)
815 return args.error;
816 if (args.slave == ~0)
Stevenb3caf552018-03-27 15:04:47 -0700817 return clib_error_return (0, "please specify valid slave interface name");
Steven9cd2d7a2017-12-20 12:43:01 -0800818
819 bond_detach_slave (vm, &args);
820
821 return args.error;
822}
823
824/* *INDENT-OFF* */
825VLIB_CLI_COMMAND (detach_interface_command, static) = {
Stevenb3caf552018-03-27 15:04:47 -0700826 .path = "bond del",
827 .short_help = "bond del <slave-interface>",
Steven9cd2d7a2017-12-20 12:43:01 -0800828 .function = detach_interface_command_fn,
829};
830/* *INDENT-ON* */
831
832static void
833show_bond (vlib_main_t * vm)
834{
835 bond_main_t *bm = &bond_main;
836 bond_if_t *bif;
837
Steven318de5d2018-10-06 22:30:50 -0700838 vlib_cli_output (vm, "%-16s %-12s %-13s %-13s %-14s %s",
Steven9cd2d7a2017-12-20 12:43:01 -0800839 "interface name", "sw_if_index", "mode",
840 "load balance", "active slaves", "slaves");
841
842 /* *INDENT-OFF* */
843 pool_foreach (bif, bm->interfaces,
844 ({
Steven318de5d2018-10-06 22:30:50 -0700845 vlib_cli_output (vm, "%-16U %-12d %-13U %-13U %-14u %u",
Steven9cd2d7a2017-12-20 12:43:01 -0800846 format_bond_interface_name, bif->dev_instance,
847 bif->sw_if_index, format_bond_mode, bif->mode,
848 format_bond_load_balance, bif->lb,
849 vec_len (bif->active_slaves), vec_len (bif->slaves));
850 }));
851 /* *INDENT-ON* */
852}
853
854static void
855show_bond_details (vlib_main_t * vm)
856{
857 bond_main_t *bm = &bond_main;
858 bond_if_t *bif;
859 u32 *sw_if_index;
860
861 /* *INDENT-OFF* */
862 pool_foreach (bif, bm->interfaces,
863 ({
864 vlib_cli_output (vm, "%U", format_bond_interface_name, bif->dev_instance);
865 vlib_cli_output (vm, " mode: %U",
866 format_bond_mode, bif->mode);
867 vlib_cli_output (vm, " load balance: %U",
868 format_bond_load_balance, bif->lb);
869 if (bif->mode == BOND_MODE_ROUND_ROBIN)
870 vlib_cli_output (vm, " last xmit slave index: %u",
871 bif->lb_rr_last_index);
872 vlib_cli_output (vm, " number of active slaves: %d",
873 vec_len (bif->active_slaves));
874 vec_foreach (sw_if_index, bif->active_slaves)
875 {
876 vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name,
877 vnet_get_main (), *sw_if_index);
Steven Luonga1876b82019-08-20 16:58:00 -0700878 if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
879 {
880 slave_if_t *sif = bond_get_slave_by_sw_if_index (*sw_if_index);
881 if (sif)
882 vlib_cli_output (vm, " weight: %u, is_local_numa: %u, "
883 "sw_if_index: %u", sif->weight,
884 sif->is_local_numa, sif->sw_if_index);
885 }
Steven9cd2d7a2017-12-20 12:43:01 -0800886 }
887 vlib_cli_output (vm, " number of slaves: %d", vec_len (bif->slaves));
888 vec_foreach (sw_if_index, bif->slaves)
889 {
890 vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name,
891 vnet_get_main (), *sw_if_index);
892 }
893 vlib_cli_output (vm, " device instance: %d", bif->dev_instance);
Alexander Chernavinad9d5282018-12-13 09:08:09 -0500894 vlib_cli_output (vm, " interface id: %d", bif->id);
Steven9cd2d7a2017-12-20 12:43:01 -0800895 vlib_cli_output (vm, " sw_if_index: %d", bif->sw_if_index);
896 vlib_cli_output (vm, " hw_if_index: %d", bif->hw_if_index);
897 }));
898 /* *INDENT-ON* */
899}
900
901static clib_error_t *
902show_bond_fn (vlib_main_t * vm, unformat_input_t * input,
903 vlib_cli_command_t * cmd)
904{
905 u8 details = 0;
906
907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
908 {
909 if (unformat (input, "details"))
910 details = 1;
911 else
912 {
913 return clib_error_return (0, "unknown input `%U'",
914 format_unformat_error, input);
915 }
916 }
917
918 if (details)
919 show_bond_details (vm);
920 else
921 show_bond (vm);
922
923 return 0;
924}
925
926/* *INDENT-OFF* */
927VLIB_CLI_COMMAND (show_bond_command, static) = {
928 .path = "show bond",
929 .short_help = "show bond [details]",
930 .function = show_bond_fn,
931};
932/* *INDENT-ON* */
933
Steven Luonga1876b82019-08-20 16:58:00 -0700934void
935bond_set_intf_weight (vlib_main_t * vm, bond_set_intf_weight_args_t * args)
936{
937 slave_if_t *sif;
938 bond_if_t *bif;
939 vnet_main_t *vnm;
940 u32 old_weight;
941
942 sif = bond_get_slave_by_sw_if_index (args->sw_if_index);
943 if (!sif)
944 {
945 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
946 args->error = clib_error_return (0, "Interface not enslaved");
947 return;
948 }
949 bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
950 if (!bif)
951 {
952 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
953 args->error = clib_error_return (0, "bond interface not found");
954 return;
955 }
956 if (bif->mode != BOND_MODE_ACTIVE_BACKUP)
957 {
958 args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
959 args->error =
960 clib_error_return (0, "Weight valid for active-backup only");
961 return;
962 }
963
964 old_weight = sif->weight;
965 sif->weight = args->weight;
966 vnm = vnet_get_main ();
967 /*
968 * No need to sort the list if the affected slave is not up (not in active
969 * slave set), active slave count is 1, or the current slave is already the
970 * primary slave and new weight > old weight.
971 */
972 if (!vnet_sw_interface_is_up (vnm, sif->sw_if_index) ||
973 (vec_len (bif->active_slaves) == 1) ||
974 ((bif->active_slaves[0] == sif->sw_if_index) &&
975 (sif->weight >= old_weight)))
976 return;
977
978 bond_sort_slaves (bif);
979}
980
981static clib_error_t *
982bond_set_intf_cmd (vlib_main_t * vm, unformat_input_t * input,
983 vlib_cli_command_t * cmd)
984{
985 bond_set_intf_weight_args_t args = { 0 };
986 u32 sw_if_index = (u32) ~ 0;
987 unformat_input_t _line_input, *line_input = &_line_input;
988 vnet_main_t *vnm = vnet_get_main ();
989 u8 weight_enter = 0;
990 u32 weight = 0;
991
992 /* Get a line of input. */
993 if (!unformat_user (input, unformat_line_input, line_input))
994 return clib_error_return (0, "Missing required arguments.");
995
996 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
997 {
998 if (unformat (line_input, "sw_if_index %d", &sw_if_index))
999 ;
1000 else if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
1001 &sw_if_index))
1002 ;
1003 else if (unformat (line_input, "weight %u", &weight))
1004 weight_enter = 1;
1005 else
1006 {
1007 clib_error_return (0, "unknown input `%U'", format_unformat_error,
1008 input);
1009 break;
1010 }
1011 }
1012
1013 unformat_free (line_input);
1014 if (sw_if_index == (u32) ~ 0)
1015 {
1016 args.rv = VNET_API_ERROR_INVALID_INTERFACE;
1017 clib_error_return (0, "Interface name is invalid!");
1018 }
1019 if (weight_enter == 0)
1020 {
1021 args.rv = VNET_API_ERROR_INVALID_ARGUMENT;
1022 clib_error_return (0, "weight missing");
1023 }
1024
1025 args.sw_if_index = sw_if_index;
1026 args.weight = weight;
1027 bond_set_intf_weight (vm, &args);
1028
1029 return args.error;
1030}
1031
1032/* *INDENT-OFF* */
1033VLIB_CLI_COMMAND(set_interface_bond_cmd, static) = {
1034 .path = "set interface bond",
1035 .short_help = "set interface bond <interface> | sw_if_index <idx>"
1036 " weight <value>",
1037 .function = bond_set_intf_cmd,
1038};
1039/* *INDENT-ON* */
1040
Steven9cd2d7a2017-12-20 12:43:01 -08001041clib_error_t *
1042bond_cli_init (vlib_main_t * vm)
1043{
1044 bond_main_t *bm = &bond_main;
1045
1046 bm->vlib_main = vm;
1047 bm->vnet_main = vnet_get_main ();
Steven0d883012018-05-11 11:06:23 -07001048 vec_validate_aligned (bm->slave_by_sw_if_index, 1, CLIB_CACHE_LINE_BYTES);
Stevenc4e99c52018-09-27 20:06:26 -07001049 vec_validate_aligned (bm->per_thread_data,
1050 vlib_get_thread_main ()->n_vlib_mains - 1,
1051 CLIB_CACHE_LINE_BYTES);
Steven9cd2d7a2017-12-20 12:43:01 -08001052
1053 return 0;
1054}
1055
1056VLIB_INIT_FUNCTION (bond_cli_init);
1057
1058/*
1059 * fd.io coding-style-patch-verification: ON
1060 *
1061 * Local Variables:
1062 * eval: (c-set-style "gnu")
1063 * End:
1064 */