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