FD.io VPP  v21.10.1-2-g0a485f517
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 #include <vpp/stats/stat_segment.h>
24 
25 void
27 {
28  bond_main_t *bm = &bond_main;
29  bond_if_t *bif;
30  int i;
31  uword p;
32  u8 switching_active = 0;
33 
37  {
38  p = *vec_elt_at_index (bif->active_members, i);
39  if (p == mif->sw_if_index)
40  {
41  if ((bif->mode == BOND_MODE_ACTIVE_BACKUP) && (i == 0) &&
42  (vec_len (bif->active_members) > 1))
43  /* deleting the active member for active-backup */
44  switching_active = 1;
45  vec_del1 (bif->active_members, i);
46  if (mif->lacp_enabled && bif->numa_only)
47  {
48  /* For lacp mode, if we check it is a member on local numa node,
49  bif->n_numa_members should be decreased by 1 becasue the first
50  bif->n_numa_members are all members on local numa node */
51  if (i < bif->n_numa_members)
52  {
53  bif->n_numa_members--;
54  ASSERT (bif->n_numa_members >= 0);
55  }
56  }
57  break;
58  }
59  }
60 
61  /* We get a new member just becoming active */
62  if (switching_active)
66 }
67 
68 /*
69  * return 1 if s2 is preferred.
70  * return -1 if s1 is preferred.
71  */
72 static int
73 bond_member_sort (void *a1, void *a2)
74 {
75  u32 *s1 = a1;
76  u32 *s2 = a2;
79  bond_if_t *bif;
80 
81  ALWAYS_ASSERT (mif1);
82  ALWAYS_ASSERT (mif2);
83  /*
84  * sort entries according to preference rules:
85  * 1. biggest weight
86  * 2. numa-node
87  * 3. current active member (to prevent churning)
88  * 4. lowest sw_if_index (for deterministic behavior)
89  *
90  */
91  if (mif2->weight > mif1->weight)
92  return 1;
93  if (mif2->weight < mif1->weight)
94  return -1;
95  else
96  {
97  if (mif2->is_local_numa > mif1->is_local_numa)
98  return 1;
99  if (mif2->is_local_numa < mif1->is_local_numa)
100  return -1;
101  else
102  {
104  /* Favor the current active member to avoid churning */
105  if (bif->active_members[0] == mif2->sw_if_index)
106  return 1;
107  if (bif->active_members[0] == mif1->sw_if_index)
108  return -1;
109  /* go for the tiebreaker as the last resort */
110  if (mif1->sw_if_index > mif2->sw_if_index)
111  return 1;
112  if (mif1->sw_if_index < mif2->sw_if_index)
113  return -1;
114  else
115  ASSERT (0);
116  }
117  }
118  return 0;
119 }
120 
121 static void
123 {
124  bond_main_t *bm = &bond_main;
125  u32 old_active = bif->active_members[0];
126 
128  if (old_active != bif->active_members[0])
131 }
132 
133 void
135 {
136  bond_if_t *bif;
137  bond_main_t *bm = &bond_main;
138  vnet_main_t *vnm = vnet_get_main ();
140  int i;
141  uword p;
142 
146  {
147  p = *vec_elt_at_index (bif->active_members, i);
148  if (p == mif->sw_if_index)
149  goto done;
150  }
151 
152  if (mif->lacp_enabled && bif->numa_only && (vm->numa_node == hw->numa_node))
153  {
155  bif->n_numa_members);
156  bif->n_numa_members++;
157  }
158  else
159  vec_add1 (bif->active_members, mif->sw_if_index);
160 
161  mif->is_local_numa = (vm->numa_node == hw->numa_node) ? 1 : 0;
162  if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
163  {
164  if (vec_len (bif->active_members) == 1)
165  /* First member becomes active? */
168  else
169  bond_sort_members (bif);
170  }
171 
172 done:
174 }
175 
176 int
178 {
179  vnet_main_t *vnm = vnet_get_main ();
180  bond_main_t *bm = &bond_main;
181  bond_if_t *bif;
183  bond_interface_details_t *r_bondifs = NULL;
184  bond_interface_details_t *bondif = NULL;
185 
186  /* *INDENT-OFF* */
187  pool_foreach (bif, bm->interfaces) {
188  vec_add2(r_bondifs, bondif, 1);
189  clib_memset (bondif, 0, sizeof (*bondif));
190  bondif->id = bif->id;
191  bondif->sw_if_index = bif->sw_if_index;
192  hi = vnet_get_hw_interface (vnm, bif->hw_if_index);
193  clib_memcpy(bondif->interface_name, hi->name,
194  MIN (ARRAY_LEN (bondif->interface_name) - 1,
195  vec_len ((const char *) hi->name)));
196  /* enforce by memset() above */
197  ASSERT(0 == bondif->interface_name[ARRAY_LEN (bondif->interface_name) - 1]);
198  bondif->mode = bif->mode;
199  bondif->lb = bif->lb;
200  bondif->numa_only = bif->numa_only;
201  bondif->active_members = vec_len (bif->active_members);
202  bondif->members = vec_len (bif->members);
203  }
204  /* *INDENT-ON* */
205 
206  *out_bondifs = r_bondifs;
207 
208  return 0;
209 }
210 
211 int
213  u32 bond_sw_if_index)
214 {
215  vnet_main_t *vnm = vnet_get_main ();
216  bond_if_t *bif;
219  member_interface_details_t *r_memberifs = NULL;
220  member_interface_details_t *memberif = NULL;
221  u32 *sw_if_index = NULL;
222  member_if_t *mif;
223 
224  bif = bond_get_bond_if_by_sw_if_index (bond_sw_if_index);
225  if (!bif)
226  return 1;
227 
229  {
230  vec_add2 (r_memberifs, memberif, 1);
231  clib_memset (memberif, 0, sizeof (*memberif));
233  if (mif)
234  {
235  sw = vnet_get_sw_interface (vnm, mif->sw_if_index);
236  hi = vnet_get_hw_interface (vnm, sw->hw_if_index);
237  clib_memcpy (memberif->interface_name, hi->name,
238  MIN (ARRAY_LEN (memberif->interface_name) - 1,
239  vec_len ((const char *) hi->name)));
240  /* enforce by memset() above */
241  ASSERT (0 ==
242  memberif->interface_name[ARRAY_LEN (memberif->interface_name)
243  - 1]);
244  memberif->sw_if_index = mif->sw_if_index;
245  memberif->is_passive = mif->is_passive;
246  memberif->is_long_timeout = mif->is_long_timeout;
247  memberif->is_local_numa = mif->is_local_numa;
248  memberif->weight = mif->weight;
249  }
250  }
251  *out_memberifs = r_memberifs;
252 
253  return 0;
254 }
255 
256 /*
257  * Manage secondary mac addresses when attaching/detaching a member.
258  * If adding, copy any secondary addresses from bond interface to member.
259  * If deleting, delete the bond interface's secondary addresses from the
260  * member.
261  */
262 static void
264  u8 is_add)
265 {
266  vnet_main_t *vnm = vnet_get_main ();
267  ethernet_interface_t *b_ei;
269  vnet_hw_interface_t *s_hwif;
270 
272  if (!b_ei || !b_ei->secondary_addrs)
273  return;
274 
275  s_hwif = vnet_get_sup_hw_interface (vnm, mif_sw_if_index);
276 
277  vec_foreach (sec_mac, b_ei->secondary_addrs)
279  sec_mac->mac.bytes, is_add);
280 }
281 
282 static void
284 {
285  bond_main_t *bm = &bond_main;
286  vnet_main_t *vnm = vnet_get_main ();
287  int i;
288  vnet_hw_interface_t *mif_hw;
289 
290  mif_hw = vnet_get_sup_hw_interface (vnm, mif->sw_if_index);
291 
292  bif->port_number_bitmap =
294  ntohs (mif->actor_admin.port_number) - 1, 0);
295  bm->member_by_sw_if_index[mif->sw_if_index] = 0;
296  vec_free (mif->last_marker_pkt);
297  vec_free (mif->last_rx_pkt);
298  vec_foreach_index (i, bif->members)
299  {
300  uword p = *vec_elt_at_index (bif->members, i);
301  if (p == mif->sw_if_index)
302  {
303  vec_del1 (bif->members, i);
304  break;
305  }
306  }
307 
309 
310  vnet_feature_enable_disable ("device-input", "bond-input",
311  mif->sw_if_index, 0, 0, 0);
312 
313  /* Put back the old mac */
315  mif->persistent_hw_address);
316 
317  /* delete the bond's secondary/virtual mac addrs from the member */
318  bond_member_add_del_mac_addrs (bif, mif->sw_if_index, 0 /* is_add */ );
319 
320 
321  if ((bif->mode == BOND_MODE_LACP) && bm->lacp_enable_disable)
322  (*bm->lacp_enable_disable) (vm, bif, mif, 0);
323 
324  if (bif->mode == BOND_MODE_LACP)
325  {
327  (bm->stats[bif->sw_if_index][mif->sw_if_index].actor_state);
329  (bm->stats[bif->sw_if_index][mif->sw_if_index].partner_state);
330  }
331 
332  pool_put (bm->neighbors, mif);
333 }
334 
335 int
337 {
338  bond_main_t *bm = &bond_main;
339  vnet_main_t *vnm = vnet_get_main ();
340  bond_if_t *bif;
341  member_if_t *mif;
343  u32 *mif_sw_if_index;
344  u32 *s_list = 0;
345 
347  if (hw == NULL || bond_dev_class.index != hw->dev_class_index)
348  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
349 
351 
352  vec_append (s_list, bif->members);
353  vec_foreach (mif_sw_if_index, s_list)
354  {
355  mif = bond_get_member_by_sw_if_index (*mif_sw_if_index);
356  if (mif)
357  bond_delete_neighbor (vm, bif, mif);
358  }
359  vec_free (s_list);
360 
361  /* bring down the interface */
364 
366 
369  hash_unset (bm->id_used, bif->id);
370  clib_memset (bif, 0, sizeof (*bif));
371  pool_put (bm->interfaces, bif);
372 
373  return 0;
374 }
375 
376 void
378 {
379  bond_main_t *bm = &bond_main;
380  vnet_main_t *vnm = vnet_get_main ();
382  bond_if_t *bif;
384 
385  if ((args->mode == BOND_MODE_LACP) && bm->lacp_plugin_loaded == 0)
386  {
387  args->rv = VNET_API_ERROR_FEATURE_DISABLED;
388  args->error = clib_error_return (0, "LACP plugin is not loaded");
389  return;
390  }
391  if (args->mode > BOND_MODE_LACP || args->mode < BOND_MODE_ROUND_ROBIN)
392  {
393  args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
394  args->error = clib_error_return (0, "Invalid mode");
395  return;
396  }
397  if (args->lb > BOND_LB_L23)
398  {
399  args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
400  args->error = clib_error_return (0, "Invalid load-balance");
401  return;
402  }
403  pool_get (bm->interfaces, bif);
404  clib_memset (bif, 0, sizeof (*bif));
405  bif->dev_instance = bif - bm->interfaces;
406  bif->id = args->id;
407  bif->lb = args->lb;
408  bif->mode = args->mode;
409  bif->gso = args->gso;
410 
411  // Adjust requested interface id
412  if (bif->id == ~0)
413  bif->id = bif->dev_instance;
414  if (hash_get (bm->id_used, bif->id))
415  {
416  args->rv = VNET_API_ERROR_INSTANCE_IN_USE;
417  pool_put (bm->interfaces, bif);
418  return;
419  }
420  hash_set (bm->id_used, bif->id, 1);
421 
422  // Special load-balance mode used for rr and bc
423  if (bif->mode == BOND_MODE_ROUND_ROBIN)
424  bif->lb = BOND_LB_RR;
425  else if (bif->mode == BOND_MODE_BROADCAST)
426  bif->lb = BOND_LB_BC;
427  else if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
428  bif->lb = BOND_LB_AB;
429 
430  bif->use_custom_mac = args->hw_addr_set;
431  if (!args->hw_addr_set)
432  {
433  f64 now = vlib_time_now (vm);
434  u32 rnd;
435  rnd = (u32) (now * 1e6);
436  rnd = random_u32 (&rnd);
437 
438  memcpy (args->hw_addr + 2, &rnd, sizeof (rnd));
439  args->hw_addr[0] = 2;
440  args->hw_addr[1] = 0xfe;
441  }
442  memcpy (bif->hw_address, args->hw_addr, 6);
444  (vnm, bond_dev_class.index, bif->dev_instance /* device instance */ ,
445  bif->hw_address /* ethernet address */ ,
446  &bif->hw_if_index, 0 /* flag change */ );
447 
448  if (args->error)
449  {
450  args->rv = VNET_API_ERROR_INVALID_REGISTRATION;
451  hash_unset (bm->id_used, bif->id);
452  pool_put (bm->interfaces, bif);
453  return;
454  }
455 
456  sw = vnet_get_hw_sw_interface (vnm, bif->hw_if_index);
457  bif->sw_if_index = sw->sw_if_index;
458  bif->group = bif->sw_if_index;
459  bif->numa_only = args->numa_only;
460 
461  hw = vnet_get_hw_interface (vnm, bif->hw_if_index);
462  /*
463  * Add GSO and Checksum offload flags if GSO is enabled on Bond
464  */
465  if (args->gso)
466  {
470  }
472  clib_spinlock_init (&bif->lockp);
473 
476 
478 
479  // for return
480  args->sw_if_index = bif->sw_if_index;
481  args->rv = 0;
482 }
483 
484 static clib_error_t *
486  vlib_cli_command_t * cmd)
487 {
488  unformat_input_t _line_input, *line_input = &_line_input;
489  bond_create_if_args_t args = { 0 };
490  u8 mode_is_set = 0;
491 
492  /* Get a line of input. */
493  if (!unformat_user (input, unformat_line_input, line_input))
494  return clib_error_return (0, "Missing required arguments.");
495 
496  args.id = ~0;
497  args.mode = -1;
498  args.lb = BOND_LB_L2;
499  args.rv = -1;
500  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
501  {
502  if (unformat (line_input, "mode %U", unformat_bond_mode, &args.mode))
503  mode_is_set = 1;
504  else if (((args.mode == BOND_MODE_LACP) || (args.mode == BOND_MODE_XOR))
505  && unformat (line_input, "load-balance %U",
507  ;
508  else if (unformat (line_input, "hw-addr %U",
510  args.hw_addr_set = 1;
511  else if (unformat (line_input, "id %u", &args.id))
512  ;
513  else if (unformat (line_input, "gso"))
514  args.gso = 1;
515  else if (unformat (line_input, "numa-only"))
516  {
517  if (args.mode == BOND_MODE_LACP)
518  args.numa_only = 1;
519  else
520  return clib_error_return (0,
521  "Only lacp mode supports numa-only so far!");
522  }
523  else
524  return clib_error_return (0, "unknown input `%U'",
525  format_unformat_error, input);
526  }
527  unformat_free (line_input);
528 
529  if (mode_is_set == 0)
530  return clib_error_return (0, "Missing bond mode");
531 
532  bond_create_if (vm, &args);
533 
534  if (!args.rv)
536  vnet_get_main (), args.sw_if_index);
537 
538  return args.error;
539 }
540 
541 /* *INDENT-OFF* */
543  .path = "create bond",
544  .short_help = "create bond mode {round-robin | active-backup | broadcast | "
545  "{lacp | xor} [load-balance { l2 | l23 | l34 } [numa-only]]} "
546  "[hw-addr <mac-address>] [id <if-id>] [gso]",
547  .function = bond_create_command_fn,
548 };
549 /* *INDENT-ON* */
550 
551 static clib_error_t *
553  vlib_cli_command_t * cmd)
554 {
555  unformat_input_t _line_input, *line_input = &_line_input;
556  u32 sw_if_index = ~0;
557  vnet_main_t *vnm = vnet_get_main ();
558  int rv;
559 
560  /* Get a line of input. */
561  if (!unformat_user (input, unformat_line_input, line_input))
562  return clib_error_return (0, "Missing <interface>");
563 
564  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
565  {
566  if (unformat (line_input, "sw_if_index %d", &sw_if_index))
567  ;
568  else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
569  vnm, &sw_if_index))
570  ;
571  else
572  return clib_error_return (0, "unknown input `%U'",
573  format_unformat_error, input);
574  }
575  unformat_free (line_input);
576 
577  if (sw_if_index == ~0)
578  return clib_error_return (0,
579  "please specify interface name or sw_if_index");
580 
582  if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
583  return clib_error_return (0, "not a bond interface");
584  else if (rv != 0)
585  return clib_error_return (0, "error on deleting bond interface");
586 
587  return 0;
588 }
589 
590 /* *INDENT-OFF* */
592 {
593  .path = "delete bond",
594  .short_help = "delete bond {<interface> | sw_if_index <sw_idx>}",
595  .function = bond_delete_command_fn,
596 };
597 /* *INDENT-ON* */
598 
599 void
601 {
602  bond_main_t *bm = &bond_main;
603  vnet_main_t *vnm = vnet_get_main ();
604  bond_if_t *bif;
605  member_if_t *mif;
607  vnet_hw_interface_t *bif_hw, *mif_hw;
610  u32 mif_if_index;
611 
613  if (!bif)
614  {
615  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
616  args->error = clib_error_return (0, "bond interface not found");
617  return;
618  }
619  // make sure the interface is not already added as member
621  {
622  args->rv = VNET_API_ERROR_VALUE_EXIST;
623  args->error = clib_error_return
624  (0, "interface was already added as member");
625  return;
626  }
627  mif_hw = vnet_get_sup_hw_interface (vnm, args->member);
628  if (mif_hw->dev_class_index == bond_dev_class.index)
629  {
630  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
631  args->error =
632  clib_error_return (0, "bond interface cannot be added as member");
633  return;
634  }
635  if (bif->gso && !(mif_hw->caps & VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO))
636  {
637  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
638  args->error =
639  clib_error_return (0, "member interface is not gso capable");
640  return;
641  }
642  if (bif->mode == BOND_MODE_LACP)
643  {
644  u8 *name = format (0, "/if/lacp/%u/%u/state%c", bif->sw_if_index,
645  args->member, 0);
646 
647  vec_validate (bm->stats, bif->sw_if_index);
648  vec_validate (bm->stats[bif->sw_if_index], args->member);
649 
651  (name, &bm->stats[bif->sw_if_index][args->member].actor_state);
652  if (args->error != 0)
653  {
654  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
655  vec_free (name);
656  return;
657  }
658 
660  name = format (0, "/if/lacp/%u/%u/partner-state%c", bif->sw_if_index,
661  args->member, 0);
663  (name, &bm->stats[bif->sw_if_index][args->member].partner_state);
664  vec_free (name);
665  if (args->error != 0)
666  {
667  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
668  return;
669  }
670  }
671 
672  pool_get (bm->neighbors, mif);
673  clib_memset (mif, 0, sizeof (*mif));
674  sw = pool_elt_at_index (im->sw_interfaces, args->member);
675  /* port_enabled is both admin up and hw link up */
677  mif->sw_if_index = sw->sw_if_index;
678  mif->hw_if_index = sw->hw_if_index;
679  mif->packet_template_index = (u8) ~ 0;
680  mif->is_passive = args->is_passive;
681  mif->group = args->group;
682  mif->bif_dev_instance = bif->dev_instance;
683  mif->mode = bif->mode;
684 
685  mif->is_long_timeout = args->is_long_timeout;
686  if (args->is_long_timeout)
688  else
690 
693  /*
694  * mif - bm->neighbors may be 0
695  * Left shift it by 1 bit to distinguish the valid entry that we actually
696  * store from the null entries
697  */
699  (uword) (((mif - bm->neighbors) << 1) | 1);
700  vec_add1 (bif->members, mif->sw_if_index);
701 
702  mif_hw = vnet_get_sup_hw_interface (vnm, mif->sw_if_index);
703 
704  /* Save the old mac */
705  memcpy (mif->persistent_hw_address, mif_hw->hw_address, 6);
706  bif_hw = vnet_get_sup_hw_interface (vnm, bif->sw_if_index);
707  if (bif->use_custom_mac)
708  {
710  bif->hw_address);
711  }
712  else
713  {
714  // bond interface gets the mac address from the first member
715  if (vec_len (bif->members) == 1)
716  {
717  memcpy (bif->hw_address, mif_hw->hw_address, 6);
719  mif_hw->hw_address);
720  }
721  else
722  {
723  // subsequent members gets the mac address of the bond interface
725  bif->hw_address);
726  }
727  }
728 
729  /* if there are secondary/virtual mac addrs, propagate to the member */
730  bond_member_add_del_mac_addrs (bif, mif->sw_if_index, 1 /* is_add */ );
731 
732  if (bif_hw->l2_if_count)
733  ethernet_set_flags (vnm, mif_hw->hw_if_index,
735  else
736  ethernet_set_flags (vnm, mif_hw->hw_if_index,
737  /*ETHERNET_INTERFACE_FLAG_DEFAULT_L3 */ 0);
738 
739  if (bif->mode == BOND_MODE_LACP)
740  {
741  if (bm->lacp_enable_disable)
742  (*bm->lacp_enable_disable) (vm, bif, mif, 1);
743  }
744  else if (mif->port_enabled)
745  {
747  }
748 
750  {
752  thread_index);
753 
756 
757  vec_foreach_index (mif_if_index, ptd->per_port_queue)
758  {
759  ptd->per_port_queue[mif_if_index].n_buffers = 0;
760  }
761  }
762 
763  args->rv = vnet_feature_enable_disable ("device-input", "bond-input",
764  mif->sw_if_index, 1, 0, 0);
765 
766  if (args->rv)
767  {
768  args->error =
770  "Error encountered on input feature arc enable");
771  }
772 }
773 
774 static clib_error_t *
776  vlib_cli_command_t * cmd)
777 {
778  bond_add_member_args_t args = { 0 };
779  unformat_input_t _line_input, *line_input = &_line_input;
780  vnet_main_t *vnm = vnet_get_main ();
781 
782  /* Get a line of input. */
783  if (!unformat_user (input, unformat_line_input, line_input))
784  return clib_error_return (0, "Missing required arguments.");
785 
786  args.member = ~0;
787  args.group = ~0;
788  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
789  {
790  if (unformat (line_input, "%U %U",
791  unformat_vnet_sw_interface, vnm, &args.group,
792  unformat_vnet_sw_interface, vnm, &args.member))
793  ;
794  else if (unformat (line_input, "passive"))
795  args.is_passive = 1;
796  else if (unformat (line_input, "long-timeout"))
797  args.is_long_timeout = 1;
798  else
799  {
800  args.error = clib_error_return (0, "unknown input `%U'",
801  format_unformat_error, input);
802  break;
803  }
804  }
805  unformat_free (line_input);
806 
807  if (args.error)
808  return args.error;
809  if (args.group == ~0)
810  return clib_error_return (0, "Missing bond interface");
811  if (args.member == ~0)
812  return clib_error_return (0,
813  "please specify valid member interface name");
814 
815  bond_add_member (vm, &args);
816 
817  return args.error;
818 }
819 
820 /* *INDENT-OFF* */
822  .path = "bond add",
823  .short_help = "bond add <BondEthernetx> <member-interface> "
824  "[passive] [long-timeout]",
826 };
827 /* *INDENT-ON* */
828 
829 void
831 {
832  bond_if_t *bif;
833  member_if_t *mif;
834 
836  if (!mif)
837  {
838  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
839  args->error = clib_error_return (0, "interface was not a member");
840  return;
841  }
843  bond_delete_neighbor (vm, bif, mif);
844 }
845 
846 static clib_error_t *
848  vlib_cli_command_t * cmd)
849 {
850  bond_detach_member_args_t args = { 0 };
851  unformat_input_t _line_input, *line_input = &_line_input;
852  vnet_main_t *vnm = vnet_get_main ();
853 
854  /* Get a line of input. */
855  if (!unformat_user (input, unformat_line_input, line_input))
856  return clib_error_return (0, "Missing required arguments.");
857 
858  args.member = ~0;
859  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
860  {
861  if (unformat (line_input, "%U",
862  unformat_vnet_sw_interface, vnm, &args.member))
863  ;
864  else
865  {
866  args.error = clib_error_return (0, "unknown input `%U'",
867  format_unformat_error, input);
868  break;
869  }
870  }
871  unformat_free (line_input);
872 
873  if (args.error)
874  return args.error;
875  if (args.member == ~0)
876  return clib_error_return (0,
877  "please specify valid member interface name");
878 
879  bond_detach_member (vm, &args);
880 
881  return args.error;
882 }
883 
884 /* *INDENT-OFF* */
886  .path = "bond del",
887  .short_help = "bond del <member-interface>",
888  .function = detach_interface_command_fn,
889 };
890 /* *INDENT-ON* */
891 
892 static void
894 {
895  bond_main_t *bm = &bond_main;
896  bond_if_t *bif;
897 
898  vlib_cli_output (vm, "%-16s %-12s %-13s %-13s %-14s %s",
899  "interface name", "sw_if_index", "mode",
900  "load balance", "active members", "members");
901 
902  /* *INDENT-OFF* */
903  pool_foreach (bif, bm->interfaces)
904  {
905  vlib_cli_output (vm, "%-16U %-12d %-13U %-13U %-14u %u",
907  bif->sw_if_index, format_bond_mode, bif->mode,
909  vec_len (bif->active_members), vec_len (bif->members));
910  }
911  /* *INDENT-ON* */
912 }
913 
914 static void
916 {
917  bond_main_t *bm = &bond_main;
918  bond_if_t *bif;
919  u32 *sw_if_index;
920 
921  /* *INDENT-OFF* */
922  pool_foreach (bif, bm->interfaces)
923  {
925  vlib_cli_output (vm, " mode: %U",
926  format_bond_mode, bif->mode);
927  vlib_cli_output (vm, " load balance: %U",
929  if (bif->gso)
930  vlib_cli_output (vm, " gso enable");
931  if (bif->mode == BOND_MODE_ROUND_ROBIN)
932  vlib_cli_output (vm, " last xmit member index: %u",
933  bif->lb_rr_last_index);
934  vlib_cli_output (vm, " number of active members: %d",
935  vec_len (bif->active_members));
937  {
940  if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
941  {
943  if (mif)
944  vlib_cli_output (vm, " weight: %u, is_local_numa: %u, "
945  "sw_if_index: %u", mif->weight,
946  mif->is_local_numa, mif->sw_if_index);
947  }
948  }
949  vlib_cli_output (vm, " number of members: %d", vec_len (bif->members));
951  {
954  }
955  vlib_cli_output (vm, " device instance: %d", bif->dev_instance);
956  vlib_cli_output (vm, " interface id: %d", bif->id);
957  vlib_cli_output (vm, " sw_if_index: %d", bif->sw_if_index);
958  vlib_cli_output (vm, " hw_if_index: %d", bif->hw_if_index);
959  }
960  /* *INDENT-ON* */
961 }
962 
963 static clib_error_t *
965  vlib_cli_command_t * cmd)
966 {
967  u8 details = 0;
968 
970  {
971  if (unformat (input, "details"))
972  details = 1;
973  else
974  {
975  return clib_error_return (0, "unknown input `%U'",
976  format_unformat_error, input);
977  }
978  }
979 
980  if (details)
982  else
983  show_bond (vm);
984 
985  return 0;
986 }
987 
988 /* *INDENT-OFF* */
990  .path = "show bond",
991  .short_help = "show bond [details]",
992  .function = show_bond_fn,
993 };
994 /* *INDENT-ON* */
995 
996 void
998 {
999  member_if_t *mif;
1000  bond_if_t *bif;
1001  vnet_main_t *vnm;
1002  u32 old_weight;
1003 
1005  if (!mif)
1006  {
1007  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
1008  args->error = clib_error_return (0, "Interface not a member");
1009  return;
1010  }
1012  if (!bif)
1013  {
1014  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
1015  args->error = clib_error_return (0, "bond interface not found");
1016  return;
1017  }
1018  if (bif->mode != BOND_MODE_ACTIVE_BACKUP)
1019  {
1020  args->rv = VNET_API_ERROR_INVALID_ARGUMENT;
1021  args->error =
1022  clib_error_return (0, "Weight valid for active-backup only");
1023  return;
1024  }
1025 
1026  old_weight = mif->weight;
1027  mif->weight = args->weight;
1028  vnm = vnet_get_main ();
1029  /*
1030  * No need to sort the list if the affected member is not up (not in active
1031  * member set), active member count is 1, or the current member is already the
1032  * primary member and new weight > old weight.
1033  */
1034  if (!vnet_sw_interface_is_up (vnm, mif->sw_if_index) ||
1035  (vec_len (bif->active_members) == 1) ||
1036  ((bif->active_members[0] == mif->sw_if_index) &&
1037  (mif->weight >= old_weight)))
1038  return;
1039 
1040  bond_sort_members (bif);
1041 }
1042 
1043 static clib_error_t *
1045  vlib_cli_command_t * cmd)
1046 {
1047  bond_set_intf_weight_args_t args = { 0 };
1048  u32 sw_if_index = (u32) ~ 0;
1049  unformat_input_t _line_input, *line_input = &_line_input;
1050  vnet_main_t *vnm = vnet_get_main ();
1051  u8 weight_enter = 0;
1052  u32 weight = 0;
1053 
1054  /* Get a line of input. */
1055  if (!unformat_user (input, unformat_line_input, line_input))
1056  return clib_error_return (0, "Missing required arguments.");
1057 
1058  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1059  {
1060  if (unformat (line_input, "sw_if_index %d", &sw_if_index))
1061  ;
1062  else if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
1063  &sw_if_index))
1064  ;
1065  else if (unformat (line_input, "weight %u", &weight))
1066  weight_enter = 1;
1067  else
1068  {
1069  clib_error_return (0, "unknown input `%U'", format_unformat_error,
1070  input);
1071  break;
1072  }
1073  }
1074 
1075  unformat_free (line_input);
1076  if (sw_if_index == (u32) ~ 0)
1077  {
1078  args.rv = VNET_API_ERROR_INVALID_INTERFACE;
1079  clib_error_return (0, "Interface name is invalid!");
1080  }
1081  if (weight_enter == 0)
1082  {
1083  args.rv = VNET_API_ERROR_INVALID_ARGUMENT;
1084  clib_error_return (0, "weight missing");
1085  }
1086 
1087  args.sw_if_index = sw_if_index;
1088  args.weight = weight;
1089  bond_set_intf_weight (vm, &args);
1090 
1091  return args.error;
1092 }
1093 
1094 /* *INDENT-OFF* */
1096  .path = "set interface bond",
1097  .short_help = "set interface bond <interface> | sw_if_index <idx>"
1098  " weight <value>",
1099  .function = bond_set_intf_cmd,
1100 };
1101 /* *INDENT-ON* */
1102 
1103 clib_error_t *
1105 {
1106  bond_main_t *bm = &bond_main;
1107 
1108  bm->vlib_main = vm;
1109  bm->vnet_main = vnet_get_main ();
1112  vlib_get_thread_main ()->n_vlib_mains - 1,
1114 
1115  return 0;
1116 }
1117 
1119 
1120 /*
1121  * fd.io coding-style-patch-verification: ON
1122  *
1123  * Local Variables:
1124  * eval: (c-set-style "gnu")
1125  * End:
1126  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
bond_disable_collecting_distributing
void bond_disable_collecting_distributing(vlib_main_t *vm, member_if_t *mif)
Definition: cli.c:26
member_interface_details_t::is_local_numa
u8 is_local_numa
Definition: node.h:143
stat_segment_register_state_counter
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
Definition: stat_segment.c:922
vlib.h
bond_delete__command
static vlib_cli_command_t bond_delete__command
(constructor) VLIB_CLI_COMMAND (bond_delete__command)
Definition: cli.c:591
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
bond_main_t::stats
lacp_stats_t ** stats
Definition: node.h:388
bond_create_if
void bond_create_if(vlib_main_t *vm, bond_create_if_args_t *args)
Definition: cli.c:377
im
vnet_interface_main_t * im
Definition: interface_output.c:415
unformat_ethernet_address
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
Definition: format.c:233
member_interface_details_t::is_long_timeout
u8 is_long_timeout
Definition: node.h:142
weight
u8 weight
Definition: fib_types.api:120
bond_main_t::member_by_sw_if_index
uword * member_by_sw_if_index
Definition: node.h:384
bond_main_t::id_used
uword * id_used
Definition: node.h:367
vnet_sw_interface_set_flags
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:523
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
vnet_sw_interface_t
Definition: interface.h:869
vnet_hw_interface_t::caps
vnet_hw_interface_capabilities_t caps
Definition: interface.h:645
bond_set_intf_weight_args_t::weight
u32 weight
Definition: node.h:117
show_bond
static void show_bond(vlib_main_t *vm)
Definition: cli.c:893
unformat_bond_mode
static uword unformat_bond_mode(unformat_input_t *input, va_list *args)
Definition: node.h:430
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
bond_if_t::group
u32 group
Definition: node.h:205
bond_get_bond_if_by_dev_instance
static bond_if_t * bond_get_bond_if_by_dev_instance(u32 dev_instance)
Definition: node.h:517
bond_add_member_args_t::group
u32 group
Definition: node.h:98
clib_spinlock_lock_if_init
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:106
ethernet_set_flags
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:441
bond_sort_members
static void bond_sort_members(bond_if_t *bif)
Definition: cli.c:122
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
bond_add_member_args_t::member
u32 member
Definition: node.h:96
bond_create_if_args_t::sw_if_index
u32 sw_if_index
Definition: node.h:88
name
string name[64]
Definition: fib.api:25
vec_insert_elts
#define vec_insert_elts(V, E, N, M)
Insert N vector elements starting at element M, insert given elements (no header, unspecified alignme...
Definition: vec.h:854
bond_per_thread_data_t::per_port_queue
bond_per_port_queue_t * per_port_queue
Definition: node.h:165
vnet_hw_interface_t::hw_address
u8 * hw_address
Definition: interface.h:649
bond_interface_details_t::members
u32 members
Definition: node.h:133
bond_main
bond_main_t bond_main
Definition: node.c:25
format_bond_interface_name
u8 * format_bond_interface_name(u8 *s, va_list *args)
Definition: device.c:72
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
bond_if_t::id
u32 id
Definition: node.h:181
u8
#define u8
Padding.
Definition: clib.h:121
vlib_cli_command_t::path
char * path
Definition: cli.h:96
vnet_interface_main_t
Definition: interface.h:990
bond_delete_if
int bond_delete_if(vlib_main_t *vm, u32 sw_if_index)
Definition: cli.c:336
lacp_stats_t::partner_state
u32 partner_state
Definition: node.h:357
vec_append
#define vec_append(v1, v2)
Append v2 after v1.
Definition: vec.h:911
bond_member_sort
static int bond_member_sort(void *a1, void *a2)
Definition: cli.c:73
bond_main_t::lacp_enable_disable
lacp_enable_disable_func lacp_enable_disable
Definition: node.h:382
member_if_t::ttl_in_seconds
f32 ttl_in_seconds
Definition: node.h:221
bond_interface_details_t::sw_if_index
u32 sw_if_index
Definition: node.h:126
add_member_interface_command
static vlib_cli_command_t add_member_interface_command
(constructor) VLIB_CLI_COMMAND (add_member_interface_command)
Definition: cli.c:821
bond_if_t::mode
u8 mode
Definition: node.h:171
vnet_hw_interface_t::l2_if_count
u32 l2_if_count
Definition: interface.h:706
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
bond_if_t::use_custom_mac
u8 use_custom_mac
Definition: node.h:207
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
bond_create_if_args_t
Definition: node.h:78
vnet_get_sw_interface
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:58
bond_get_bond_if_by_sw_if_index
static bond_if_t * bond_get_bond_if_by_sw_if_index(u32 sw_if_index)
Definition: node.h:503
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
detach_interface_command
static vlib_cli_command_t detach_interface_command
(constructor) VLIB_CLI_COMMAND (detach_interface_command)
Definition: cli.c:885
bond_cli_init
clib_error_t * bond_cli_init(vlib_main_t *vm)
Definition: cli.c:1104
member_interface_details_t
member interface details struct
Definition: node.h:137
member_if_t::persistent_hw_address
u8 persistent_hw_address[6]
Definition: node.h:215
bond_main_t::vnet_main
vnet_main_t * vnet_main
Definition: node.h:377
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
unformat_input_t
struct _unformat_input_t unformat_input_t
vnet_hw_interface_t::dev_instance
u32 dev_instance
Definition: interface.h:660
bond_if_t
Definition: node.h:168
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
bond_delete_neighbor
static void bond_delete_neighbor(vlib_main_t *vm, bond_if_t *bif, member_if_t *mif)
Definition: cli.c:283
bond_add_member_args_t::is_passive
u8 is_passive
Definition: node.h:99
ethernet.h
member_if_t::last_rx_pkt
u8 * last_rx_pkt
Definition: node.h:239
bond_main_t::interfaces
bond_if_t * interfaces
Definition: node.h:364
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
member_if_t::is_local_numa
u8 is_local_numa
Definition: node.h:349
random_u32
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
Definition: interface.h:524
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
LACP_LONG_TIMOUT_TIME
#define LACP_LONG_TIMOUT_TIME
Definition: node.h:28
vnet_sw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:876
bond_interface_details_t::interface_name
u8 interface_name[64]
Definition: node.h:128
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
bond_set_intf_weight
void bond_set_intf_weight(vlib_main_t *vm, bond_set_intf_weight_args_t *args)
Definition: cli.c:997
bond_add_member_args_t
Definition: node.h:93
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
ethernet_interface_address
Definition: ethernet.h:135
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
bond_create_command
static vlib_cli_command_t bond_create_command
(constructor) VLIB_CLI_COMMAND (bond_create_command)
Definition: cli.c:542
unformat_bond_load_balance
static uword unformat_bond_load_balance(unformat_input_t *input, va_list *args)
Definition: node.h:462
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vnet_hw_interface_change_mac_address
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address)
Definition: interface.c:1629
bond_if_t::port_number_bitmap
uword * port_number_bitmap
Definition: node.h:206
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
LACP_SHORT_TIMOUT_TIME
#define LACP_SHORT_TIMOUT_TIME
Definition: node.h:26
bond_if_t::members
u32 * members
Definition: node.h:187
VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
Definition: interface.h:537
hash_get
#define hash_get(h, key)
Definition: hash.h:249
MIN
#define MIN(x, y)
Definition: node.h:31
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
bond_interface_details_t::numa_only
u8 numa_only
Definition: node.h:131
bond_detach_member
void bond_detach_member(vlib_main_t *vm, bond_detach_member_args_t *args)
Definition: cli.c:830
bond_dev_class
vnet_device_class_t bond_dev_class
bond_if_t::lb
u8 lb
Definition: node.h:172
bond_add_member_args_t::rv
int rv
Definition: node.h:102
lacp_stats_t::actor_state
u32 actor_state
Definition: node.h:358
bond_create_if_args_t::gso
u8 gso
Definition: node.h:86
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
clib_bitmap_free
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
uword
u64 uword
Definition: types.h:112
bond_detach_member_args_t::rv
int rv
Definition: node.h:110
vnet_hw_interface_t::dev_class_index
u32 dev_class_index
Definition: interface.h:659
member_if_t::hw_if_index
u32 hw_if_index
Definition: node.h:245
bond_delete_command_fn
static clib_error_t * bond_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:552
bond_per_thread_data_t
Definition: node.h:163
ethernet_interface
Definition: ethernet.h:146
bond_main_t::neighbors
member_if_t * neighbors
Definition: node.h:370
member_if_t::actor_admin
lacp_port_info_t actor_admin
Definition: node.h:259
member_if_t::weight
u32 weight
Definition: node.h:248
node.h
f64
double f64
Definition: types.h:142
bond_create_if_args_t::hw_addr_set
u8 hw_addr_set
Definition: node.h:81
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
set_interface_bond_cmd
static vlib_cli_command_t set_interface_bond_cmd
(constructor) VLIB_CLI_COMMAND (set_interface_bond_cmd)
Definition: cli.c:1095
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
mac_address_t_::bytes
u8 bytes[6]
Definition: mac_address.h:25
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
bond_member_add_del_mac_addrs
static void bond_member_add_del_mac_addrs(bond_if_t *bif, u32 mif_sw_if_index, u8 is_add)
Definition: cli.c:263
bond_create_if_args_t::rv
int rv
Definition: node.h:89
bond_set_intf_weight_args_t::error
clib_error_t * error
Definition: node.h:120
ALWAYS_ASSERT
#define ALWAYS_ASSERT(truth)
Definition: error_bootstrap.h:89
clib_bitmap_set
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
member_if_t::sw_if_index
u32 sw_if_index
Definition: node.h:218
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
member_interface_details_t::weight
u32 weight
Definition: node.h:144
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1015
stat_segment.h
ethernet_get_interface
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:982
bond_interface_details_t::mode
u32 mode
Definition: node.h:129
vnet_hw_interface_t::numa_node
u8 numa_node
Definition: interface.h:732
bond_if_t::numa_only
u8 numa_only
Definition: node.h:199
vlib_main_t::numa_node
u32 numa_node
Definition: main.h:217
show_bond_command
static vlib_cli_command_t show_bond_command
(constructor) VLIB_CLI_COMMAND (show_bond_command)
Definition: cli.c:989
ethernet_interface_address::mac
mac_address_t mac
Definition: ethernet.h:139
member_if_t::port_enabled
u8 port_enabled
Definition: node.h:265
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
bond_create_if_args_t::id
u32 id
Definition: node.h:80
bond_set_intf_cmd
static clib_error_t * bond_set_intf_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:1044
ethernet_main
ethernet_main_t ethernet_main
Definition: init.c:45
bond_if_t::n_numa_members
word n_numa_members
Definition: node.h:203
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:458
member_if_t
Definition: node.h:213
member_interface_details_t::interface_name
u8 interface_name[64]
Definition: node.h:140
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:462
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
bond_main_t::lacp_plugin_loaded
u8 lacp_plugin_loaded
Definition: node.h:380
member_if_t::is_long_timeout
u8 is_long_timeout
Definition: node.h:224
bond_if_t::lb_rr_last_index
u32 lb_rr_last_index
Definition: node.h:175
vnet_get_hw_sw_interface
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:72
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_get_sup_hw_interface
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:92
bond_interface_details_t::active_members
u32 active_members
Definition: node.h:132
member_if_t::mode
u8 mode
Definition: node.h:328
ethernet_delete_interface
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:393
bond_enable_collecting_distributing
void bond_enable_collecting_distributing(vlib_main_t *vm, member_if_t *mif)
Definition: cli.c:134
bond_dump_member_ifs
int bond_dump_member_ifs(member_interface_details_t **out_memberifs, u32 bond_sw_if_index)
Definition: cli.c:212
add_member_interface_command_fn
static clib_error_t * add_member_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:775
bond_interface_details_t::lb
u32 lb
Definition: node.h:130
stat_segment_deregister_state_counter
clib_error_t * stat_segment_deregister_state_counter(u32 index)
Definition: stat_segment.c:934
bond_per_port_queue_t::n_buffers
u32 n_buffers
Definition: node.h:160
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
bond_add_member_args_t::error
clib_error_t * error
Definition: node.h:103
member_if_t::bif_dev_instance
u32 bif_dev_instance
Definition: node.h:323
bond_main_t::bond_by_sw_if_index
uword * bond_by_sw_if_index
Definition: node.h:373
bond_dump_ifs
int bond_dump_ifs(bond_interface_details_t **out_bondifs)
Definition: cli.c:177
bond_create_if_args_t::error
clib_error_t * error
Definition: node.h:90
bond_create_if_args_t::lb
u8 lb
Definition: node.h:84
BOND_SEND_GARP_NA
@ BOND_SEND_GARP_NA
Definition: node.h:75
show_bond_fn
static clib_error_t * show_bond_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:964
bond_get_member_by_sw_if_index
static member_if_t * bond_get_member_by_sw_if_index(u32 sw_if_index)
Definition: node.h:525
vnet_feature_enable_disable
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: pnat_test_stubs.h:50
member_if_t::last_marker_pkt
u8 * last_marker_pkt
Definition: node.h:242
now
f64 now
Definition: nat44_ei_out2in.c:710
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
bond_if_t::lockp
clib_spinlock_t lockp
Definition: node.h:210
bond_set_intf_weight_args_t
Definition: node.h:114
bond_interface_details_t::id
u32 id
Definition: node.h:127
member_interface_details_t::is_passive
u8 is_passive
Definition: node.h:141
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vnet_hw_interface_add_del_mac_address
clib_error_t * vnet_hw_interface_add_del_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address, u8 is_add)
Definition: interface.c:1539
vlib_main_t
Definition: main.h:102
bond_set_intf_weight_args_t::sw_if_index
u32 sw_if_index
Definition: node.h:116
bond_if_t::gso
u8 gso
Definition: node.h:200
bond_create_if_args_t::mode
u8 mode
Definition: node.h:83
bond_if_t::hw_address
u8 hw_address[6]
Definition: node.h:208
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_hw_interface_set_flags
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:513
unix.h
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
bond_if_t::active_members
u32 * active_members
Definition: node.h:190
ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:162
member_if_t::packet_template_index
u8 packet_template_index
Definition: node.h:230
i
int i
Definition: flowhash_template.h:376
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
Definition: interface.h:525
bond_set_intf_weight_args_t::rv
int rv
Definition: node.h:119
format_bond_load_balance
static u8 * format_bond_load_balance(u8 *s, va_list *args)
Definition: node.h:477
vnet_sw_interface_is_up
static uword vnet_sw_interface_is_up(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:339
bond_interface_details_t
BOND interface details struct.
Definition: node.h:124
detach_interface_command_fn
static clib_error_t * detach_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:847
vnet_sw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:887
vnet_hw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:667
rv
int __clib_unused rv
Definition: application.c:491
bond_main_t::per_thread_data
bond_per_thread_data_t * per_thread_data
Definition: node.h:386
bond_if_t::dev_instance
u32 dev_instance
Definition: node.h:178
bond_detach_member_args_t::member
u32 member
Definition: node.h:108
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
member_if_t::is_passive
u8 is_passive
Definition: node.h:251
bond_add_member
void bond_add_member(vlib_main_t *vm, bond_add_member_args_t *args)
Definition: cli.c:600
bond_main_t
Definition: node.h:361
member_if_t::lacp_enabled
u8 lacp_enabled
Definition: node.h:271
clib_spinlock_unlock_if_init
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:129
vlib_cli_command_t
Definition: cli.h:92
format_bond_mode
static u8 * format_bond_mode(u8 *s, va_list *args)
Definition: node.h:445
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
bond_create_if_args_t::numa_only
u8 numa_only
Definition: node.h:85
member_interface_details_t::sw_if_index
u32 sw_if_index
Definition: node.h:139
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
ethernet_interface::secondary_addrs
ethernet_interface_address_t * secondary_addrs
Definition: ethernet.h:176
bond_create_command_fn
static clib_error_t * bond_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:485
bond_if_t::hw_if_index
u32 hw_if_index
Definition: node.h:183
bond_detach_member_args_t
Definition: node.h:106
bond_create_if_args_t::hw_addr
u8 hw_addr[6]
Definition: node.h:82
bond_if_t::sw_if_index
u32 sw_if_index
Definition: node.h:184
member_if_t::group
u32 group
Definition: node.h:319
ethernet_register_interface
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:348
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
bond_detach_member_args_t::error
clib_error_t * error
Definition: node.h:111
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
bond_process_node
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
Definition: device.c:842
bond_add_member_args_t::is_long_timeout
u8 is_long_timeout
Definition: node.h:100
bond_main_t::vlib_main
vlib_main_t * vlib_main
Definition: node.h:376
show_bond_details
static void show_bond_details(vlib_main_t *vm)
Definition: cli.c:915