FD.io VPP  v16.09
Vector Packet Processing
interface.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * interface.c: VNET interfaces/sub-interfaces
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 #include <vnet/vnet.h>
41 #include <vnet/plugin/plugin.h>
42 
43 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0)
44 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1)
45 
47  u32 hw_if_index,
48  u32 flags,
49  u32 helper_flags);
50 
52  u32 sw_if_index,
53  u32 flags,
54  u32 helper_flags);
55 
57  u32 hw_if_index,
58  u32 hw_class_index,
59  u32 redistribute);
60 
61 typedef struct
62 {
63  /* Either sw or hw interface index. */
65 
66  /* Flags. */
69 
70 static void
72 {
74  va_arg (*va, vnet_sw_hw_interface_state_t *);
75  u32 n = va_arg (*va, u32);
76  u32 i;
77  for (i = 0; i < n; i++)
78  {
79  serialize_integer (m, s[i].sw_hw_if_index,
80  sizeof (s[i].sw_hw_if_index));
81  serialize_integer (m, s[i].flags, sizeof (s[i].flags));
82  }
83 }
84 
85 static void
87  va_list * va)
88 {
90  va_arg (*va, vnet_sw_hw_interface_state_t *);
91  u32 n = va_arg (*va, u32);
92  u32 i;
93  for (i = 0; i < n; i++)
94  {
95  unserialize_integer (m, &s[i].sw_hw_if_index,
96  sizeof (s[i].sw_hw_if_index));
97  unserialize_integer (m, &s[i].flags, sizeof (s[i].flags));
98  }
99 }
100 
101 static void
103 {
105  va_arg (*va, vnet_sw_hw_interface_state_t *);
107 }
108 
109 static void
111 {
112  CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
114 
116 
119  /* helper_flags no redistribution */ 0);
120 }
121 
122 static void
124 {
125  CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
127 
129 
132  /* helper_flags no redistribution */ 0);
133 }
134 
135 MC_SERIALIZE_MSG (vnet_sw_interface_set_flags_msg, static) =
136 {
137 .name = "vnet_sw_interface_set_flags",.serialize =
140 
141 MC_SERIALIZE_MSG (vnet_hw_interface_set_flags_msg, static) =
142 {
143 .name = "vnet_hw_interface_set_flags",.serialize =
146 
147 void
149 {
150  vnet_main_t *vnm = va_arg (*va, vnet_main_t *);
151  vnet_sw_hw_interface_state_t *sts = 0, *st;
152  vnet_sw_interface_t *sif;
153  vnet_hw_interface_t *hif;
155 
156  /* Serialize hardware interface classes since they may have changed.
157  Must do this before sending up/down flags. */
158  /* *INDENT-OFF* */
159  pool_foreach (hif, im->hw_interfaces, ({
160  vnet_hw_interface_class_t * hw_class = vnet_get_hw_interface_class (vnm, hif->hw_class_index);
161  serialize_cstring (m, hw_class->name);
162  }));
163  /* *INDENT-ON* */
164 
165  /* Send sw/hw interface state when non-zero. */
166  /* *INDENT-OFF* */
167  pool_foreach (sif, im->sw_interfaces, ({
168  if (sif->flags != 0)
169  {
170  vec_add2 (sts, st, 1);
171  st->sw_hw_if_index = sif->sw_if_index;
172  st->flags = sif->flags;
173  }
174  }));
175  /* *INDENT-ON* */
176 
178 
179  if (sts)
180  _vec_len (sts) = 0;
181 
182  /* *INDENT-OFF* */
183  pool_foreach (hif, im->hw_interfaces, ({
184  if (hif->flags != 0)
185  {
186  vec_add2 (sts, st, 1);
187  st->sw_hw_if_index = hif->hw_if_index;
188  st->flags = hif->flags;
189  }
190  }));
191  /* *INDENT-ON* */
192 
194 
195  vec_free (sts);
196 }
197 
198 void
200 {
201  vnet_main_t *vnm = va_arg (*va, vnet_main_t *);
202  vnet_sw_hw_interface_state_t *sts = 0, *st;
203 
204  /* First set interface hardware class. */
205  {
207  vnet_hw_interface_t *hif;
208  char *class_name;
209  uword *p;
210  clib_error_t *error;
211 
212  /* *INDENT-OFF* */
213  pool_foreach (hif, im->hw_interfaces, ({
214  unserialize_cstring (m, &class_name);
215  p = hash_get_mem (im->hw_interface_class_by_name, class_name);
216  ASSERT (p != 0);
217  error = vnet_hw_interface_set_class_helper (vnm, hif->hw_if_index, p[0], /* redistribute */ 0);
218  if (error)
219  clib_error_report (error);
220  vec_free (class_name);
221  }));
222  /* *INDENT-ON* */
223  }
224 
226  vec_foreach (st, sts)
227  vnet_sw_interface_set_flags_helper (vnm, st->sw_hw_if_index, st->flags,
228  /* no distribute */ 0);
229  vec_free (sts);
230 
232  vec_foreach (st, sts)
233  vnet_hw_interface_set_flags_helper (vnm, st->sw_hw_if_index, st->flags,
234  /* no distribute */ 0);
235  vec_free (sts);
236 }
237 
238 static clib_error_t *
240  u32 flags,
241  _vnet_interface_function_list_elt_t *
242  elt)
243 {
244  clib_error_t *error = 0;
245 
246  while (elt)
247  {
248  error = elt->fp (vnm, if_index, flags);
249  if (error)
250  return error;
251  elt = elt->next_interface_function;
252  }
253  return error;
254 }
255 
256 static clib_error_t *
258  u32 is_create)
259 {
260  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
261  vnet_hw_interface_class_t *hw_class =
263  vnet_device_class_t *dev_class =
265  clib_error_t *error = 0;
266 
267  if (hw_class->interface_add_del_function
268  && (error =
269  hw_class->interface_add_del_function (vnm, hw_if_index, is_create)))
270  return error;
271 
272  if (dev_class->interface_add_del_function
273  && (error =
274  dev_class->interface_add_del_function (vnm, hw_if_index,
275  is_create)))
276  return error;
277 
279  (vnm, hw_if_index, is_create, vnm->hw_interface_add_del_functions);
280 
281  return error;
282 }
283 
284 static clib_error_t *
286  u32 is_create)
287 {
289  (vnm, sw_if_index, is_create, vnm->sw_interface_add_del_functions);
290 }
291 
292 #define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE (1 << 0)
293 #define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE (1 << 1)
294 
295 static clib_error_t *
297  u32 flags, u32 helper_flags)
298 {
299  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
300  vnet_hw_interface_class_t *hw_class =
302  vnet_device_class_t *dev_class =
304  vlib_main_t *vm = vnm->vlib_main;
305  u32 mask;
306  clib_error_t *error = 0;
307  u32 is_create =
308  (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
309 
310  mask =
313  flags &= mask;
314 
315  /* Call hardware interface add/del callbacks. */
316  if (is_create)
317  call_hw_interface_add_del_callbacks (vnm, hw_if_index, is_create);
318 
319  /* Already in the desired state? */
320  if (!is_create && (hi->flags & mask) == flags)
321  goto done;
322 
323  /* Some interface classes do not redistribute (e.g. are local). */
324  if (!dev_class->redistribute)
326 
327  if (vm->mc_main
329  {
331  s.sw_hw_if_index = hw_if_index;
332  s.flags = flags;
333  mc_serialize (vm->mc_main, &vnet_hw_interface_set_flags_msg, &s);
334  }
335 
338  {
339  /* Do hardware class (e.g. ethernet). */
340  if (hw_class->link_up_down_function
341  && (error = hw_class->link_up_down_function (vnm, hw_if_index,
342  flags)))
343  goto done;
344 
346  (vnm, hw_if_index, is_create,
348 
349  if (error)
350  goto done;
351  }
352 
353  hi->flags &= ~mask;
354  hi->flags |= flags;
355 
356 done:
357  return error;
358 }
359 
360 static clib_error_t *
362  u32 flags, u32 helper_flags)
363 {
364  vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
365  vlib_main_t *vm = vnm->vlib_main;
366  u32 mask;
367  clib_error_t *error = 0;
368  u32 is_create =
369  (helper_flags & VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE) != 0;
370  u32 old_flags;
371 
373  flags &= mask;
374 
375  if (is_create)
376  {
377  error =
378  call_sw_interface_add_del_callbacks (vnm, sw_if_index, is_create);
379  if (error)
380  goto done;
381 
383  {
384  /* Notify everyone when the interface is created as admin up */
385  error = call_elf_section_interface_callbacks (vnm, sw_if_index,
386  flags,
387  vnm->
388  sw_interface_admin_up_down_functions);
389  if (error)
390  goto done;
391  }
392  }
393  else
394  {
395  vnet_sw_interface_t *si_sup = si;
396 
397  /* Check that super interface is in correct state. */
398  if (si->type == VNET_SW_INTERFACE_TYPE_SUB)
399  {
400  si_sup = vnet_get_sw_interface (vnm, si->sup_sw_if_index);
401 
402  /* Check to see if we're bringing down the soft interface and if it's parent is up */
403  if ((flags != (si_sup->flags & mask)) &&
404  (!((flags == 0)
405  && ((si_sup->flags & mask) ==
407  {
408  error = clib_error_return (0, "super-interface %U must be %U",
410  si_sup,
412  flags);
413  goto done;
414  }
415  }
416 
417  /* Donot change state for slave link of bonded interfaces */
419  {
420  error = clib_error_return
421  (0, "not allowed as %U belong to a BondEthernet interface",
423  goto done;
424  }
425 
426  /* Already in the desired state? */
427  if ((si->flags & mask) == flags)
428  goto done;
429 
430  /* Sub-interfaces of hardware interfaces that do no redistribute,
431  do not redistribute themselves. */
432  if (si_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
433  {
435  vnet_get_hw_interface (vnm, si_sup->hw_if_index);
436  vnet_device_class_t *dev_class =
438  if (!dev_class->redistribute)
439  helper_flags &=
441  }
442 
443  if (vm->mc_main
444  && (helper_flags &
446  {
448  s.sw_hw_if_index = sw_if_index;
449  s.flags = flags;
450  mc_serialize (vm->mc_main, &vnet_sw_interface_set_flags_msg, &s);
451  }
452 
454  (vnm, sw_if_index, flags, vnm->sw_interface_admin_up_down_functions);
455 
456  if (error)
457  goto done;
458 
460  {
463  vnet_hw_interface_class_t *hw_class =
465  vnet_device_class_t *dev_class =
467 
468  /* save the si admin up flag */
469  old_flags = si->flags;
470 
471  /* update si admin up flag in advance if we are going admin down */
472  if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
473  si->flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
474 
475  if (dev_class->admin_up_down_function
476  && (error = dev_class->admin_up_down_function (vnm,
477  si->hw_if_index,
478  flags)))
479  {
480  /* restore si admin up flag to it's original state on errors */
481  si->flags = old_flags;
482  goto done;
483  }
484 
485  if (hw_class->admin_up_down_function
486  && (error = hw_class->admin_up_down_function (vnm,
487  si->hw_if_index,
488  flags)))
489  {
490  /* restore si admin up flag to it's original state on errors */
491  si->flags = old_flags;
492  goto done;
493  }
494 
495  /* Admin down implies link down. */
496  if (!(flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
499  hi->flags &
501  helper_flags);
502  }
503  }
504 
505  si->flags &= ~mask;
506  si->flags |= flags;
507 
508 done:
509  return error;
510 }
511 
512 clib_error_t *
514 {
516  (vnm, hw_if_index, flags,
518 }
519 
520 clib_error_t *
522 {
524  (vnm, sw_if_index, flags,
526 }
527 
528 static u32
530  vnet_sw_interface_t * template)
531 {
534  u32 sw_if_index;
535 
536  pool_get (im->sw_interfaces, sw);
537  sw_if_index = sw - im->sw_interfaces;
538 
539  sw[0] = template[0];
540 
541  sw->flags = 0;
542  sw->sw_if_index = sw_if_index;
544  sw->sup_sw_if_index = sw->sw_if_index;
545 
546  /* Allocate counters for this interface. */
547  {
548  u32 i;
549 
551 
552  for (i = 0; i < vec_len (im->sw_if_counters); i++)
553  {
554  vlib_validate_simple_counter (&im->sw_if_counters[i], sw_if_index);
555  vlib_zero_simple_counter (&im->sw_if_counters[i], sw_if_index);
556  }
557 
558  for (i = 0; i < vec_len (im->combined_sw_if_counters); i++)
559  {
561  sw_if_index);
563  sw_if_index);
564  }
565 
567  }
568 
569  return sw_if_index;
570 }
571 
572 clib_error_t *
574  u32 * sw_if_index)
575 {
576  clib_error_t *error;
578  vnet_device_class_t *dev_class;
579 
580  hi = vnet_get_sup_hw_interface (vnm, template->sup_sw_if_index);
581  dev_class = vnet_get_device_class (vnm, hi->dev_class_index);
582 
583  if (template->type == VNET_SW_INTERFACE_TYPE_SUB &&
584  dev_class->subif_add_del_function)
585  {
586  error = dev_class->subif_add_del_function (vnm, hi->hw_if_index,
587  (struct vnet_sw_interface_t
588  *) template, 1);
589  if (error)
590  return error;
591  }
592 
593  *sw_if_index = vnet_create_sw_interface_no_callbacks (vnm, template);
595  (vnm, *sw_if_index, template->flags,
597 
598  if (error)
599  {
600  /* undo the work done by vnet_create_sw_interface_no_callbacks() */
602  vnet_sw_interface_t *sw =
603  pool_elt_at_index (im->sw_interfaces, *sw_if_index);
604  pool_put (im->sw_interfaces, sw);
605  }
606 
607  return error;
608 }
609 
610 void
612 {
614  vnet_sw_interface_t *sw =
615  pool_elt_at_index (im->sw_interfaces, sw_if_index);
616 
617  /* Bring down interface in case it is up. */
618  if (sw->flags != 0)
619  vnet_sw_interface_set_flags (vnm, sw_if_index, /* flags */ 0);
620 
621  call_sw_interface_add_del_callbacks (vnm, sw_if_index, /* is_create */ 0);
622 
623  pool_put (im->sw_interfaces, sw);
624 }
625 
626 static void
628  u32 node_index, vnet_device_class_t * dev_class)
629 {
630  vlib_node_t *n = vlib_get_node (vm, node_index);
631 
632  n->function = dev_class->tx_function;
633  n->format_trace = dev_class->format_tx_trace;
634  vlib_register_errors (vm, node_index,
635  dev_class->tx_function_n_errors,
636  dev_class->tx_function_error_strings);
637 }
638 
639 static void
641  u32 node_index, vnet_hw_interface_class_t * hw_class)
642 {
643  vlib_node_t *n = vlib_get_node (vm, node_index);
644  n->format_buffer = hw_class->format_header;
645  n->unformat_buffer = hw_class->unformat_header;
646 }
647 
648 /* Register an interface instance. */
649 u32
651  u32 dev_class_index,
652  u32 dev_instance,
653  u32 hw_class_index, u32 hw_instance)
654 {
657  vnet_device_class_t *dev_class =
658  vnet_get_device_class (vnm, dev_class_index);
659  vnet_hw_interface_class_t *hw_class =
660  vnet_get_hw_interface_class (vnm, hw_class_index);
661  vlib_main_t *vm = vnm->vlib_main;
662  u32 hw_index;
663  char *tx_node_name, *output_node_name;
664 
665  pool_get (im->hw_interfaces, hw);
666 
667  hw_index = hw - im->hw_interfaces;
668  hw->hw_if_index = hw_index;
669 
670  if (dev_class->format_device_name)
671  hw->name = format (0, "%U", dev_class->format_device_name, dev_instance);
672  else if (hw_class->format_interface_name)
673  hw->name = format (0, "%U", hw_class->format_interface_name,
674  dev_instance);
675  else
676  hw->name = format (0, "%s%x", hw_class->name, dev_instance);
677 
678  if (!im->hw_interface_by_name)
679  im->hw_interface_by_name = hash_create_vec ( /* size */ 0,
680  sizeof (hw->name[0]),
681  sizeof (uword));
682 
683  hash_set_mem (im->hw_interface_by_name, hw->name, hw_index);
684 
685  /* Make hardware interface point to software interface. */
686  {
688 
689  memset (&sw, 0, sizeof (sw));
691  sw.hw_if_index = hw_index;
693  }
694 
695  hw->dev_class_index = dev_class_index;
696  hw->dev_instance = dev_instance;
697  hw->hw_class_index = hw_class_index;
698  hw->hw_instance = hw_instance;
699 
700  hw->max_rate_bits_per_sec = 0;
701  hw->min_packet_bytes = 0;
703  hw->max_l3_packet_bytes[VLIB_RX] = ~0;
704  hw->max_l3_packet_bytes[VLIB_TX] = ~0;
705 
706  tx_node_name = (char *) format (0, "%v-tx", hw->name);
707  output_node_name = (char *) format (0, "%v-output", hw->name);
708 
709  /* If we have previously deleted interface nodes, re-use them. */
710  if (vec_len (im->deleted_hw_interface_nodes) > 0)
711  {
714  vlib_node_t *node;
715  vlib_node_runtime_t *nrt;
716 
717  hn = vec_end (im->deleted_hw_interface_nodes) - 1;
718 
719  hw->tx_node_index = hn->tx_node_index;
721 
722  vlib_node_rename (vm, hw->tx_node_index, "%v", tx_node_name);
723  vlib_node_rename (vm, hw->output_node_index, "%v", output_node_name);
724 
726  ASSERT (rt->is_deleted == 1);
727  rt->is_deleted = 0;
728  rt->hw_if_index = hw_index;
729  rt->sw_if_index = hw->sw_if_index;
730  rt->dev_instance = hw->dev_instance;
731 
733  rt->hw_if_index = hw_index;
734  rt->sw_if_index = hw->sw_if_index;
735  rt->dev_instance = hw->dev_instance;
736 
737  /* The new class may differ from the old one.
738  * Functions have to be updated. */
739  node = vlib_get_node (vm, hw->output_node_index);
740  node->function = dev_class->no_flatten_output_chains ?
745  nrt->function = node->function;
746 
747  node = vlib_get_node (vm, hw->tx_node_index);
748  node->function = dev_class->tx_function;
749  node->format_trace = dev_class->format_tx_trace;
750  nrt = vlib_node_get_runtime (vm, hw->tx_node_index);
751  nrt->function = node->function;
752 
754  _vec_len (im->deleted_hw_interface_nodes) -= 1;
755  }
756  else
757  {
760  .hw_if_index = hw_index,
761  .sw_if_index = hw->sw_if_index,
762  .dev_instance = hw->dev_instance,
763  .is_deleted = 0,
764  };
765 
766  memset (&r, 0, sizeof (r));
767  r.type = VLIB_NODE_TYPE_INTERNAL;
768  r.runtime_data = &rt;
769  r.runtime_data_bytes = sizeof (rt);
770  r.scalar_size = 0;
771  r.vector_size = sizeof (u32);
772 
773  r.flags = VLIB_NODE_FLAG_IS_OUTPUT;
774  r.name = tx_node_name;
775  r.function = dev_class->tx_function;
776 
777  hw->tx_node_index = vlib_register_node (vm, &r);
778 
780  "error-drop",
782 
783  r.flags = 0;
784  r.name = output_node_name;
785  r.function = dev_class->no_flatten_output_chains ?
788  r.format_trace = format_vnet_interface_output_trace;
789 
790  {
791  static char *e[] = {
792  "interface is down",
793  "interface is deleted",
794  };
795 
796  r.n_errors = ARRAY_LEN (e);
797  r.error_strings = e;
798  }
799  hw->output_node_index = vlib_register_node (vm, &r);
800 
801 #define _(sym,str) vlib_node_add_named_next_with_slot (vm, \
802  hw->output_node_index, str, \
803  VNET_INTERFACE_OUTPUT_NEXT_##sym);
805 #undef _
807  "error-drop",
810  hw->tx_node_index,
812  }
813 
814  setup_output_node (vm, hw->output_node_index, hw_class);
815  setup_tx_node (vm, hw->tx_node_index, dev_class);
816 
817  /* Call all up/down callbacks with zero flags when interface is created. */
818  vnet_sw_interface_set_flags_helper (vnm, hw->sw_if_index, /* flags */ 0,
820  vnet_hw_interface_set_flags_helper (vnm, hw_index, /* flags */ 0,
822 
823  return hw_index;
824 }
825 
826 void
828 {
830  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
831  vlib_main_t *vm = vnm->vlib_main;
832 
833  /* If it is up, mark it down. */
834  if (hw->flags != 0)
835  vnet_hw_interface_set_flags (vnm, hw_if_index, /* flags */ 0);
836 
837  /* Call delete callbacks. */
838  call_hw_interface_add_del_callbacks (vnm, hw_if_index, /* is_create */ 0);
839 
840  /* Delete software interface corresponding to hardware interface. */
842 
843  /* Delete any sub-interfaces. */
844  {
845  u32 id, sw_if_index;
846  /* *INDENT-OFF* */
847  hash_foreach (id, sw_if_index, hw->sub_interface_sw_if_index_by_id, ({
848  vnet_delete_sw_interface (vnm, sw_if_index);
849  }));
850  /* *INDENT-ON* */
851  }
852 
853  {
857 
858  /* Mark node runtime as deleted so output node (if called) will drop packets. */
859  rt->is_deleted = 1;
860 
862  "interface-%d-output-deleted", hw_if_index);
863  vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted",
864  hw_if_index);
866  dn->tx_node_index = hw->tx_node_index;
868  }
869 
871  vec_free (hw->name);
872 
873  pool_put (im->hw_interfaces, hw);
874 }
875 
876 static void
878 {
879  u32 hw_if_index = va_arg (*va, u32);
880  char *hw_class_name = va_arg (*va, char *);
881  serialize_integer (m, hw_if_index, sizeof (hw_if_index));
882  serialize_cstring (m, hw_class_name);
883 }
884 
885 static void
887 {
888  CLIB_UNUSED (mc_main_t * mc) = va_arg (*va, mc_main_t *);
889  vnet_main_t *vnm = vnet_get_main ();
890  u32 hw_if_index;
891  char *hw_class_name;
892  uword *p;
893  clib_error_t *error;
894 
895  unserialize_integer (m, &hw_if_index, sizeof (hw_if_index));
896  unserialize_cstring (m, &hw_class_name);
897  p =
898  hash_get (vnm->interface_main.hw_interface_class_by_name, hw_class_name);
899  ASSERT (p != 0);
900  error = vnet_hw_interface_set_class_helper (vnm, hw_if_index, p[0],
901  /* redistribute */ 0);
902  if (error)
903  clib_error_report (error);
904 }
905 
906 MC_SERIALIZE_MSG (vnet_hw_interface_set_class_msg, static) =
907 {
908 .name = "vnet_hw_interface_set_class",.serialize =
911 
912 void
914  u32 hw_class_index, u32 hw_instance)
915 {
916  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
918  vnet_get_hw_interface_class (vnm, hw_class_index);
919 
920  hi->hw_class_index = hw_class_index;
921  hi->hw_instance = hw_instance;
923 }
924 
925 static clib_error_t *
927  u32 hw_class_index, u32 redistribute)
928 {
929  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
931  vnet_hw_interface_class_t *old_class =
933  vnet_hw_interface_class_t *new_class =
934  vnet_get_hw_interface_class (vnm, hw_class_index);
935  vnet_device_class_t *dev_class =
937  clib_error_t *error = 0;
938 
939  /* New class equals old class? Nothing to do. */
940  if (hi->hw_class_index == hw_class_index)
941  return 0;
942 
943  /* No need (and incorrect since admin up flag may be set) to do error checking when
944  receiving unserialize message. */
945  if (redistribute)
946  {
948  return clib_error_return (0,
949  "%v must be admin down to change class from %s to %s",
950  hi->name, old_class->name, new_class->name);
951 
952  /* Make sure interface supports given class. */
953  if ((new_class->is_valid_class_for_interface
954  && !new_class->is_valid_class_for_interface (vnm, hw_if_index,
955  hw_class_index))
956  || (dev_class->is_valid_class_for_interface
957  && !dev_class->is_valid_class_for_interface (vnm, hw_if_index,
958  hw_class_index)))
959  return clib_error_return (0,
960  "%v class cannot be changed from %s to %s",
961  hi->name, old_class->name, new_class->name);
962 
963  if (vnm->vlib_main->mc_main)
964  {
966  &vnet_hw_interface_set_class_msg, hw_if_index,
967  new_class->name);
968  return 0;
969  }
970  }
971 
972  if (old_class->hw_class_change)
973  old_class->hw_class_change (vnm, hw_if_index, old_class->index,
974  new_class->index);
975 
976  vnet_hw_interface_init_for_class (vnm, hw_if_index, new_class->index,
977  /* instance */ ~0);
978 
979  if (new_class->hw_class_change)
980  new_class->hw_class_change (vnm, hw_if_index, old_class->index,
981  new_class->index);
982 
983  if (dev_class->hw_class_change)
984  dev_class->hw_class_change (vnm, hw_if_index, new_class->index);
985 
986  return error;
987 }
988 
989 clib_error_t *
991  u32 hw_class_index)
992 {
993  return vnet_hw_interface_set_class_helper (vnm, hw_if_index, hw_class_index,
994  /* redistribute */ 1);
995 }
996 
997 static int
999  u32 hw_if_index,
1000  u32 node_index,
1001  u32 redistribute)
1002 {
1003  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1005  (vnm, hi->dev_class_index);
1006 
1007  if (redistribute)
1008  {
1009  /* $$$$ fixme someday maybe */
1010  ASSERT (vnm->vlib_main->mc_main == 0);
1011  }
1012  if (dev_class->rx_redirect_to_node)
1013  {
1014  dev_class->rx_redirect_to_node (vnm, hw_if_index, node_index);
1015  return 0;
1016  }
1017 
1018  return VNET_API_ERROR_UNIMPLEMENTED;
1019 }
1020 
1021 int
1023  u32 node_index)
1024 {
1025  return vnet_hw_interface_rx_redirect_to_node_helper (vnm, hw_if_index,
1026  node_index,
1027  1 /* redistribute */ );
1028 }
1029 
1030 word
1032  uword sw_if_index0, uword sw_if_index1)
1033 {
1034  vnet_sw_interface_t *sup0 = vnet_get_sup_sw_interface (vnm, sw_if_index0);
1035  vnet_sw_interface_t *sup1 = vnet_get_sup_sw_interface (vnm, sw_if_index1);
1038 
1039  if (h0 != h1)
1040  return vec_cmp (h0->name, h1->name);
1041  return (word) h0->hw_instance - (word) h1->hw_instance;
1042 }
1043 
1044 word
1046  uword hw_if_index0, uword hw_if_index1)
1047 {
1048  vnet_hw_interface_t *h0 = vnet_get_hw_interface (vnm, hw_if_index0);
1049  vnet_hw_interface_t *h1 = vnet_get_hw_interface (vnm, hw_if_index1);
1050 
1051  if (h0 != h1)
1052  return vec_cmp (h0->name, h1->name);
1053  return (word) h0->hw_instance - (word) h1->hw_instance;
1054 }
1055 
1056 clib_error_t *
1058 {
1059  vnet_main_t *vnm = vnet_get_main ();
1061  vlib_buffer_t *b = 0;
1062  vnet_buffer_opaque_t *o = 0;
1063 
1064  /*
1065  * Keep people from shooting themselves in the foot.
1066  */
1067  if (sizeof (b->opaque) != sizeof (vnet_buffer_opaque_t))
1068  {
1069 #define _(a) if (sizeof(o->a) > sizeof (o->unused)) \
1070  clib_warning \
1071  ("FATAL: size of opaque union subtype %s is %d (max %d)", \
1072  #a, sizeof(o->a), sizeof (o->unused));
1074 #undef _
1075 
1076  return clib_error_return
1077  (0, "FATAL: size of vlib buffer opaque %d, size of vnet opaque %d",
1078  sizeof (b->opaque), sizeof (vnet_buffer_opaque_t));
1079  }
1080 
1083  im->sw_if_counter_lock[0] = 1; /* should be no need */
1084 
1094 
1099 
1100  im->sw_if_counter_lock[0] = 0;
1101 
1102  im->device_class_by_name = hash_create_string ( /* size */ 0,
1103  sizeof (uword));
1104  {
1106 
1107  c = vnm->device_class_registrations;
1108 
1109  while (c)
1110  {
1111  c->index = vec_len (im->device_classes);
1112  hash_set_mem (im->device_class_by_name, c->name, c->index);
1113  vec_add1 (im->device_classes, c[0]);
1114  c = c->next_class_registration;
1115  }
1116  }
1117 
1118  im->hw_interface_class_by_name = hash_create_string ( /* size */ 0,
1119  sizeof (uword));
1120 
1121  im->sw_if_index_by_sup_and_sub = hash_create_mem (0, sizeof (u64),
1122  sizeof (uword));
1123  {
1125 
1127 
1128  while (c)
1129  {
1130  c->index = vec_len (im->hw_interface_classes);
1131  hash_set_mem (im->hw_interface_class_by_name, c->name, c->index);
1132  vec_add1 (im->hw_interface_classes, c[0]);
1133  c = c->next_class_registration;
1134  }
1135  }
1136 
1137  {
1138  clib_error_t *error;
1139 
1141  return error;
1142 
1143  return error;
1144  }
1145 }
1146 
1148 
1149 /* Kludge to renumber interface names [only!] */
1150 int
1151 vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance)
1152 {
1153  int rv;
1154  vnet_main_t *vnm = vnet_get_main ();
1156  vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
1157 
1159  (vnm, hi->dev_class_index);
1160 
1161  if (dev_class->name_renumber == 0 || dev_class->format_device_name == 0)
1162  return VNET_API_ERROR_UNIMPLEMENTED;
1163 
1164  rv = dev_class->name_renumber (hi, new_show_dev_instance);
1165 
1166  if (rv)
1167  return rv;
1168 
1170  vec_free (hi->name);
1171  /* Use the mapping we set up to call it Ishmael */
1172  hi->name = format (0, "%U", dev_class->format_device_name,
1173  hi->dev_instance);
1174 
1176  return rv;
1177 }
1178 
1179 int
1181  vlib_main_t * vm,
1182  u32 sw_if_index,
1183  intf_output_feat_t feature, int is_add)
1184 {
1185  vnet_sw_interface_t *sw;
1186 
1187  sw = vnet_get_sw_interface (vnm, sw_if_index);
1188 
1189  if (is_add)
1190  {
1191 
1192  sw->output_feature_bitmap |= (1 << feature);
1194 
1195  }
1196  else
1197  { /* delete */
1198 
1199  sw->output_feature_bitmap &= ~(1 << feature);
1200  if (sw->output_feature_bitmap == (1 << INTF_OUTPUT_FEAT_DONE))
1201  sw->output_feature_bitmap = 0;
1202 
1203  }
1204  return 0;
1205 }
1206 
1207 clib_error_t *
1208 vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index, char *new_name)
1209 {
1211  vlib_main_t *vm = vnm->vlib_main;
1212  vnet_hw_interface_t *hw;
1213  u8 *old_name;
1214  clib_error_t *error = 0;
1215 
1216  hw = vnet_get_hw_interface (vnm, hw_if_index);
1217  if (!hw)
1218  {
1219  return clib_error_return (0,
1220  "unable to find hw interface for index %u",
1221  hw_if_index);
1222  }
1223 
1224  old_name = hw->name;
1225 
1226  /* set new hw->name */
1227  hw->name = format (0, "%s", new_name);
1228 
1229  /* remove the old name to hw_if_index mapping and install the new one */
1230  hash_unset_mem (im->hw_interface_by_name, old_name);
1231  hash_set_mem (im->hw_interface_by_name, hw->name, hw_if_index);
1232 
1233  /* rename tx/output nodes */
1234  vlib_node_rename (vm, hw->tx_node_index, "%v-tx", hw->name);
1235  vlib_node_rename (vm, hw->output_node_index, "%v-output", hw->name);
1236 
1237  /* free the old name vector */
1238  vec_free (old_name);
1239 
1240  return error;
1241 }
1242 
1243 /*
1244  * fd.io coding-style-patch-verification: ON
1245  *
1246  * Local Variables:
1247  * eval: (c-set-style "gnu")
1248  * End:
1249  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
void serialize_vnet_interface_state(serialize_main_t *m, va_list *va)
Definition: interface.c:148
vmrglw vmrglh hi
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
static clib_error_t * vnet_hw_interface_set_class_helper(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index, u32 redistribute)
Definition: interface.c:926
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:513
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:110
volatile u32 * sw_if_counter_lock
Definition: interface.h:499
vnet_hw_interface_nodes_t * deleted_hw_interface_nodes
Definition: interface.h:503
#define INTF_OUTPUT_FEAT_DONE
Definition: interface.h:552
#define vec_serialize(m, v, f)
Definition: serialize.h:371
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
Definition: vnet.h:64
void * vnet_interface_output_node_multiarch_select(void)
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node_index, uword next_node_index, uword slot)
Definition: node.c:156
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: interface.c:1022
void vlib_register_errors(vlib_main_t *vm, u32 node_index, u32 n_errors, char *error_strings[])
Definition: error.c:145
int vnet_interface_add_del_feature(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index, intf_output_feat_t feature, int is_add)
Definition: interface.c:1180
#define vec_unserialize(m, v, f)
Definition: serialize.h:374
format_function_t * format_trace
Definition: node.h:315
vnet_device_class_t * device_class_registrations
Definition: vnet.h:67
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:482
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
Definition: interface.c:1031
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1151
_vnet_interface_function_list_elt_t * sw_interface_admin_up_down_functions
Definition: vnet.h:72
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:521
intf_output_feat_t
Definition: interface.h:543
#define hash_set_mem(h, key, value)
Definition: hash.h:274
MC_SERIALIZE_MSG(vnet_sw_interface_set_flags_msg, static)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:348
static void unserialize_vnet_hw_interface_set_flags(serialize_main_t *m, va_list *va)
Definition: interface.c:123
#define clib_error_report(e)
Definition: error.h:125
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:273
struct _vnet_device_class vnet_device_class_t
#define mc_serialize(mc, msg, args...)
Definition: mc.h:651
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
static clib_error_t * vnet_hw_interface_set_flags_helper(vnet_main_t *vnm, u32 hw_if_index, u32 flags, u32 helper_flags)
Definition: interface.c:296
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:278
mc_main_t * mc_main
Definition: main.h:133
vlib_node_function_t * function
Definition: node.h:218
u32 vlib_register_node(vlib_main_t *vm, vlib_node_registration_t *r)
Definition: node.c:446
static void unserialize_vec_vnet_sw_hw_interface_state(serialize_main_t *m, va_list *va)
Definition: interface.c:86
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:290
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
void vlib_worker_thread_node_runtime_update(void)
Definition: threads.c:831
vlib_node_function_t * function
Definition: node.h:415
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static u32 vnet_create_sw_interface_no_callbacks(vnet_main_t *vnm, vnet_sw_interface_t *template)
Definition: interface.c:529
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:501
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:407
void * vnet_interface_output_node_no_flatten_multiarch_select(void)
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * call_hw_interface_add_del_callbacks(vnet_main_t *vnm, u32 hw_if_index, u32 is_create)
Definition: interface.c:257
unsigned long u64
Definition: types.h:89
#define vec_end(v)
End (last data address) of vector.
#define vlib_call_init_function(vm, x)
Definition: init.h:161
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:650
_vnet_interface_function_list_elt_t * hw_interface_link_up_down_functions
Definition: vnet.h:70
#define hash_create_string(elts, value_bytes)
Definition: hash.h:641
char * name
The counter collection&#39;s name.
Definition: counter.h:68
uword * hw_interface_by_name
Definition: interface.h:481
void vlib_node_rename(vlib_main_t *vm, u32 node_index, char *fmt,...)
Definition: node.c:76
vnet_hw_interface_t * hw_interfaces
Definition: interface.h:478
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:626
#define hash_get(h, key)
Definition: hash.h:248
format_function_t format_vnet_sw_interface_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
Definition: counter.h:321
u8 * format_vnet_interface_output_trace(u8 *s, va_list *va)
#define hash_unset_mem(h, key)
Definition: hash.h:280
vlib_main_t * vlib_main
Definition: vnet.h:80
#define VNET_SW_INTERFACE_FLAG_BOND_SLAVE
Definition: interface.h:424
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
static void serialize_vec_vnet_sw_hw_interface_state(serialize_main_t *m, va_list *va)
Definition: interface.c:71
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:495
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
Definition: node_funcs.h:109
static void unserialize_vnet_hw_interface_set_class(serialize_main_t *m, va_list *va)
Definition: interface.c:886
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:500
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
Definition: interface.c:1045
format_function_t * format_buffer
Definition: node.h:311
uword * hw_interface_class_by_name
Definition: interface.h:488
void unserialize_cstring(serialize_main_t *m, char **s)
Definition: serialize.c:178
void unserialize_vnet_interface_state(serialize_main_t *m, va_list *va)
Definition: interface.c:199
clib_error_t * vnet_rename_interface(vnet_main_t *vnm, u32 hw_if_index, char *new_name)
Definition: interface.c:1208
_vnet_interface_function_list_elt_t * sw_interface_add_del_functions
Definition: vnet.h:71
_vnet_interface_function_list_elt_t * hw_interface_add_del_functions
Definition: vnet.h:69
clib_error_t * serialize(serialize_main_t *m,...)
Definition: serialize.c:671
svmdb_client_t * c
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Definition: node_funcs.h:88
unformat_function_t * unformat_buffer
Definition: node.h:312
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:524
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
Definition: serialize.h:201
static void serialize_integer(serialize_main_t *m, u64 x, u32 n_bytes)
Definition: serialize.h:185
static clib_error_t * call_sw_interface_add_del_callbacks(vnet_main_t *vnm, u32 sw_if_index, u32 is_create)
Definition: interface.c:285
void vnet_hw_interface_init_for_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:913
#define ARRAY_LEN(x)
Definition: clib.h:59
static void setup_output_node(vlib_main_t *vm, u32 node_index, vnet_hw_interface_class_t *hw_class)
Definition: interface.c:640
format_function_t format_vnet_sw_interface_flags
static void unserialize_vnet_sw_interface_set_flags(serialize_main_t *m, va_list *va)
Definition: interface.c:110
#define VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE
Definition: interface.c:292
static clib_error_t * vnet_sw_interface_set_flags_helper(vnet_main_t *vnm, u32 sw_if_index, u32 flags, u32 helper_flags)
Definition: interface.c:361
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:516
void vlib_validate_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
validate a simple counter
Definition: counter.c:98
Definition: mc.h:522
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:415
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
Definition: interface.h:345
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
static void serialize_vnet_sw_hw_interface_set_flags(serialize_main_t *m, va_list *va)
Definition: interface.c:102
#define VNET_SW_INTERFACE_FLAG_PUNT
Definition: interface.h:418
static void setup_tx_node(vlib_main_t *vm, u32 node_index, vnet_device_class_t *dev_class)
Definition: interface.c:627
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
static vnet_hw_interface_class_t * vnet_get_hw_interface_class(vnet_main_t *vnm, u32 hw_class_index)
clib_error_t * unserialize(serialize_main_t *m,...)
Definition: serialize.c:683
static clib_error_t * call_elf_section_interface_callbacks(vnet_main_t *vnm, u32 if_index, u32 flags, _vnet_interface_function_list_elt_t *elt)
Definition: interface.c:239
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
Definition: counter.h:143
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
Definition: vec.h:880
uword * device_class_by_name
Definition: interface.h:489
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:827
u64 uword
Definition: types.h:112
void serialize_cstring(serialize_main_t *m, char *s)
Definition: serialize.c:164
#define VLIB_NODE_FLAG_IS_OUTPUT
Definition: node.h:253
Definition: defs.h:47
#define hash_create_vec(elts, key_bytes, value_bytes)
Definition: hash.h:633
i64 word
Definition: types.h:111
struct _vnet_hw_interface_class vnet_hw_interface_class_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
clib_error_t * vnet_interface_init(vlib_main_t *vm)
Definition: interface.c:1057
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
static int vnet_hw_interface_rx_redirect_to_node_helper(vnet_main_t *vnm, u32 hw_if_index, u32 node_index, u32 redistribute)
Definition: interface.c:998
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:492
vnet_hw_interface_class_t * hw_interface_class_registrations
Definition: vnet.h:68
char * name
The counter collection&#39;s name.
Definition: counter.h:219
vnet_hw_interface_class_t * hw_interface_classes
Definition: interface.h:484
u32 opaque[8]
Opaque data used by sub-graphs for their own purposes.
Definition: buffer.h:130
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:114
static void serialize_vnet_hw_interface_set_class(serialize_main_t *m, va_list *va)
Definition: interface.c:877
#define foreach_intf_output_feat
Definition: interface.h:539
vnet_sw_interface_type_t type
Definition: interface.h:410
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
#define vec_foreach(var, vec)
Vector iterator.
void vnet_delete_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface.c:611
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:521
vnet_device_class_t * device_classes
Definition: interface.h:485
u32 per_packet_overhead_bytes
Definition: interface.h:342
#define clib_error_return(e, args...)
Definition: error.h:111
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:573
#define foreach_buffer_opaque_union_subtype
Definition: buffer.h:70
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
Definition: node.c:213
u32 flags
Definition: vhost-user.h:76
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
#define VNET_INTERFACE_SET_FLAGS_HELPER_WANT_REDISTRIBUTE
Definition: interface.c:293
Definition: defs.h:46
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)
Definition: interface.c:990