FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
cli.c
Go to the documentation of this file.
1 /*
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>
23 
24 void
26 {
27  bond_main_t *bm = &bond_main;
28  bond_if_t *bif;
29  int i;
30  uword p;
31  u8 switching_active = 0;
32 
36  {
37  p = *vec_elt_at_index (bif->active_slaves, i);
38  if (p == sif->sw_if_index)
39  {
40  /* Are we disabling the very 1st slave? */
41  if (sif->sw_if_index == *vec_elt_at_index (bif->active_slaves, 0))
42  switching_active = 1;
43 
44  vec_del1 (bif->active_slaves, i);
46 
47  /* We got a new slave just becoming active? */
48  if ((vec_len (bif->active_slaves) >= 1) &&
49  (bif->mode == BOND_MODE_ACTIVE_BACKUP) && switching_active)
52  break;
53  }
54  }
56 }
57 
58 void
60 {
61  bond_if_t *bif;
62  bond_main_t *bm = &bond_main;
63 
67  {
69  sif->sw_if_index);
70  vec_add1 (bif->active_slaves, sif->sw_if_index);
71 
72  /* First slave becomes active? */
73  if ((vec_len (bif->active_slaves) == 1) &&
74  (bif->mode == BOND_MODE_ACTIVE_BACKUP))
77  }
79 }
80 
81 int
83 {
84  vnet_main_t *vnm = vnet_get_main ();
85  bond_main_t *bm = &bond_main;
86  bond_if_t *bif;
88  bond_interface_details_t *r_bondifs = NULL;
90 
91  /* *INDENT-OFF* */
92  pool_foreach (bif, bm->interfaces,
93  vec_add2(r_bondifs, bondif, 1);
94  memset (bondif, 0, sizeof (*bondif));
95  bondif->sw_if_index = bif->sw_if_index;
96  hi = vnet_get_hw_interface (vnm, bif->hw_if_index);
97  clib_memcpy(bondif->interface_name, hi->name,
98  MIN (ARRAY_LEN (bondif->interface_name) - 1,
99  strlen ((const char *) hi->name)));
100  bondif->mode = bif->mode;
101  bondif->lb = bif->lb;
102  bondif->active_slaves = vec_len (bif->active_slaves);
103  bondif->slaves = vec_len (bif->slaves);
104  );
105  /* *INDENT-ON* */
106 
107  *out_bondifs = r_bondifs;
108 
109  return 0;
110 }
111 
112 int
114  u32 bond_sw_if_index)
115 {
116  vnet_main_t *vnm = vnet_get_main ();
117  bond_if_t *bif;
120  slave_interface_details_t *r_slaveifs = NULL;
121  slave_interface_details_t *slaveif = NULL;
122  u32 *sw_if_index = NULL;
123  slave_if_t *sif;
124 
125  bif = bond_get_master_by_sw_if_index (bond_sw_if_index);
126  if (!bif)
127  return 1;
128 
129  vec_foreach (sw_if_index, bif->slaves)
130  {
131  vec_add2 (r_slaveifs, slaveif, 1);
132  memset (slaveif, 0, sizeof (*slaveif));
133  sif = bond_get_slave_by_sw_if_index (*sw_if_index);
134  if (sif)
135  {
136  sw = vnet_get_sw_interface (vnm, sif->sw_if_index);
137  hi = vnet_get_hw_interface (vnm, sw->hw_if_index);
138  clib_memcpy (slaveif->interface_name, hi->name,
139  MIN (ARRAY_LEN (slaveif->interface_name) - 1,
140  strlen ((const char *) hi->name)));
141  slaveif->sw_if_index = sif->sw_if_index;
142  slaveif->is_passive = sif->is_passive;
143  slaveif->is_long_timeout = sif->is_long_timeout;
144  }
145  }
146  *out_slaveifs = r_slaveifs;
147 
148  return 0;
149 }
150 
151 static void
153 {
154  bond_main_t *bm = &bond_main;
155  vnet_main_t *vnm = vnet_get_main ();
156  int i;
157  vnet_hw_interface_t *sif_hw;
158 
159  sif_hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index);
160 
161  bif->port_number_bitmap =
163  ntohs (sif->actor_admin.port_number) - 1, 0);
164  bm->slave_by_sw_if_index[sif->sw_if_index] = 0;
165  vec_free (sif->last_marker_pkt);
166  vec_free (sif->last_rx_pkt);
167  vec_foreach_index (i, bif->slaves)
168  {
169  uword p = *vec_elt_at_index (bif->slaves, i);
170  if (p == sif->sw_if_index)
171  {
172  vec_del1 (bif->slaves, i);
173  break;
174  }
175  }
176 
178 
179  vnet_feature_enable_disable ("device-input", "bond-input",
180  sif_hw->hw_if_index, 0, 0, 0);
181 
182  /* Put back the old mac */
184  sif->persistent_hw_address);
185 
186  if ((bif->mode == BOND_MODE_LACP) && bm->lacp_enable_disable)
187  (*bm->lacp_enable_disable) (vm, bif, sif, 0);
188 
189  pool_put (bm->neighbors, sif);
190 }
191 
192 int
194 {
195  bond_main_t *bm = &bond_main;
196  vnet_main_t *vnm = vnet_get_main ();
197  bond_if_t *bif;
198  slave_if_t *sif;
200  u32 *sif_sw_if_index;
201  u32 **s_list = 0;
202  u32 i;
203 
204  hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
205  if (hw == NULL || bond_dev_class.index != hw->dev_class_index)
206  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
207 
209 
210  vec_foreach (sif_sw_if_index, bif->slaves)
211  {
212  vec_add1 (s_list, sif_sw_if_index);
213  }
214 
215  for (i = 0; i < vec_len (s_list); i++)
216  {
217  sif_sw_if_index = s_list[i];
218  sif = bond_get_slave_by_sw_if_index (*sif_sw_if_index);
219  if (sif)
220  bond_delete_neighbor (vm, bif, sif);
221  }
222 
223  if (s_list)
224  vec_free (s_list);
225 
226  /* bring down the interface */
229 
231 
234  memset (bif, 0, sizeof (*bif));
235  pool_put (bm->interfaces, bif);
236 
237  return 0;
238 }
239 
240 void
242 {
243  bond_main_t *bm = &bond_main;
244  vnet_main_t *vnm = vnet_get_main ();
246  bond_if_t *bif;
247 
248  if ((args->mode == BOND_MODE_LACP) && bm->lacp_plugin_loaded == 0)
249  {
250  args->rv = VNET_API_ERROR_FEATURE_DISABLED;
251  args->error = clib_error_return (0, "LACP plugin is not loaded");
252  return;
253  }
254  if (args->mode > BOND_MODE_LACP || args->mode < BOND_MODE_ROUND_ROBIN)
255  {
256  args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
257  args->error = clib_error_return (0, "Invalid mode");
258  return;
259  }
260  if (args->lb > BOND_LB_L23)
261  {
262  args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
263  args->error = clib_error_return (0, "Invalid load-balance");
264  return;
265  }
266  pool_get (bm->interfaces, bif);
267  memset (bif, 0, sizeof (*bif));
268  bif->dev_instance = bif - bm->interfaces;
269  bif->lb = args->lb;
270  bif->mode = args->mode;
271 
272  // Special load-balance mode used for rr and bc
273  if (bif->mode == BOND_MODE_ROUND_ROBIN)
274  bif->lb = BOND_LB_RR;
275  else if (bif->mode == BOND_MODE_BROADCAST)
276  bif->lb = BOND_LB_BC;
277  else if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
278  bif->lb = BOND_LB_AB;
279 
280  bif->use_custom_mac = args->hw_addr_set;
281  if (!args->hw_addr_set)
282  {
283  f64 now = vlib_time_now (vm);
284  u32 rnd;
285  rnd = (u32) (now * 1e6);
286  rnd = random_u32 (&rnd);
287 
288  memcpy (args->hw_addr + 2, &rnd, sizeof (rnd));
289  args->hw_addr[0] = 2;
290  args->hw_addr[1] = 0xfe;
291  }
292  memcpy (bif->hw_address, args->hw_addr, 6);
294  (vnm, bond_dev_class.index, bif - bm->interfaces /* device instance */ ,
295  bif->hw_address /* ethernet address */ ,
296  &bif->hw_if_index, 0 /* flag change */ );
297 
298  if (args->error)
299  {
300  args->rv = VNET_API_ERROR_INVALID_REGISTRATION;
301  pool_put (bm->interfaces, bif);
302  return;
303  }
304 
305  sw = vnet_get_hw_sw_interface (vnm, bif->hw_if_index);
306  bif->sw_if_index = sw->sw_if_index;
307  bif->group = bif->sw_if_index;
308  if (vlib_get_thread_main ()->n_vlib_mains > 1)
309  clib_spinlock_init (&bif->lockp);
310 
313 
315 
316  // for return
317  args->sw_if_index = bif->sw_if_index;
318 }
319 
320 static clib_error_t *
322  vlib_cli_command_t * cmd)
323 {
324  unformat_input_t _line_input, *line_input = &_line_input;
325  bond_create_if_args_t args = { 0 };
326  u8 mode_is_set = 0;
327 
328  /* Get a line of input. */
329  if (!unformat_user (input, unformat_line_input, line_input))
330  return clib_error_return (0, "Missing required arguments.");
331 
332  args.mode = -1;
333  args.lb = BOND_LB_L2;
334  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
335  {
336  if (unformat (line_input, "mode %U", unformat_bond_mode, &args.mode))
337  mode_is_set = 1;
338  else if (((args.mode == BOND_MODE_LACP) || (args.mode == BOND_MODE_XOR))
339  && unformat (line_input, "load-balance %U",
341  ;
342  else if (unformat (line_input, "hw-addr %U",
344  args.hw_addr_set = 1;
345  else
346  return clib_error_return (0, "unknown input `%U'",
347  format_unformat_error, input);
348  }
349  unformat_free (line_input);
350 
351  if (mode_is_set == 0)
352  return clib_error_return (0, "Missing bond mode");
353 
354  bond_create_if (vm, &args);
355 
356  return args.error;
357 }
358 
359 /* *INDENT-OFF* */
360 VLIB_CLI_COMMAND (bond_create_command, static) = {
361  .path = "create bond",
362  .short_help = "create bond mode {round-robin | active-backup | broadcast | "
363  "{lacp | xor} [load-balance { l2 | l23 | l34 }]} [hw-addr <mac-address>]",
364  .function = bond_create_command_fn,
365 };
366 /* *INDENT-ON* */
367 
368 static clib_error_t *
370  vlib_cli_command_t * cmd)
371 {
372  unformat_input_t _line_input, *line_input = &_line_input;
373  u32 sw_if_index = ~0;
374  vnet_main_t *vnm = vnet_get_main ();
375  int rv;
376 
377  /* Get a line of input. */
378  if (!unformat_user (input, unformat_line_input, line_input))
379  return clib_error_return (0, "Missing <interface>");
380 
381  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
382  {
383  if (unformat (line_input, "sw_if_index %d", &sw_if_index))
384  ;
385  else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
386  vnm, &sw_if_index))
387  ;
388  else
389  return clib_error_return (0, "unknown input `%U'",
390  format_unformat_error, input);
391  }
392  unformat_free (line_input);
393 
394  if (sw_if_index == ~0)
395  return clib_error_return (0,
396  "please specify interface name or sw_if_index");
397 
398  rv = bond_delete_if (vm, sw_if_index);
399  if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
400  return clib_error_return (0, "not a bond interface");
401  else if (rv != 0)
402  return clib_error_return (0, "error on deleting bond interface");
403 
404  return 0;
405 }
406 
407 /* *INDENT-OFF* */
408 VLIB_CLI_COMMAND (bond_delete__command, static) =
409 {
410  .path = "delete bond",
411  .short_help = "delete bond {<interface> | sw_if_index <sw_idx>}",
412  .function = bond_delete_command_fn,
413 };
414 /* *INDENT-ON* */
415 
416 void
418 {
419  bond_main_t *bm = &bond_main;
420  vnet_main_t *vnm = vnet_get_main ();
421  bond_if_t *bif;
422  slave_if_t *sif;
424  vnet_hw_interface_t *bif_hw, *sif_hw;
426  u32 thread_index;
427  u32 sif_if_index;
428 
430  if (!bif)
431  {
432  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
433  args->error = clib_error_return (0, "bond interface not found");
434  return;
435  }
436  // make sure the interface is not already enslaved
438  {
439  args->rv = VNET_API_ERROR_VALUE_EXIST;
440  args->error = clib_error_return (0, "interface was already enslaved");
441  return;
442  }
443  sif_hw = vnet_get_sup_hw_interface (vnm, args->slave);
444  if (sif_hw->dev_class_index == bond_dev_class.index)
445  {
446  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
447  args->error =
448  clib_error_return (0, "bond interface cannot be enslaved");
449  return;
450  }
451  pool_get (bm->neighbors, sif);
452  memset (sif, 0, sizeof (*sif));
453  sw = pool_elt_at_index (im->sw_interfaces, args->slave);
455  sif->sw_if_index = sw->sw_if_index;
456  sif->hw_if_index = sw->hw_if_index;
457  sif->packet_template_index = (u8) ~ 0;
458  sif->is_passive = args->is_passive;
459  sif->group = args->group;
460  sif->bif_dev_instance = bif->dev_instance;
461  sif->mode = bif->mode;
462 
463  sif->is_long_timeout = args->is_long_timeout;
464  if (args->is_long_timeout)
466  else
468 
471  /*
472  * sif - bm->neighbors may be 0
473  * Left shift it by 1 bit to distinguish the valid entry that we actually
474  * store from the null entries
475  */
477  (uword) (((sif - bm->neighbors) << 1) | 1);
478  vec_add1 (bif->slaves, sif->sw_if_index);
479 
480  sif_hw = vnet_get_sup_hw_interface (vnm, sif->sw_if_index);
481 
482  /* Save the old mac */
483  memcpy (sif->persistent_hw_address, sif_hw->hw_address, 6);
484  bif_hw = vnet_get_sup_hw_interface (vnm, bif->sw_if_index);
485  if (bif->use_custom_mac)
486  {
488  bif->hw_address);
489  }
490  else
491  {
492  // bond interface gets the mac address from the first slave
493  if (vec_len (bif->slaves) == 1)
494  {
495  memcpy (bif->hw_address, sif_hw->hw_address, 6);
497  sif_hw->hw_address);
498  }
499  else
500  {
501  // subsequent slaves gets the mac address of the bond interface
503  bif->hw_address);
504  }
505  }
506 
507  if (bif_hw->l2_if_count)
508  {
509  ethernet_set_flags (vnm, sif_hw->hw_if_index,
511  /* ensure all packets go to ethernet-input */
512  ethernet_set_rx_redirect (vnm, sif_hw, 1);
513  }
514 
515  if (bif->mode == BOND_MODE_LACP)
516  {
517  if (bm->lacp_enable_disable)
518  (*bm->lacp_enable_disable) (vm, bif, sif, 1);
519  }
520  else if (sif->port_enabled &&
522  {
524  }
525 
526  vec_foreach_index (thread_index, bm->per_thread_data)
527  {
529  thread_index);
530 
533 
534  vec_foreach_index (sif_if_index, ptd->per_port_queue)
535  {
536  ptd->per_port_queue[sif_if_index].n_buffers = 0;
537  }
538  }
539 
540  args->rv = vnet_feature_enable_disable ("device-input", "bond-input",
541  sif_hw->hw_if_index, 1, 0, 0);
542 
543  if (args->rv)
544  {
545  args->error =
547  "Error encountered on input feature arc enable");
548  }
549 }
550 
551 static clib_error_t *
553  vlib_cli_command_t * cmd)
554 {
555  bond_enslave_args_t args = { 0 };
556  unformat_input_t _line_input, *line_input = &_line_input;
557  vnet_main_t *vnm = vnet_get_main ();
558 
559  /* Get a line of input. */
560  if (!unformat_user (input, unformat_line_input, line_input))
561  return clib_error_return (0, "Missing required arguments.");
562 
563  args.slave = ~0;
564  args.group = ~0;
565  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
566  {
567  if (unformat (line_input, "%U %U",
568  unformat_vnet_sw_interface, vnm, &args.group,
569  unformat_vnet_sw_interface, vnm, &args.slave))
570  ;
571  else if (unformat (line_input, "passive"))
572  args.is_passive = 1;
573  else if (unformat (line_input, "long-timeout"))
574  args.is_long_timeout = 1;
575  else
576  {
577  args.error = clib_error_return (0, "unknown input `%U'",
578  format_unformat_error, input);
579  break;
580  }
581  }
582  unformat_free (line_input);
583 
584  if (args.error)
585  return args.error;
586  if (args.group == ~0)
587  return clib_error_return (0, "Missing bond interface");
588  if (args.slave == ~0)
589  return clib_error_return (0, "please specify valid slave interface name");
590 
591  bond_enslave (vm, &args);
592 
593  return args.error;
594 }
595 
596 /* *INDENT-OFF* */
597 VLIB_CLI_COMMAND (enslave_interface_command, static) = {
598  .path = "bond add",
599  .short_help = "bond add <BondEthernetx> <slave-interface> "
600  "[passive] [long-timeout]",
601  .function = enslave_interface_command_fn,
602 };
603 /* *INDENT-ON* */
604 
605 void
607 {
608  bond_if_t *bif;
609  slave_if_t *sif;
610 
611  sif = bond_get_slave_by_sw_if_index (args->slave);
612  if (!sif)
613  {
614  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
615  args->error = clib_error_return (0, "interface was not enslaved");
616  return;
617  }
619  bond_delete_neighbor (vm, bif, sif);
620 }
621 
622 static clib_error_t *
624  vlib_cli_command_t * cmd)
625 {
626  bond_detach_slave_args_t args = { 0 };
627  unformat_input_t _line_input, *line_input = &_line_input;
628  vnet_main_t *vnm = vnet_get_main ();
629 
630  /* Get a line of input. */
631  if (!unformat_user (input, unformat_line_input, line_input))
632  return clib_error_return (0, "Missing required arguments.");
633 
634  args.slave = ~0;
635  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
636  {
637  if (unformat (line_input, "%U",
638  unformat_vnet_sw_interface, vnm, &args.slave))
639  ;
640  else
641  {
642  args.error = clib_error_return (0, "unknown input `%U'",
643  format_unformat_error, input);
644  break;
645  }
646  }
647  unformat_free (line_input);
648 
649  if (args.error)
650  return args.error;
651  if (args.slave == ~0)
652  return clib_error_return (0, "please specify valid slave interface name");
653 
654  bond_detach_slave (vm, &args);
655 
656  return args.error;
657 }
658 
659 /* *INDENT-OFF* */
660 VLIB_CLI_COMMAND (detach_interface_command, static) = {
661  .path = "bond del",
662  .short_help = "bond del <slave-interface>",
663  .function = detach_interface_command_fn,
664 };
665 /* *INDENT-ON* */
666 
667 static void
669 {
670  bond_main_t *bm = &bond_main;
671  bond_if_t *bif;
672 
673  vlib_cli_output (vm, "%-16s %-12s %-13s %-13s %-14s %s",
674  "interface name", "sw_if_index", "mode",
675  "load balance", "active slaves", "slaves");
676 
677  /* *INDENT-OFF* */
678  pool_foreach (bif, bm->interfaces,
679  ({
680  vlib_cli_output (vm, "%-16U %-12d %-13U %-13U %-14u %u",
681  format_bond_interface_name, bif->dev_instance,
682  bif->sw_if_index, format_bond_mode, bif->mode,
683  format_bond_load_balance, bif->lb,
684  vec_len (bif->active_slaves), vec_len (bif->slaves));
685  }));
686  /* *INDENT-ON* */
687 }
688 
689 static void
691 {
692  bond_main_t *bm = &bond_main;
693  bond_if_t *bif;
694  u32 *sw_if_index;
695 
696  /* *INDENT-OFF* */
697  pool_foreach (bif, bm->interfaces,
698  ({
699  vlib_cli_output (vm, "%U", format_bond_interface_name, bif->dev_instance);
700  vlib_cli_output (vm, " mode: %U",
701  format_bond_mode, bif->mode);
702  vlib_cli_output (vm, " load balance: %U",
703  format_bond_load_balance, bif->lb);
704  if (bif->mode == BOND_MODE_ROUND_ROBIN)
705  vlib_cli_output (vm, " last xmit slave index: %u",
706  bif->lb_rr_last_index);
707  vlib_cli_output (vm, " number of active slaves: %d",
708  vec_len (bif->active_slaves));
709  vec_foreach (sw_if_index, bif->active_slaves)
710  {
711  vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name,
712  vnet_get_main (), *sw_if_index);
713  }
714  vlib_cli_output (vm, " number of slaves: %d", vec_len (bif->slaves));
715  vec_foreach (sw_if_index, bif->slaves)
716  {
717  vlib_cli_output (vm, " %U", format_vnet_sw_if_index_name,
718  vnet_get_main (), *sw_if_index);
719  }
720  vlib_cli_output (vm, " device instance: %d", bif->dev_instance);
721  vlib_cli_output (vm, " sw_if_index: %d", bif->sw_if_index);
722  vlib_cli_output (vm, " hw_if_index: %d", bif->hw_if_index);
723  }));
724  /* *INDENT-ON* */
725 }
726 
727 static clib_error_t *
729  vlib_cli_command_t * cmd)
730 {
731  u8 details = 0;
732 
734  {
735  if (unformat (input, "details"))
736  details = 1;
737  else
738  {
739  return clib_error_return (0, "unknown input `%U'",
740  format_unformat_error, input);
741  }
742  }
743 
744  if (details)
745  show_bond_details (vm);
746  else
747  show_bond (vm);
748 
749  return 0;
750 }
751 
752 /* *INDENT-OFF* */
753 VLIB_CLI_COMMAND (show_bond_command, static) = {
754  .path = "show bond",
755  .short_help = "show bond [details]",
756  .function = show_bond_fn,
757 };
758 /* *INDENT-ON* */
759 
760 clib_error_t *
762 {
763  bond_main_t *bm = &bond_main;
764 
765  bm->vlib_main = vm;
766  bm->vnet_main = vnet_get_main ();
769  vlib_get_thread_main ()->n_vlib_mains - 1,
771 
772  return 0;
773 }
774 
776 
777 /*
778  * fd.io coding-style-patch-verification: ON
779  *
780  * Local Variables:
781  * eval: (c-set-style "gnu")
782  * End:
783  */
vnet_main_t * vnet_main
Definition: node.h:308
vmrglw vmrglh hi
u32 dev_instance
Definition: node.h:161
u32 group
Definition: node.h:178
#define vec_foreach_index(var, v)
Iterate over vector indices.
u32 hw_if_index
Definition: node.h:162
static uword unformat_bond_mode(unformat_input_t *input, va_list *args)
Definition: node.h:356
#define hash_set(h, key, value)
Definition: hash.h:255
static void bond_delete_neighbor(vlib_main_t *vm, bond_if_t *bif, slave_if_t *sif)
Definition: cli.c:152
static void show_bond_details(vlib_main_t *vm)
Definition: cli.c:690
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
Definition: device.c:767
int bond_delete_if(vlib_main_t *vm, u32 sw_if_index)
Definition: cli.c:193
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:469
#define hash_unset(h, key)
Definition: hash.h:261
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:323
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 lb
Definition: node.h:156
static clib_error_t * detach_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:623
vnet_interface_main_t interface_main
Definition: vnet.h:56
clib_error_t * error
Definition: node.h:87
int bond_dump_ifs(bond_interface_details_t **out_bondifs)
Definition: cli.c:82
static bond_if_t * bond_get_master_by_sw_if_index(u32 sw_if_index)
Definition: node.h:429
#define NULL
Definition: clib.h:57
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:227
u8 is_long_timeout
Definition: node.h:97
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:98
u8 * last_marker_pkt
Definition: node.h:215
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:562
int i
bond_main_t bond_main
Definition: node.c:24
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
lacp_enable_disable_func lacp_enable_disable
Definition: node.h:313
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * enslave_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:552
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:494
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:448
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:228
u8 mode
Definition: node.h:289
void bond_enable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
Definition: cli.c:59
unsigned char u8
Definition: types.h:56
bond_per_thread_data_t * per_thread_data
Definition: node.h:317
double f64
Definition: types.h:142
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
static clib_error_t * show_bond_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:728
memset(h->entries, 0, sizeof(h->entries[0])*entries)
f32 ttl_in_seconds
Definition: node.h:194
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u32 sw_if_index
Definition: vxlan_gbp.api:39
u8 use_custom_mac
Definition: node.h:180
u32 sw_if_index
Definition: node.h:163
uword * active_slave_by_sw_if_index
Definition: node.h:172
void bond_enslave(vlib_main_t *vm, bond_enslave_args_t *args)
Definition: cli.c:417
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_main_t * vlib_main
Definition: node.h:307
unsigned int u32
Definition: types.h:88
#define MIN(x, y)
Definition: node.h:31
unformat_function_t unformat_line_input
Definition: format.h:282
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:57
u8 * last_rx_pkt
Definition: node.h:212
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
Definition: node.c:1202
static clib_error_t * bond_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:321
#define LACP_LONG_TIMOUT_TIME
Definition: node.h:28
#define hash_get(h, key)
Definition: hash.h:249
vnet_device_class_t bond_dev_class
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:464
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:960
struct _unformat_input_t unformat_input_t
static uword unformat_bond_load_balance(unformat_input_t *input, va_list *args)
Definition: node.h:388
u8 persistent_hw_address[6]
Definition: node.h:188
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:274
vnet_sw_interface_flags_t flags
Definition: interface.h:720
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:806
#define LACP_SHORT_TIMOUT_TIME
Definition: node.h:26
static clib_error_t * bond_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:369
bond_if_t * interfaces
Definition: node.h:298
u8 is_long_timeout
Definition: node.h:197
void bond_detach_slave(vlib_main_t *vm, bond_detach_slave_args_t *args)
Definition: cli.c:606
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
u32 * slaves
Definition: node.h:166
u8 is_passive
Definition: node.h:221
u8 mode
Definition: node.h:155
u32 sw_if_index
Definition: node.h:191
vlib_main_t * vm
Definition: buffer.c:294
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:339
uword * bond_by_sw_if_index
Definition: node.h:304
u32 group
Definition: node.h:280
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, u8 *mac_address)
Definition: interface.c:1422
#define clib_memcpy(a, b, c)
Definition: string.h:75
void bond_disable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
Definition: cli.c:25
clib_spinlock_t lockp
Definition: node.h:183
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:159
#define ARRAY_LEN(x)
Definition: clib.h:61
static void show_bond(vlib_main_t *vm)
Definition: cli.c:668
BOND interface details struct.
Definition: node.h:112
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
uword * slave_by_sw_if_index
Definition: node.h:315
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
Definition: format.c:233
void bond_create_if(vlib_main_t *vm, bond_create_if_args_t *args)
Definition: cli.c:241
u8 lacp_plugin_loaded
Definition: node.h:311
static bond_if_t * bond_get_master_by_dev_instance(u32 dev_instance)
Definition: node.h:443
u32 bif_dev_instance
Definition: node.h:284
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:277
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
u32 * active_slaves
Definition: node.h:169
clib_error_t * error
Definition: node.h:100
clib_error_t * error
Definition: node.h:108
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword * port_number_bitmap
Definition: node.h:179
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:162
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:846
int bond_dump_slave_ifs(slave_interface_details_t **out_slaveifs, u32 bond_sw_if_index)
Definition: cli.c:113
slave interface details struct
Definition: node.h:123
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
slave_if_t * neighbors
Definition: node.h:301
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:477
u8 hw_address[6]
Definition: node.h:181
u8 port_enabled
Definition: node.h:235
static slave_if_t * bond_get_slave_by_sw_if_index(u32 sw_if_index)
Definition: node.h:451
lacp_port_info_t actor_admin
Definition: node.h:229
clib_error_t * bond_cli_init(vlib_main_t *vm)
Definition: cli.c:761
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
u8 packet_template_index
Definition: node.h:203
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:82
u32 hw_if_index
Definition: node.h:218
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:233
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
bond_per_port_queue_t * per_port_queue
Definition: node.h:149
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:371