FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
interface_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * interface_api.c - vnet interface api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
25 #include <vnet/api_errno.h>
26 #include <vnet/ethernet/ethernet.h>
27 #include <vnet/ip/ip.h>
28 #include <vnet/fib/fib_table.h>
29 #include <vnet/mfib/mfib_table.h>
30 #include <vnet/l2/l2_vtr.h>
31 #include <vnet/fib/fib_api.h>
32 #include <vnet/mfib/mfib_table.h>
33 #include <vlibapi/api_types.h>
34 
35 #include <vnet/format_fns.h>
36 #include <vnet/ip/ip_types_api.h>
38 
39 #include <interface.api_enum.h>
40 #include <interface.api_types.h>
41 
42 #define REPLY_MSG_ID_BASE msg_id_base
44 
46 
48 
49 #define foreach_vpe_api_msg \
50  _ (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
51  _ (SW_INTERFACE_SET_PROMISC, sw_interface_set_promisc) \
52  _ (HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \
53  _ (SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \
54  _ (WANT_INTERFACE_EVENTS, want_interface_events) \
55  _ (SW_INTERFACE_DUMP, sw_interface_dump) \
56  _ (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
57  _ (SW_INTERFACE_SET_RX_MODE, sw_interface_set_rx_mode) \
58  _ (SW_INTERFACE_RX_PLACEMENT_DUMP, sw_interface_rx_placement_dump) \
59  _ (SW_INTERFACE_SET_RX_PLACEMENT, sw_interface_set_rx_placement) \
60  _ (SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
61  _ (SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
62  _ (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
63  _ (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
64  _ (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \
65  _ (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, sw_interface_add_del_mac_address) \
66  _ (SW_INTERFACE_SET_MAC_ADDRESS, sw_interface_set_mac_address) \
67  _ (SW_INTERFACE_GET_MAC_ADDRESS, sw_interface_get_mac_address) \
68  _ (CREATE_VLAN_SUBIF, create_vlan_subif) \
69  _ (CREATE_SUBIF, create_subif) \
70  _ (DELETE_SUBIF, delete_subif) \
71  _ (CREATE_LOOPBACK, create_loopback) \
72  _ (CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
73  _ (DELETE_LOOPBACK, delete_loopback) \
74  _ (INTERFACE_NAME_RENUMBER, interface_name_renumber) \
75  _ (COLLECT_DETAILED_INTERFACE_STATS, collect_detailed_interface_stats) \
76  _ (SW_INTERFACE_SET_IP_DIRECTED_BROADCAST, \
77  sw_interface_set_ip_directed_broadcast) \
78  _ (SW_INTERFACE_ADDRESS_REPLACE_BEGIN, sw_interface_address_replace_begin) \
79  _ (SW_INTERFACE_ADDRESS_REPLACE_END, sw_interface_address_replace_end)
80 
81 static void
83 {
84  vl_api_sw_interface_set_flags_reply_t *rmp;
85  vnet_main_t *vnm = vnet_get_main ();
86  int rv = 0;
88  u16 flags;
89 
91 
92  flags =
93  ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
95 
96  error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
97  if (error)
98  {
99  rv = -1;
101  }
102 
104  REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
105 }
106 
107 static void
110 {
111  vl_api_sw_interface_set_promisc_reply_t *rmp;
112  vnet_main_t *vnm = vnet_get_main ();
114  int rv = 0;
118 
120 
121  sw_if_index = ntohl (mp->sw_if_index);
123  eif = ethernet_get_interface (em, swif->hw_if_index);
124  if (!eif)
125  {
126  rv = VNET_API_ERROR_INVALID_VALUE;
127  goto done;
128  }
129 
131  rv = ethernet_set_flags (vnm, swif->hw_if_index, flags);
132 
133 done:
135  REPLY_MACRO (VL_API_SW_INTERFACE_SET_PROMISC_REPLY);
136 }
137 
138 static void
140 {
141  vl_api_hw_interface_set_mtu_reply_t *rmp;
142  vnet_main_t *vnm = vnet_get_main ();
143  u32 sw_if_index = ntohl (mp->sw_if_index);
144  u16 mtu = ntohs (mp->mtu);
146  int rv = 0;
147 
149 
152  {
153  rv = VNET_API_ERROR_INVALID_VALUE;
154  goto bad_sw_if_index;
155  }
156 
159 
160  if (!eif)
161  {
162  rv = VNET_API_ERROR_FEATURE_DISABLED;
163  goto bad_sw_if_index;
164  }
165 
166  if (mtu < hi->min_supported_packet_bytes)
167  {
168  rv = VNET_API_ERROR_INVALID_VALUE;
169  goto bad_sw_if_index;
170  }
171 
172  if (mtu > hi->max_supported_packet_bytes)
173  {
174  rv = VNET_API_ERROR_INVALID_VALUE;
175  goto bad_sw_if_index;
176  }
177 
179 
181  REPLY_MACRO (VL_API_HW_INTERFACE_SET_MTU_REPLY);
182 }
183 
184 static void
186 {
187  vl_api_sw_interface_set_mtu_reply_t *rmp;
188  vnet_main_t *vnm = vnet_get_main ();
189  u32 sw_if_index = ntohl (mp->sw_if_index);
190  int rv = 0;
191  int i;
192  u32 per_protocol_mtu[VNET_N_MTU];
193 
195 
196  for (i = 0; i < VNET_N_MTU; i++)
197  {
198  per_protocol_mtu[i] = ntohl (mp->mtu[i]);
199  }
200  vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, per_protocol_mtu);
201 
203  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY);
204 }
205 
206 static void
209 {
210  vl_api_sw_interface_set_ip_directed_broadcast_reply_t *rmp;
211  u32 sw_if_index = ntohl (mp->sw_if_index);
212  int rv = 0;
213 
215 
217  sw_if_index, mp->enable);
218 
220  REPLY_MACRO (VL_API_SW_INTERFACE_SET_IP_DIRECTED_BROADCAST_REPLY);
221 }
222 
223 static void
227  u8 * interface_name, u32 context)
228 {
230  vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index);
231  vnet_device_class_t *dev_class =
232  vnet_get_device_class (am->vnet_main, hi->dev_class_index);
233 
234  vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
235  clib_memset (mp, 0, sizeof (*mp));
236  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_DETAILS);
237  mp->sw_if_index = ntohl (swif->sw_if_index);
238  mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
239 
240  mp->flags |= (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
242  mp->flags |= (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ?
244  mp->flags = ntohl (mp->flags);
245 
246  switch (swif->type)
247  {
249  mp->type = IF_API_TYPE_SUB;
250  break;
252  mp->type = IF_API_TYPE_P2P;
253  break;
255  mp->type = IF_API_TYPE_PIPE;
256  break;
257  default:
259  }
260  mp->type = ntohl (mp->type);
261 
262  mp->link_duplex = ntohl (((hi->flags & VNET_HW_INTERFACE_FLAG_DUPLEX_MASK) >>
264  mp->link_speed = ntohl (hi->link_speed);
265  mp->link_mtu = ntohs (hi->max_packet_bytes);
266  mp->mtu[VNET_MTU_L3] = ntohl (swif->mtu[VNET_MTU_L3]);
267  mp->mtu[VNET_MTU_IP4] = ntohl (swif->mtu[VNET_MTU_IP4]);
268  mp->mtu[VNET_MTU_IP6] = ntohl (swif->mtu[VNET_MTU_IP6]);
269  mp->mtu[VNET_MTU_MPLS] = ntohl (swif->mtu[VNET_MTU_MPLS]);
270 
271  mp->context = context;
272 
273  strncpy ((char *) mp->interface_name,
274  (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
275 
276  if (dev_class && dev_class->name)
277  strncpy ((char *) mp->interface_dev_type, (char *) dev_class->name,
278  ARRAY_LEN (mp->interface_dev_type) - 1);
279 
280  /* Send the L2 address for ethernet physical intfcs */
281  if (swif->sup_sw_if_index == swif->sw_if_index
282  && hi->hw_class_index == ethernet_hw_interface_class.index)
283  {
284  ethernet_main_t *em = ethernet_get_main (am->vlib_main);
286 
287  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
288  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address.mac));
290  }
291  else if (swif->sup_sw_if_index != swif->sw_if_index)
292  {
293  vnet_sub_interface_t *sub = &swif->sub;
294  mp->sub_id = ntohl (sub->id);
295  mp->sub_number_of_tags =
296  sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
299  mp->sub_if_flags =
300  ntohl (sub->eth.raw_flags & SUB_IF_API_FLAG_MASK_VNET);
301  }
302 
303  /* vlan tag rewrite data */
304  u32 vtr_op = L2_VTR_DISABLED;
305  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
306 
307  if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
308  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
309  {
310  // error - default to disabled
311  mp->vtr_op = ntohl (L2_VTR_DISABLED);
312  clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
313  swif->sw_if_index);
314  }
315  else
316  {
317  mp->vtr_op = ntohl (vtr_op);
318  mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
319  mp->vtr_tag1 = ntohl (vtr_tag1);
320  mp->vtr_tag2 = ntohl (vtr_tag2);
321  }
322 
323  /* pbb tag rewrite data */
324  ethernet_header_t eth_hdr;
325  u32 pbb_vtr_op = L2_VTR_DISABLED;
326  u16 outer_tag = 0;
327  u16 b_vlanid = 0;
328  u32 i_sid = 0;
329  clib_memset (&eth_hdr, 0, sizeof (eth_hdr));
330 
331  if (!l2pbb_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
332  &pbb_vtr_op, &outer_tag, &eth_hdr, &b_vlanid, &i_sid))
333  {
334  mp->sub_if_flags |= ntohl (SUB_IF_API_FLAG_DOT1AH);
337  mp->b_vlanid = b_vlanid;
338  mp->i_sid = i_sid;
339  }
340 
341  u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index);
342  if (tag)
343  strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
344 
345  vl_api_send_msg (rp, (u8 *) mp);
346 }
347 
348 static void
350 {
353  vnet_interface_main_t *im = &am->vnet_main->interface_main;
356 
358 
359  if (rp == 0)
360  {
361  clib_warning ("Client %d AWOL", mp->client_index);
362  return;
363  }
364 
365  u8 *filter = 0, *name = 0;
366  sw_if_index = ntohl (mp->sw_if_index);
367 
368  if (!mp->name_filter_valid && sw_if_index != ~0 && sw_if_index != 0)
369  {
370  /* is it a valid sw_if_index? */
372  return;
373 
375 
377  name =
378  format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main,
379  swif, 0);
381  vec_free (name);
382  return;
383  }
384 
385  if (mp->name_filter_valid)
386  {
387  filter = vl_api_from_api_to_new_vec (mp, &mp->name_filter);
388  vec_add1 (filter, 0); /* Ensure it's a C string for strcasecmp() */
389  }
390 
391  char *strcasestr (char *, char *); /* lnx hdr file botch */
392  /* *INDENT-OFF* */
394  {
396  continue;
398  name = format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main,
399  swif, 0);
400 
401  if (filter && !strcasestr((char *) name, (char *) filter))
402  continue;
403 
405  }
406  /* *INDENT-ON* */
407 
408  vec_free (name);
409  vec_free (filter);
410 }
411 
412 static void
415 {
417  vnet_main_t *vnm = vnet_get_main ();
418  vl_api_sw_interface_add_del_address_reply_t *rmp;
419  int rv = 0;
420  u32 is_del;
421  clib_error_t *error = 0;
422  ip46_address_t address;
423 
425 
426  is_del = mp->is_add == 0;
427  vnm->api_errno = 0;
428 
429  if (mp->del_all)
431  else if (ip_address_decode (&mp->prefix.address, &address) == IP46_TYPE_IP6)
433  (void *) &address.ip6,
434  mp->prefix.len, is_del);
435  else
437  (void *) &address.ip4,
438  mp->prefix.len, is_del);
439 
440  if (error)
441  {
442  rv = vnm->api_errno;
444  goto done;
445  }
446 
448 
449 done:
450  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
451 }
452 
453 static void
455 {
456  vl_api_sw_interface_set_table_reply_t *rmp;
457  u32 sw_if_index = ntohl (mp->sw_if_index);
458  u32 table_id = ntohl (mp->vrf_id);
459  int rv = 0;
460 
462 
463  if (mp->is_ipv6)
465  else
467 
469 
470  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
471 }
472 
473 int
475  u32 sw_if_index, u32 table_id, u8 is_api)
476 {
478  u32 fib_index, mfib_index;
480  mfib_source_t msrc;
481 
482  if (is_api)
483  {
485  msrc = MFIB_SOURCE_API;
486  }
487  else
488  {
490  msrc = MFIB_SOURCE_CLI;
491  }
492 
493  /*
494  * This if table does not exist = error is what we want in the end.
495  */
496  fib_index = fib_table_find (fproto, table_id);
497  mfib_index = mfib_table_find (fproto, table_id);
498 
499  if (~0 == fib_index || ~0 == mfib_index)
500  {
501  return (VNET_API_ERROR_NO_SUCH_FIB);
502  }
503 
504  if (FIB_PROTOCOL_IP6 == fproto)
505  {
506  /*
507  * If the interface already has in IP address, then a change int
508  * VRF is not allowed. The IP address applied must first be removed.
509  * We do not do that automatically here, since VPP has no knowledge
510  * of whether those subnets are valid in the destination VRF.
511  */
512  /* *INDENT-OFF* */
514  ia, sw_if_index,
515  1 /* honor unnumbered */ ,
516  ({
517  return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE);
518  }));
519  /* *INDENT-ON* */
520 
521  /*
522  * tell those that are interested that the binding is changing.
523  */
526  cb->function (&ip6_main, cb->function_opaque,
527  sw_if_index,
528  fib_index,
530 
531  /* unlock currently assigned tables */
537  FIB_PROTOCOL_IP6, msrc);
538 
539  if (0 != table_id)
540  {
541  /* we need to lock the table now it's inuse */
542  fib_table_lock (fib_index, FIB_PROTOCOL_IP6, src);
543  mfib_table_lock (mfib_index, FIB_PROTOCOL_IP6, msrc);
544  }
545 
548  }
549  else
550  {
551  /*
552  * If the interface already has in IP address, then a change int
553  * VRF is not allowed. The IP address applied must first be removed.
554  * We do not do that automatically here, since VPP has no knowledge
555  * of whether those subnets are valid in the destination VRF.
556  */
557  /* *INDENT-OFF* */
559  ia, sw_if_index,
560  1 /* honor unnumbered */ ,
561  ({
562  return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE);
563  }));
564  /* *INDENT-ON* */
565 
566  /*
567  * tell those that are interested that the binding is changing.
568  */
571  cb->function (&ip4_main, cb->function_opaque,
572  sw_if_index,
573  fib_index,
575 
576  /* unlock currently assigned tables */
582  FIB_PROTOCOL_IP4, msrc);
583 
584  if (0 != table_id)
585  {
586  /* we need to lock the table now it's inuse */
588  table_id, src);
589 
591  table_id, msrc);
592  }
593 
596  }
597 
598  return (0);
599 }
600 
601 static void
603  u32 context, int retval, u32 vrf_id)
604 {
606 
607  mp = vl_msg_api_alloc (sizeof (*mp));
608  clib_memset (mp, 0, sizeof (*mp));
609  mp->_vl_msg_id =
610  ntohs (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_GET_TABLE_REPLY);
611  mp->context = context;
612  mp->retval = htonl (retval);
613  mp->vrf_id = htonl (vrf_id);
614 
615  vl_api_send_msg (reg, (u8 *) mp);
616 }
617 
618 static void
620 {
622  fib_table_t *fib_table = 0;
623  u32 sw_if_index = ~0;
624  u32 fib_index = ~0;
625  u32 table_id = ~0;
626  fib_protocol_t fib_proto = FIB_PROTOCOL_IP4;
627  int rv = 0;
628 
630  if (!reg)
631  return;
632 
634 
635  sw_if_index = ntohl (mp->sw_if_index);
636 
637  if (mp->is_ipv6)
638  fib_proto = FIB_PROTOCOL_IP6;
639 
640  fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
641  if (fib_index != ~0)
642  {
643  fib_table = fib_table_get (fib_index, fib_proto);
644  table_id = fib_table->ft_table_id;
645  }
646 
648 
650 }
651 
654 {
655  vl_api_sw_interface_set_unnumbered_reply_t *rmp;
656  int rv = 0;
657  vnet_main_t *vnm = vnet_get_main ();
658  u32 sw_if_index = ntohl (mp->sw_if_index);
659  u32 unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
660 
661  /*
662  * The API message field names are backwards from
663  * the underlying data structure names.
664  * It's not worth changing them now.
665  */
666  if (!vnet_sw_interface_is_api_valid (vnm, unnumbered_sw_if_index))
667  {
668  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
669  goto done;
670  }
671 
672  /* Only check the "use loop0" field when setting the binding */
674  {
675  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
676  goto done;
677  }
678 
679  rv = vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
680  sw_if_index, mp->is_add);
681 done:
682  REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
683 }
684 
685 static void
687  mp)
688 {
689  vl_api_sw_interface_clear_stats_reply_t *rmp;
690 
691  vnet_main_t *vnm = vnet_get_main ();
695  int j, n_counters;
696  int rv = 0;
697 
698  if (mp->sw_if_index != ~0)
700 
701  n_counters = vec_len (im->combined_sw_if_counters);
702 
703  for (j = 0; j < n_counters; j++)
704  {
705  im = &vnm->interface_main;
707  if (mp->sw_if_index == (u32) ~ 0)
709  else
711  }
712 
713  n_counters = vec_len (im->sw_if_counters);
714 
715  for (j = 0; j < n_counters; j++)
716  {
717  im = &vnm->interface_main;
718  sm = im->sw_if_counters + j;
719  if (mp->sw_if_index == (u32) ~ 0)
721  else
722  vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
723  }
724 
726 
727  REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
728 }
729 
730 /*
731  * Events used for sw_interface_events
732  */
734 {
741 };
742 
743 static void
746  vl_api_registration_t * vl_reg,
748 {
750 
751  mp = vl_msg_api_alloc (sizeof (*mp));
752  clib_memset (mp, 0, sizeof (*mp));
753  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_EVENT);
754  mp->sw_if_index = ntohl (sw_if_index);
755  mp->client_index = reg->client_index;
756  mp->pid = reg->client_pid;
757  mp->flags = 0;
758  mp->flags |= (events & API_ADMIN_UP_EVENT) ?
762  mp->flags = ntohl (mp->flags);
763  mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? true : false;
764  vl_api_send_msg (vl_reg, (u8 *) mp);
765 }
766 
767 static uword
770 {
772  uword *event_by_sw_if_index = 0;
774  int i;
775  vl_api_registration_t *vl_reg;
776  uword event_type;
777  uword *event_data = 0;
779 
780  vam->link_state_process_up = 1;
781 
782  while (1)
783  {
785 
786  /* Batch up events */
787  while ((event_type = vlib_process_get_events (vm, &event_data)) != ~0)
788  {
789  for (i = 0; i < vec_len (event_data); i++)
790  {
791  sw_if_index = event_data[i];
792  vec_validate_init_empty (event_by_sw_if_index, sw_if_index, 0);
793  event_by_sw_if_index[sw_if_index] |= event_type;
794  }
795  vec_reset_length (event_data);
796  }
797 
798  for (i = 0; i < vec_len (event_by_sw_if_index); i++)
799  {
800  if (event_by_sw_if_index[i] == 0)
801  continue;
802 
803  /* *INDENT-OFF* */
804  pool_foreach (reg, vam->interface_events_registrations)
805  {
807  if (vl_reg)
808  send_sw_interface_event (vam, reg, vl_reg, i, event_by_sw_if_index[i]);
809  }
810  /* *INDENT-ON* */
811  }
812  vec_reset_length (event_by_sw_if_index);
813  }
814 
815  return 0;
816 }
817 
818 static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
819  u32 flags);
821  u32 hw_if_index, u32 flags);
824  u32 flags);
825 
826 /* *INDENT-OFF* */
828  .function = link_state_process,
829  .type = VLIB_NODE_TYPE_PROCESS,
830  .name = "vpe-link-state-process",
831 };
832 /* *INDENT-ON* */
833 
837 
838 static clib_error_t *
840 {
843 
844  if (vam->link_state_process_up)
845  {
850  link_state_process_node.index, event,
851  hi->sw_if_index);
852  }
853  return 0;
854 }
855 
856 static clib_error_t *
858 {
860 
861  /*
862  * Note: it's perfectly fair to set a subif admin up / admin down.
863  * Note the subtle distinction between this routine and the previous
864  * routine.
865  */
866  if (vam->link_state_process_up)
867  {
871  link_state_process_node.index, event,
872  sw_if_index);
873  }
874  return 0;
875 }
876 
877 static clib_error_t *
879 {
881 
882  if (vam->link_state_process_up)
883  {
884  enum api_events event =
887  link_state_process_node.index, event,
888  sw_if_index);
889  }
890  return 0;
891 }
892 
895 {
896  vnet_main_t *vnm = vnet_get_main ();
897  vl_api_sw_interface_tag_add_del_reply_t *rmp;
898  int rv = 0;
899  u8 *tag;
900  u32 sw_if_index = ntohl (mp->sw_if_index);
901 
903 
904  if (mp->is_add)
905  {
906  if (mp->tag[0] == 0)
907  {
908  rv = VNET_API_ERROR_INVALID_VALUE;
909  goto out;
910  }
911 
912  mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
913  tag = format (0, "%s%c", mp->tag, 0);
915  }
916  else
918 
920 out:
921  REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
922 }
923 
926 {
927  vl_api_sw_interface_add_del_mac_address_reply_t *rmp;
928  vnet_main_t *vnm = vnet_get_main ();
929  u32 sw_if_index = ntohl (mp->sw_if_index);
932  int rv = 0;
933 
935 
936  /* for subifs, the MAC should be changed on the actual hw if */
938  error = vnet_hw_interface_add_del_mac_address (vnm, hi->hw_if_index,
939  mp->addr, mp->is_add);
940  if (error)
941  {
942  rv = VNET_API_ERROR_UNIMPLEMENTED;
944  goto out;
945  }
946 
948 out:
949  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY);
950 }
951 
954 {
955  vl_api_sw_interface_set_mac_address_reply_t *rmp;
956  vnet_main_t *vnm = vnet_get_main ();
957  u32 sw_if_index = ntohl (mp->sw_if_index);
960  int rv = 0;
962 
964 
967  error =
969  if (error)
970  {
971  rv = VNET_API_ERROR_UNIMPLEMENTED;
973  goto out;
974  }
975 
977 out:
978  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MAC_ADDRESS_REPLY);
979 }
980 
983 {
986  vnet_main_t *vnm = vnet_get_main ();
987  u32 sw_if_index = ntohl (mp->sw_if_index);
989  ethernet_interface_t *eth_if = 0;
990  int rv = 0;
991 
993 
997 
999 
1001  if (!reg)
1002  return;
1003  rmp = vl_msg_api_alloc (sizeof (*rmp));
1004  rmp->_vl_msg_id =
1005  htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_GET_MAC_ADDRESS_REPLY);
1006  rmp->context = mp->context;
1007  rmp->retval = htonl (rv);
1008  if (!rv && eth_if)
1009  mac_address_encode (&eth_if->address.mac, rmp->mac_address);
1010  vl_api_send_msg (reg, (u8 *) rmp);
1011 }
1012 
1013 static void
1016 {
1017  vl_api_sw_interface_set_interface_name_reply_t *rmp;
1018  vnet_main_t *vnm = vnet_get_main ();
1019  u32 sw_if_index = ntohl (mp->sw_if_index);
1022  int rv = 0;
1023 
1024  if (mp->name[0] == 0)
1025  {
1026  rv = VNET_API_ERROR_INVALID_VALUE;
1027  goto out;
1028  }
1029  if (si == 0)
1030  {
1031  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1032  goto out;
1033  }
1034 
1035  error = vnet_rename_interface (vnm, si->hw_if_index, (char *) mp->name);
1036  if (error)
1037  {
1039  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1040  }
1041 
1042 out:
1043  REPLY_MACRO (VL_API_SW_INTERFACE_SET_INTERFACE_NAME_REPLY);
1044 }
1045 
1048 {
1049  vl_api_sw_interface_set_rx_mode_reply_t *rmp;
1050  vnet_main_t *vnm = vnet_get_main ();
1051  u32 sw_if_index = ntohl (mp->sw_if_index);
1054  int rv = 0;
1056 
1057  VALIDATE_SW_IF_INDEX (mp);
1058 
1061  {
1062  rv = VNET_API_ERROR_INVALID_VALUE;
1063  goto bad_sw_if_index;
1064  }
1065 
1066  rx_mode = (vnet_hw_if_rx_mode) ntohl (mp->mode);
1068  mp->queue_id_valid,
1069  ntohl (mp->queue_id),
1071 
1072  if (error)
1073  {
1074  rv = VNET_API_ERROR_UNIMPLEMENTED;
1076  goto out;
1077  }
1078 
1080 out:
1081  REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_MODE_REPLY);
1082 }
1083 
1084 static void
1086  vl_api_registration_t * rp,
1087  u32 sw_if_index, u32 worker_id,
1088  u32 queue_id, u8 mode, u32 context)
1089 {
1091  mp = vl_msg_api_alloc (sizeof (*mp));
1092  clib_memset (mp, 0, sizeof (*mp));
1093 
1094  mp->_vl_msg_id =
1095  htons (REPLY_MSG_ID_BASE + VL_API_SW_INTERFACE_RX_PLACEMENT_DETAILS);
1096  mp->sw_if_index = htonl (sw_if_index);
1097  mp->queue_id = htonl (queue_id);
1098  mp->worker_id = htonl (worker_id);
1099  mp->mode = htonl (mode);
1100  mp->context = context;
1101 
1102  vl_api_send_msg (rp, (u8 *) mp);
1103 }
1104 
1107 {
1108  vnet_main_t *vnm = vnet_get_main ();
1110  u32 sw_if_index = ntohl (mp->sw_if_index);
1111  vl_api_registration_t *reg;
1112 
1114  if (!reg)
1115  return;
1116 
1117  if (sw_if_index == ~0)
1118  {
1119  vnet_hw_if_rx_queue_t **all_queues = 0;
1120  vnet_hw_if_rx_queue_t **qptr;
1123  vec_add1 (all_queues, q);
1125 
1126  vec_foreach (qptr, all_queues)
1127  {
1128  u32 current_thread = qptr[0]->thread_index;
1129  u32 hw_if_index = qptr[0]->hw_if_index;
1130  vnet_hw_interface_t *hw_if =
1131  vnet_get_hw_interface (vnm, hw_if_index);
1133  am, reg, hw_if->sw_if_index, current_thread, qptr[0]->queue_id,
1134  qptr[0]->mode, mp->context);
1135  }
1136  vec_free (all_queues);
1137  }
1138  else
1139  {
1140  int i;
1142 
1144  {
1145  clib_warning ("sw_if_index %u does not exist", sw_if_index);
1146  goto bad_sw_if_index;
1147  }
1148 
1151  {
1152  clib_warning ("interface type is not HARDWARE! P2P, PIPE and SUB"
1153  " interfaces are not supported");
1154  goto bad_sw_if_index;
1155  }
1156 
1158 
1159  for (i = 0; i < vec_len (hw->rx_queue_indices); i++)
1160  {
1161  vnet_hw_if_rx_queue_t *rxq =
1164  am, reg, hw->sw_if_index, rxq->thread_index, rxq->queue_id,
1165  rxq->mode, mp->context);
1166  }
1167  }
1168 
1170 }
1171 
1174 {
1175  vl_api_sw_interface_set_rx_placement_reply_t *rmp;
1176  vnet_main_t *vnm = vnet_get_main ();
1177  u32 sw_if_index = ntohl (mp->sw_if_index);
1179  clib_error_t *error = 0;
1180  int rv = 0;
1181 
1182  VALIDATE_SW_IF_INDEX (mp);
1183 
1186  {
1187  rv = VNET_API_ERROR_INVALID_VALUE;
1188  goto bad_sw_if_index;
1189  }
1190 
1192  ntohl (mp->queue_id),
1193  ntohl (mp->worker_id), mp->is_main);
1194  if (error)
1195  {
1196  rv = VNET_API_ERROR_UNIMPLEMENTED;
1198  goto out;
1199  }
1200 
1202 out:
1203  REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_PLACEMENT_REPLY);
1204 }
1205 
1206 static void
1208 {
1210  vnet_main_t *vnm = vnet_get_main ();
1211  u32 sw_if_index = (u32) ~ 0;
1213  int rv = 0;
1214  u32 id;
1215  vnet_sw_interface_t template;
1216  uword *p;
1218  u64 sup_and_sub_key;
1219  vl_api_registration_t *reg;
1221 
1222  VALIDATE_SW_IF_INDEX (mp);
1223 
1224  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
1225 
1226  if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
1227  {
1228  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1229  goto out;
1230  }
1231 
1232  id = ntohl (mp->vlan_id);
1233  if (id == 0 || id > 4095)
1234  {
1235  rv = VNET_API_ERROR_INVALID_VLAN;
1236  goto out;
1237  }
1238 
1239  sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
1240 
1241  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1242  if (p)
1243  {
1244  rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
1245  goto out;
1246  }
1247 
1248  clib_memset (&template, 0, sizeof (template));
1249  template.type = VNET_SW_INTERFACE_TYPE_SUB;
1250  template.flood_class = VNET_FLOOD_CLASS_NORMAL;
1251  template.sup_sw_if_index = hi->sw_if_index;
1252  template.sub.id = id;
1253  template.sub.eth.raw_flags = 0;
1254  template.sub.eth.flags.one_tag = 1;
1255  template.sub.eth.outer_vlan_id = id;
1256  template.sub.eth.flags.exact_match = 1;
1257 
1258  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1259  if (error)
1260  {
1262  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1263  goto out;
1264  }
1265 
1266  u64 *kp = clib_mem_alloc (sizeof (*kp));
1267  *kp = sup_and_sub_key;
1268 
1269  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
1271 
1273 
1274 out:
1276  if (!reg)
1277  return;
1278 
1279  rmp = vl_msg_api_alloc (sizeof (*rmp));
1280  rmp->_vl_msg_id = htons (REPLY_MSG_ID_BASE + VL_API_CREATE_VLAN_SUBIF_REPLY);
1281  rmp->context = mp->context;
1282  rmp->retval = htonl (rv);
1283  rmp->sw_if_index = htonl (sw_if_index);
1284  vl_api_send_msg (reg, (u8 *) rmp);
1285 }
1286 
1287 static void
1289 {
1291  vnet_main_t *vnm = vnet_get_main ();
1292  u32 sub_sw_if_index = ~0;
1294  int rv = 0;
1295 
1296  VALIDATE_SW_IF_INDEX (mp);
1297 
1298  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
1299 
1300  if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
1301  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1302  else
1303  rv = vnet_create_sub_interface (ntohl (mp->sw_if_index),
1304  ntohl (mp->sub_id),
1305  ntohl (mp->sub_if_flags),
1306  ntohs (mp->inner_vlan_id),
1307  ntohs (mp->outer_vlan_id),
1308  &sub_sw_if_index);
1309 
1311 
1312  /* *INDENT-OFF* */
1313  REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
1314  ({
1315  rmp->sw_if_index = ntohl(sub_sw_if_index);
1316  }));
1317  /* *INDENT-ON* */
1318 }
1319 
1320 static void
1322 {
1323  vl_api_delete_subif_reply_t *rmp;
1324  int rv;
1325 
1326  rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
1327 
1328  REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
1329 }
1330 
1331 static void
1333  mp)
1334 {
1335  vl_api_interface_name_renumber_reply_t *rmp;
1336  int rv = 0;
1337 
1338  VALIDATE_SW_IF_INDEX (mp);
1339 
1341  (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
1342 
1344 
1345  REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
1346 }
1347 
1348 static void
1350 {
1352  u32 sw_if_index;
1353  int rv;
1355 
1358 
1359  /* *INDENT-OFF* */
1360  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
1361  ({
1362  rmp->sw_if_index = ntohl (sw_if_index);
1363  }));
1364  /* *INDENT-ON* */
1365 }
1366 
1369 {
1371  u32 sw_if_index;
1372  u8 is_specified = mp->is_specified;
1373  u32 user_instance = ntohl (mp->user_instance);
1374  int rv;
1376 
1379  is_specified, user_instance);
1380 
1381  /* *INDENT-OFF* */
1382  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY,
1383  ({
1384  rmp->sw_if_index = ntohl (sw_if_index);
1385  }));
1386  /* *INDENT-ON* */
1387 }
1388 
1389 static void
1391 {
1392  vl_api_delete_loopback_reply_t *rmp;
1393  u32 sw_if_index;
1394  int rv;
1395 
1396  sw_if_index = ntohl (mp->sw_if_index);
1398 
1399  REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
1400 }
1401 
1402 static void
1405 {
1406  vl_api_collect_detailed_interface_stats_reply_t *rmp;
1407  int rv = 0;
1408 
1409  rv =
1411  mp->enable_disable);
1412 
1413  REPLY_MACRO (VL_API_COLLECT_DETAILED_INTERFACE_STATS_REPLY);
1414 }
1415 
1416 static void
1419 {
1420  vl_api_sw_interface_address_replace_begin_reply_t *rmp;
1421  int rv = 0;
1422 
1424 
1425  REPLY_MACRO (VL_API_SW_INTERFACE_ADDRESS_REPLACE_BEGIN_REPLY);
1426 }
1427 
1428 static void
1431 {
1432  vl_api_sw_interface_address_replace_end_reply_t *rmp;
1433  int rv = 0;
1434 
1436 
1437  REPLY_MACRO (VL_API_SW_INTERFACE_ADDRESS_REPLACE_END_REPLY);
1438 }
1439 
1440 /*
1441  * vpe_api_hookup
1442  * Add vpe's API message handlers to the table.
1443  * vlib has already mapped shared memory and
1444  * added the client registration handlers.
1445  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1446  */
1447 
1448 pub_sub_handler (interface_events, INTERFACE_EVENTS);
1449 
1450 #include <vnet/interface.api.c>
1451 static clib_error_t *
1453 {
1455 
1456  /* Mark these APIs as mp safe */
1457  am->is_mp_safe[VL_API_SW_INTERFACE_DUMP] = 1;
1458  am->is_mp_safe[VL_API_SW_INTERFACE_DETAILS] = 1;
1459  am->is_mp_safe[VL_API_SW_INTERFACE_TAG_ADD_DEL] = 1;
1460  am->is_mp_safe[VL_API_SW_INTERFACE_SET_INTERFACE_NAME] = 1;
1461 
1462  /* Do not replay VL_API_SW_INTERFACE_DUMP messages */
1463  am->api_trace_cfg[VL_API_SW_INTERFACE_DUMP].replay_enable = 0;
1464 
1465  /*
1466  * Set up the (msg_name, crc, message-id) table
1467  */
1469 
1470  return 0;
1471 }
1472 
1474 
1475 /*
1476  * fd.io coding-style-patch-verification: ON
1477  *
1478  * Local Variables:
1479  * eval: (c-set-style "gnu")
1480  * End:
1481  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
SUB_IF_API_FLAG_MASK_VNET
@ SUB_IF_API_FLAG_MASK_VNET
Definition: interface_types.api:52
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
vl_api_sw_interface_rx_placement_dump_t::client_index
u32 client_index
Definition: interface.api:485
vl_api_sw_interface_set_ip_directed_broadcast_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:90
im
vnet_interface_main_t * im
Definition: interface_output.c:415
vl_api_sw_interface_get_table_reply_t
Reply to get_sw_interface_vrf.
Definition: interface.api:315
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
api.h
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
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(link_up_down_function)
vl_api_sw_interface_get_table_t::client_index
u32 client_index
Definition: interface.api:305
vl_api_sw_interface_set_mac_address_t_handler
static void vl_api_sw_interface_set_mac_address_t_handler(vl_api_sw_interface_set_mac_address_t *mp)
Definition: interface_api.c:953
vl_api_sw_interface_address_replace_begin_t
IP interface address replace begin.
Definition: interface.api:263
vnet_sub_interface_t::eth
struct vnet_sub_interface_t::@374 eth
mac
vl_api_mac_address_t mac
Definition: l2.api:559
VNET_SW_INTERFACE_TYPE_PIPE
@ VNET_SW_INTERFACE_TYPE_PIPE
Definition: interface.h:769
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
vl_api_sw_interface_rx_placement_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:509
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vnet_sw_interface_t::type
vnet_sw_interface_type_t type
Definition: interface.h:871
vl_api_sw_interface_rx_placement_dump_t
dump the rx queue placement of interface(s)
Definition: interface.api:483
vl_api_collect_detailed_interface_stats_t_handler
static void vl_api_collect_detailed_interface_stats_t_handler(vl_api_collect_detailed_interface_stats_t *mp)
Definition: interface_api.c:1404
vl_api_sw_interface_set_ip_directed_broadcast_t_handler
static void vl_api_sw_interface_set_ip_directed_broadcast_t_handler(vl_api_sw_interface_set_ip_directed_broadcast_t *mp)
Definition: interface_api.c:208
vl_api_sw_interface_tag_add_del_t::is_add
bool is_add
Definition: interface.api:361
API_ADMIN_UP_EVENT
@ API_ADMIN_UP_EVENT
Definition: interface_api.c:737
foreach_ip_interface_address
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: ip_interface.h:57
vnet_hw_interface_set_mtu
void vnet_hw_interface_set_mtu(vnet_main_t *vnm, u32 hw_if_index, u32 mtu)
Definition: interface.c:775
vnet_sw_interface_t
Definition: interface.h:869
vnet_sub_interface_t::raw_flags
u16 raw_flags
Definition: interface.h:787
rx_mode
rx_mode
Definition: interface_types.api:56
vnet_device_class_t
struct _vnet_device_class vnet_device_class_t
vnet_sub_interface_t::flags
struct vnet_sub_interface_t::@374::@375::@377 flags
vl_api_create_vlan_subif_t::vlan_id
u32 vlan_id
Definition: interface.api:554
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
ip4_main_t::lookup_main
ip_lookup_main_t lookup_main
Definition: ip4.h:109
vl_api_sw_interface_dump_t_handler
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
Definition: interface_api.c:349
vl_api_sw_interface_dump_t::name_filter
string name_filter[]
Definition: interface.api:223
vl_api_sw_interface_get_table_reply_t::context
u32 context
Definition: interface.api:317
send_interface_rx_placement_details
static void send_interface_rx_placement_details(vpe_api_main_t *am, vl_api_registration_t *rp, u32 sw_if_index, u32 worker_id, u32 queue_id, u8 mode, u32 context)
Definition: interface_api.c:1085
vnet_hw_if_rxq_cmp_cli_api
static_always_inline int vnet_hw_if_rxq_cmp_cli_api(vnet_hw_if_rx_queue_t **a, vnet_hw_if_rx_queue_t **b)
Definition: rx_queue_funcs.h:99
VNET_SW_INTERFACE_ADD_DEL_FUNCTION
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(sw_interface_add_del_function)
vl_api_sw_interface_set_flags_t::flags
vl_api_if_status_flags_t flags
Definition: interface.api:40
msg_id_base
static u16 msg_id_base
Definition: interface_api.c:45
link_state_process_node
static vlib_node_registration_t link_state_process_node
(constructor) VLIB_REGISTER_NODE (link_state_process_node)
Definition: interface_api.c:827
vnet_interface_name_renumber
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1474
vnet_sub_interface_t::outer_vlan_id
u16 outer_vlan_id
Definition: interface.h:783
ip4_main_t::table_bind_callbacks
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip4.h:145
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1104
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
IF_STATUS_API_FLAG_LINK_UP
@ IF_STATUS_API_FLAG_LINK_UP
Definition: interface_types.api:23
vnet_hw_if_rx_queue_t::mode
vnet_hw_if_rx_mode mode
Definition: interface.h:597
ethernet_set_flags
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:441
vlib_process_wait_for_event
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:660
f
vlib_frame_t * f
Definition: interface_output.c:1098
vnet_hw_if_get_rx_queue
static_always_inline vnet_hw_if_rx_queue_t * vnet_hw_if_get_rx_queue(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:43
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
l2pbb_get
u32 l2pbb_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u16 *outer_tag, ethernet_header_t *eth_hdr, u16 *b_vlanid, u32 *i_sid)
Get pbb tag rewrite on the given interface.
Definition: l2_vtr.c:686
name
string name[64]
Definition: fib.api:25
vl_api_sw_interface_tag_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:362
vl_api_create_vlan_subif_t::client_index
u32 client_index
Definition: interface.api:551
api_types.h
vnet_sub_interface_t::inner_vlan_id
u16 inner_vlan_id
Definition: interface.h:784
MFIB_SOURCE_API
@ MFIB_SOURCE_API
Definition: mfib_types.h:165
vnet_create_sub_interface
int vnet_create_sub_interface(u32 sw_if_index, u32 id, u32 flags, u16 inner_vlan_id, u16 outer_vlan_id, u32 *sub_sw_if_index)
Definition: interface.c:1053
vlib_clear_combined_counters
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:61
vl_api_interface_name_renumber_t
Definition: interface.api:516
ethernet_header_t::dst_address
u8 dst_address[6]
Definition: packet.h:55
vnet_hw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:670
vl_api_sw_interface_get_table_t::is_ipv6
bool is_ipv6
Definition: interface.api:308
vl_api_sw_interface_rx_placement_details_t::mode
vl_api_rx_mode_t mode
Definition: interface.api:512
ethernet_header_t::src_address
u8 src_address[6]
Definition: packet.h:56
vl_api_sw_interface_set_promisc_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:53
vl_api_sw_interface_get_table_reply_t::retval
i32 retval
Definition: interface.api:318
vl_api_sw_interface_set_unnumbered_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:333
vl_api_sw_interface_address_replace_begin_t_handler
static void vl_api_sw_interface_address_replace_begin_t_handler(vl_api_sw_interface_address_replace_begin_t *mp)
Definition: interface_api.c:1418
vnet_hw_if_rx_queue_t::thread_index
u32 thread_index
Definition: interface.h:588
admin_up_down_function
static clib_error_t * admin_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: interface_api.c:857
MFIB_SOURCE_CLI
@ MFIB_SOURCE_CLI
Definition: mfib_types.h:166
vl_api_sw_interface_add_del_address_t::is_add
bool is_add
Definition: interface.api:239
set_hw_interface_rx_placement
clib_error_t * set_hw_interface_rx_placement(u32 hw_if_index, u32 queue_id, u32 thread_index, u8 is_main)
Definition: interface_cli.c:1709
vl_api_sw_interface_get_mac_address_reply_t
Reply for get interface's MAC address request.
Definition: interface.api:413
vpe_api_main_t
Definition: api_helper_macros.h:414
vl_api_create_loopback_reply_t
Create loopback interface response.
Definition: interface.api:597
SUB_IF_API_FLAG_DOT1AH
@ SUB_IF_API_FLAG_DOT1AH
Definition: interface_types.api:53
send_sw_interface_event
static void send_sw_interface_event(vpe_api_main_t *am, vpe_client_registration_t *reg, vl_api_registration_t *vl_reg, u32 sw_if_index, enum api_events events)
Definition: interface_api.c:744
VNET_SW_INTERFACE_TYPE_SUB
@ VNET_SW_INTERFACE_TYPE_SUB
Definition: interface.h:767
mfib_table_find_or_create_and_lock
u32 mfib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, mfib_source_t src)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:613
vl_api_sw_interface_address_replace_end_t
IP interface address replace end.
Definition: interface.api:276
vnet_swif_is_api_visible
static uword vnet_swif_is_api_visible(vnet_sw_interface_t *si)
Definition: interface_funcs.h:272
send_sw_interface_get_table_reply
static void send_sw_interface_get_table_reply(vl_api_registration_t *reg, u32 context, int retval, u32 vrf_id)
Definition: interface_api.c:602
VNET_MTU_MPLS
@ VNET_MTU_MPLS
Definition: interface.h:833
vl_api_sw_interface_address_replace_end_t_handler
static void vl_api_sw_interface_address_replace_end_t_handler(vl_api_sw_interface_address_replace_end_t *mp)
Definition: interface_api.c:1430
vnet_interface_main_t
Definition: interface.h:990
vl_api_sw_interface_dump_t::client_index
u32 client_index
Definition: interface.api:219
vl_api_create_vlan_subif_reply_t
Reply for the vlan subinterface create request.
Definition: interface.api:562
VNET_FLOOD_CLASS_NORMAL
@ VNET_FLOOD_CLASS_NORMAL
Definition: interface.h:819
fib_table.h
vl_api_sw_interface_details_t::i_sid
u32 i_sid
Definition: interface.api:200
vl_api_sw_interface_details_t::b_vlanid
u16 b_vlanid
Definition: interface.api:199
vpe_api_main_t::vlib_main
vlib_main_t * vlib_main
Definition: api_helper_macros.h:425
vl_api_sw_interface_set_rx_placement_t::worker_id
u32 worker_id
Definition: interface.api:457
vl_api_sw_interface_set_ip_directed_broadcast_t
Set IP4 directed broadcast The directed broadcast enabled a packet sent to the interface's subnet add...
Definition: interface.api:86
vl_api_delete_loopback_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:641
u16
unsigned short u16
Definition: types.h:57
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
vl_api_sw_interface_set_rx_mode_t::mode
vl_api_rx_mode_t mode
Definition: interface.api:437
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
vl_api_sw_interface_get_mac_address_reply_t::context
u32 context
Definition: interface.api:415
vl_api_sw_interface_details_t::flags
vl_api_if_status_flags_t flags
Definition: interface.api:163
am
app_main_t * am
Definition: application.c:489
VNET_SW_INTERFACE_FLAG_ADMIN_UP
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:844
vl_api_sw_interface_set_promisc_t::promisc_on
bool promisc_on
Definition: interface.api:54
vl_api_sw_interface_details_t::vtr_tag1
u32 vtr_tag1
Definition: interface.api:192
ethernet_hw_interface_class
vnet_hw_interface_class_t ethernet_hw_interface_class
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vl_api_sw_interface_set_mtu_t::mtu
u32 mtu[4]
Definition: interface.api:77
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
vl_api_sw_interface_get_table_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:307
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
vnet_sub_interface_t
Definition: interface.h:772
VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:575
vl_api_hw_interface_set_mtu_t
Set interface physical MTU.
Definition: interface.api:63
vl_api_sw_interface_set_rx_mode_t_handler
static void vl_api_sw_interface_set_rx_mode_t_handler(vl_api_sw_interface_set_rx_mode_t *mp)
Definition: interface_api.c:1047
vnet_interface_main_t::sw_if_counters
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:1023
ip4_table_bind_callback_t::function_opaque
uword function_opaque
Definition: ip4.h:95
vl_api_sw_interface_set_interface_name_t
Set custom interface name Set custom interface name for the interface.
Definition: interface.api:469
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
vnet_get_device_class
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
Definition: interface_funcs.h:124
vl_api_sw_interface_set_rx_mode_t::queue_id_valid
bool queue_id_valid
Definition: interface.api:435
vl_api_sw_interface_add_del_mac_address_t_handler
static void vl_api_sw_interface_add_del_mac_address_t_handler(vl_api_sw_interface_add_del_mac_address_t *mp)
Definition: interface_api.c:925
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:47
vnet_interface_main_t::hw_if_rx_queues
vnet_hw_if_rx_queue_t * hw_if_rx_queues
Definition: interface.h:996
vl_api_sw_interface_set_promisc_t
Set interface promiscuous mode.
Definition: interface.api:49
vlib_frame_t
Definition: node.h:372
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
vl_api_sw_interface_get_mac_address_reply_t::retval
i32 retval
Definition: interface.api:416
vl_api_sw_interface_details_t::sub_id
u32 sub_id
Definition: interface.api:180
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(interface_api_hookup)
vl_api_create_subif_t::outer_vlan_id
u16 outer_vlan_id
Definition: interface.api:532
ethernet.h
error
Definition: cJSON.c:88
vnet_sw_interface_ip_directed_broadcast
void vnet_sw_interface_ip_directed_broadcast(vnet_main_t *vnm, u32 sw_if_index, u8 enable)
Definition: interface.c:748
set_hw_interface_change_rx_mode
clib_error_t * set_hw_interface_change_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u8 queue_id_valid, u32 queue_id, vnet_hw_if_rx_mode mode)
Definition: interface_cli.c:1508
ip6_table_bind_callback_t::function
ip6_table_bind_function_t * function
Definition: ip6.h:106
vl_api_sw_interface_get_mac_address_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:405
vl_api_sw_interface_details_t::sup_sw_if_index
u32 sup_sw_if_index
Definition: interface.api:158
vl_api_sw_interface_get_table_t
Get VRF id assigned to interface.
Definition: interface.api:303
vl_api_sw_interface_details_t::link_speed
u32 link_speed
Definition: interface.api:171
vl_api_create_loopback_instance_reply_t
Create loopback interface instance response.
Definition: interface.api:625
vl_api_collect_detailed_interface_stats_t::enable_disable
bool enable_disable
Definition: interface.api:656
vl_api_sw_interface_details_t
Interface details structure (fix this)
Definition: interface.api:151
vl_api_sw_interface_details_t::b_dmac
vl_api_mac_address_t b_dmac
Definition: interface.api:197
vnet_sw_interface_is_api_valid
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:285
ip_address_decode
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:172
vl_api_sw_interface_details_t::sub_inner_vlan_id
u16 sub_inner_vlan_id
Definition: interface.api:185
vnet_get_sw_interface_tag
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:131
ip4_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:120
ethernet_main_t_::interfaces
ethernet_interface_t * interfaces
Definition: ethernet.h:303
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
vl_api_sw_interface_dump_t
Request all or filtered subset of sw_interface_details.
Definition: interface.api:217
vl_api_sw_interface_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xFFFFFFFF]
Definition: interface.api:221
fib_table_t_
A protocol Independent FIB table.
Definition: fib_table.h:71
ip_interface_address_mark
void ip_interface_address_mark(void)
Definition: ip_interface.c:229
mfib_table_lock
void mfib_table_lock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Release a reference counting lock on the table.
Definition: mfib_table.c:806
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vl_api_sw_interface_add_del_address_t
Set or delete one or all ip addresses on a specified interface.
Definition: interface.api:234
vl_api_sw_interface_set_interface_name_t::name
string name[64]
Definition: interface.api:474
vl_api_sw_interface_set_unnumbered_t_handler
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
Definition: interface_api.c:653
mfib_source_t
enum mfib_source_t_ mfib_source_t
Possible [control plane] sources of MFIB entries.
vnet_hw_if_rx_queue_t::queue_id
u32 queue_id
Definition: interface.h:594
ip6_add_del_interface_address
clib_error_t * ip6_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 is_del)
Definition: ip6_forward.c:298
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_sw_interface_clear_stats_t
Clear interface statistics.
Definition: interface.api:343
vl_api_create_loopback_instance_t
Create loopback interface instance request.
Definition: interface.api:611
vl_api_collect_detailed_interface_stats_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:655
vl_api_sw_interface_rx_placement_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:487
ip4_add_del_interface_address
clib_error_t * ip4_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 is_del)
Definition: ip4_forward.c:830
vl_api_sw_interface_details_t::interface_dev_type
string interface_dev_type[64]
Definition: interface.api:204
vl_api_sw_interface_details_t::vtr_tag2
u32 vtr_tag2
Definition: interface.api:193
vl_api_sw_interface_rx_placement_dump_t_handler
static void vl_api_sw_interface_rx_placement_dump_t_handler(vl_api_sw_interface_rx_placement_dump_t *mp)
Definition: interface_api.c:1106
VNET_MTU_IP4
@ VNET_MTU_IP4
Definition: interface.h:831
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vnet_sw_interface_update_unnumbered
int vnet_sw_interface_update_unnumbered(u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable)
Definition: interface.c:1661
ethernet_main_t_
Definition: ethernet.h:288
vl_api_create_subif_t
Definition: interface.api:524
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
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
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
vl_api_create_subif_t::sub_if_flags
vl_api_sub_if_flags_t sub_if_flags
Definition: interface.api:531
link_up_down_function
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: interface_api.c:839
IF_STATUS_API_FLAG_ADMIN_UP
@ IF_STATUS_API_FLAG_ADMIN_UP
Definition: interface_types.api:22
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vl_api_sw_interface_event_t::pid
u32 pid
Definition: interface.api:104
vl_api_sw_interface_event_t::client_index
u32 client_index
Definition: interface.api:103
fib_table_t_::ft_table_id
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
vl_api_sw_interface_details_t::interface_name
string interface_name[64]
Definition: interface.api:203
vl_api_delete_subif_t
Delete sub interface request.
Definition: interface.api:574
VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
Definition: interface.h:573
fib_table_find_or_create_and_lock
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1170
vl_api_sw_interface_set_rx_placement_t
Set an interface's rx-placement Rx-Queue placement on specific thread is operational for only hardwar...
Definition: interface.api:451
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vpe_client_registration_t::client_pid
u32 client_pid
Definition: api_helper_macros.h:411
vl_api_create_vlan_subif_t::context
u32 context
Definition: interface.api:552
vnet_create_loopback_interface
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
Definition: interface.c:831
vl_api_sw_interface_add_del_mac_address_t::sw_if_index
u32 sw_if_index
Definition: interface.api:377
rx_queue_funcs.h
vl_api_create_subif_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:528
vnet_hw_if_rx_mode
vnet_hw_if_rx_mode
Definition: interface.h:53
L2_VTR_DISABLED
@ L2_VTR_DISABLED
Definition: l2_vtr.h:30
vl_api_sw_interface_clear_stats_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:347
vl_api_create_subif_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:540
vl_api_sw_interface_rx_placement_details_t::queue_id
u32 queue_id
Definition: interface.api:510
vnet_create_sw_interface
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:619
vl_api_create_loopback_t
Create loopback interface request.
Definition: interface.api:585
uword
u64 uword
Definition: types.h:112
vl_api_sw_interface_get_mac_address_t::client_index
u32 client_index
Definition: interface.api:403
vlib_zero_combined_counter
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:298
vl_api_sw_interface_details_t::sub_number_of_tags
u8 sub_number_of_tags
Definition: interface.api:183
l2_vtr.h
ethernet_header_t
Definition: packet.h:52
vl_api_sw_interface_details_t::mtu
u32 mtu[4]
Definition: interface.api:177
vl_api_sw_interface_set_flags_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:39
vl_api_sw_interface_add_del_mac_address_t::is_add
u8 is_add
Definition: interface.api:379
ip6_main_t::table_bind_callbacks
ip6_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip6.h:151
vl_api_sw_interface_set_rx_mode_t
Set an interface's rx-mode.
Definition: interface.api:430
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: interface_api.c:42
IF_API_TYPE_PIPE
@ IF_API_TYPE_PIPE
Definition: interface_types.api:73
vl_api_sw_interface_add_del_address_t::del_all
bool del_all
Definition: interface.api:241
vl_api_create_loopback_t_handler
static void vl_api_create_loopback_t_handler(vl_api_create_loopback_t *mp)
Definition: interface_api.c:1349
ethernet_interface
Definition: ethernet.h:146
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
vnet_set_sw_interface_tag
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
Definition: interface_funcs.h:141
interface.h
vl_api_sw_interface_set_rx_placement_t::queue_id
u32 queue_id
Definition: interface.api:456
vl_api_sw_interface_set_mtu_t_handler
static void vl_api_sw_interface_set_mtu_t_handler(vl_api_sw_interface_set_mtu_t *mp)
Definition: interface_api.c:185
events
static perfmon_event_t events[]
Definition: core.c:21
ip6_table_bind_callback_t::function_opaque
uword function_opaque
Definition: ip6.h:107
link_state_process
static uword link_state_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: interface_api.c:768
vl_api_sw_interface_set_table_t_handler
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
Definition: interface_api.c:454
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
vl_api_sw_interface_details_t::l2_address
vl_api_mac_address_t l2_address
Definition: interface.api:161
vl_api_delete_loopback_t_handler
static void vl_api_delete_loopback_t_handler(vl_api_delete_loopback_t *mp)
Definition: interface_api.c:1390
ip6_main_t::fib_index_by_sw_if_index
u32 * fib_index_by_sw_if_index
Definition: ip6.h:127
address
manual_print typedef address
Definition: ip_types.api:96
API_SW_INTERFACE_ADD_EVENT
@ API_SW_INTERFACE_ADD_EVENT
Definition: interface_api.c:739
vl_api_sw_interface_set_unnumbered_t
Set unnumbered interface add / del request.
Definition: interface.api:329
src
vl_api_address_t src
Definition: gre.api:54
VNET_HW_INTERFACE_BOND_INFO_SLAVE
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:715
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
vnet_rename_interface
clib_error_t * vnet_rename_interface(vnet_main_t *vnm, u32 hw_if_index, char *new_name)
Definition: interface.c:1503
vl_api_create_vlan_subif_t_handler
static void vl_api_create_vlan_subif_t_handler(vl_api_create_vlan_subif_t *mp)
Definition: interface_api.c:1207
vl_api_sw_interface_details_t::b_smac
vl_api_mac_address_t b_smac
Definition: interface.api:198
vl_api_sw_interface_set_rx_placement_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:455
vl_api_sw_interface_tag_add_del_t
Set / clear software interface tag.
Definition: interface.api:357
vl_api_sw_interface_dump_t::name_filter_valid
bool name_filter_valid
Definition: interface.api:222
vl_api_sw_interface_get_table_t::context
u32 context
Definition: interface.api:306
vl_api_sw_interface_set_flags_t
Set flags on the interface.
Definition: interface.api:35
vl_api_sw_interface_tag_add_del_t::tag
string tag[64]
Definition: interface.api:363
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
mfib_table.h
vl_api_sw_interface_details_t::link_duplex
vl_api_link_duplex_t link_duplex
Definition: interface.api:168
vl_api_sw_interface_rx_placement_details_t::context
u32 context
Definition: interface.api:508
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vl_api_sw_interface_dump_t::context
u32 context
Definition: interface.api:220
vnet_interface_main_t::combined_sw_if_counters
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:1024
ip6_table_bind_callback_t
Definition: ip6.h:104
fib_api.h
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1015
ip4_table_bind_callback_t
Definition: ip4.h:92
VNET_MTU_IP6
@ VNET_MTU_IP6
Definition: interface.h:832
vl_api_interface_name_renumber_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:520
vl_api_sw_interface_set_promisc_t_handler
static void vl_api_sw_interface_set_promisc_t_handler(vl_api_sw_interface_set_promisc_t *mp)
Definition: interface_api.c:108
vl_api_sw_interface_details_t::vtr_push_dot1q
u32 vtr_push_dot1q
Definition: interface.api:191
mfib_table_unlock
void mfib_table_unlock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Take a reference counting lock on the table.
Definition: mfib_table.c:777
ethernet_get_interface
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:982
vl_api_sw_interface_set_interface_name_t_handler
static void vl_api_sw_interface_set_interface_name_t_handler(vl_api_sw_interface_set_interface_name_t *mp)
Definition: interface_api.c:1014
vl_api_sw_interface_add_del_address_t_handler
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
Definition: interface_api.c:414
vl_api_sw_interface_set_rx_mode_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:434
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vnet_main_t::api_errno
vnet_api_error_t api_errno
Definition: vnet.h:109
vl_api_interface_name_renumber_t_handler
static void vl_api_interface_name_renumber_t_handler(vl_api_interface_name_renumber_t *mp)
Definition: interface_api.c:1332
IF_API_TYPE_HARDWARE
@ IF_API_TYPE_HARDWARE
Definition: interface_types.api:68
vl_api_create_subif_reply_t
Definition: interface.api:536
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2785
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
vnet_sw_if_index_is_api_valid
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)
Definition: api_helper_macros.h:276
vl_api_create_loopback_instance_t::user_instance
u32 user_instance
Definition: interface.api:617
API_SW_INTERFACE_DEL_EVENT
@ API_SW_INTERFACE_DEL_EVENT
Definition: interface_api.c:740
vl_api_delete_loopback_t
Delete loopback interface request.
Definition: interface.api:637
id
u8 id[64]
Definition: dhcp.api:160
ethernet_interface_address::mac
mac_address_t mac
Definition: ethernet.h:139
true
#define true
Definition: cJSON.c:65
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
vl_api_create_loopback_instance_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:629
vl_api_create_loopback_instance_t_handler
static void vl_api_create_loopback_instance_t_handler(vl_api_create_loopback_instance_t *mp)
Definition: interface_api.c:1368
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vl_api_create_subif_t::inner_vlan_id
u16 inner_vlan_id
Definition: interface.api:533
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
VNET_N_MTU
@ VNET_N_MTU
Definition: interface.h:834
vl_api_sw_interface_set_table_t::vrf_id
u32 vrf_id
Definition: interface.api:295
vnet_delete_loopback_interface
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:1033
vl_api_sw_interface_event_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:105
vl_api_sw_interface_get_table_reply_t::vrf_id
u32 vrf_id
Definition: interface.api:319
ip4_main_t::mfib_index_by_sw_if_index
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:123
vl_api_create_vlan_subif_reply_t::context
u32 context
Definition: interface.api:564
vl_api_sw_interface_details_t::sub_if_flags
vl_api_sub_if_flags_t sub_if_flags
Definition: interface.api:187
vl_api_sw_interface_details_t::link_mtu
u16 link_mtu
Definition: interface.api:174
ethernet_main
ethernet_main_t ethernet_main
Definition: init.c:45
vl_api_sw_interface_set_interface_name_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:473
vl_api_sw_interface_set_table_t::is_ipv6
bool is_ipv6
Definition: interface.api:294
mac_address_encode
void mac_address_encode(const mac_address_t *in, u8 *out)
Definition: ethernet_types_api.c:26
format_fns.h
u64
unsigned long u64
Definition: types.h:89
vl_api_sw_interface_details_t::vtr_op
u32 vtr_op
Definition: interface.api:190
mfib_table_find
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:555
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vl_api_sw_interface_details_t::context
u32 context
Definition: interface.api:153
vlib_combined_counter_main_t
A collection of combined counters.
Definition: counter.h:203
vlib_zero_simple_counter
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:154
ip_table_bind
int ip_table_bind(fib_protocol_t fproto, u32 sw_if_index, u32 table_id, u8 is_api)
Definition: interface_api.c:474
vl_api_sw_interface_set_rx_placement_t::is_main
bool is_main
Definition: interface.api:458
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
fib_table_get
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:29
vl_api_sw_interface_rx_placement_details_t::worker_id
u32 worker_id
Definition: interface.api:511
fib_table_get_index_for_sw_if_index
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:1003
vl_api_delete_subif_t_handler
static void vl_api_delete_subif_t_handler(vl_api_delete_subif_t *mp)
Definition: interface_api.c:1321
fib_table_lock
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
Definition: fib_table.c:1361
vl_api_sw_interface_details_t::type
vl_api_if_type_t type
Definition: interface.api:165
ip.h
ip6_main_t::mfib_index_by_sw_if_index
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip6.h:130
u32
unsigned int u32
Definition: types.h:88
api_events
api_events
Definition: interface_api.c:733
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
vl_api_sw_interface_set_mac_address_t
Set an interface's MAC address.
Definition: interface.api:388
ip_interface_address_sweep
void ip_interface_address_sweep(void)
Definition: ip_interface.c:289
vnet_sub_interface_t::id
u32 id
Definition: interface.h:778
l2vtr_get
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
Definition: l2_vtr.c:347
table_id
u32 table_id
Definition: wireguard.api:102
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
vnet_clear_sw_interface_tag
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:156
ethernet_types_api.h
si
vnet_sw_interface_t * si
Definition: interface_output.c:418
pub_sub_handler
pub_sub_handler(interface_events, INTERFACE_EVENTS)
vl_api_sw_interface_event_t
Interface Event generated by want_interface_events.
Definition: interface.api:101
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
interface_api_hookup
static clib_error_t * interface_api_hookup(vlib_main_t *vm)
Definition: interface_api.c:1452
IF_API_TYPE_P2P
@ IF_API_TYPE_P2P
Definition: interface_types.api:72
vl_api_delete_subif_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:577
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
FIB_SOURCE_CLI
@ FIB_SOURCE_CLI
From the CLI.
Definition: fib_source.h:79
mac_address_decode
void mac_address_decode(const u8 *in, mac_address_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
Definition: ethernet_types_api.c:20
ip4_table_bind_callback_t::function
ip4_table_bind_function_t * function
Definition: ip4.h:94
FIB_SOURCE_API
@ FIB_SOURCE_API
From the control plane API.
Definition: fib_source.h:75
ip6_main_t::lookup_main
ip_lookup_main_t lookup_main
Definition: ip6.h:112
vl_api_sw_interface_details_t::tag
string tag[64]
Definition: interface.api:205
vpe_api_main_t::link_state_process_up
foreach_registration_hash u8 link_state_process_up
Definition: api_helper_macros.h:422
vl_api_sw_interface_set_rx_placement_t_handler
static void vl_api_sw_interface_set_rx_placement_t_handler(vl_api_sw_interface_set_rx_placement_t *mp)
Definition: interface_api.c:1173
mac_address_t_
Definition: mac_address.h:21
vnet_sw_interface_stats_collect_enable_disable
int vnet_sw_interface_stats_collect_enable_disable(u32 sw_if_index, u8 enable)
Definition: interface_stats.c:25
vl_api_from_api_to_new_vec
u8 * vl_api_from_api_to_new_vec(void *mp, vl_api_string_t *astr)
Definition: api_shared.c:1202
vl_api_create_vlan_subif_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:553
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
vl_api_sw_interface_add_del_address_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:238
vpe_client_registration_t::client_index
u32 client_index
Definition: api_helper_macros.h:410
send_sw_interface_details
static void send_sw_interface_details(vpe_api_main_t *am, vl_api_registration_t *rp, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
Definition: interface_api.c:224
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
vl_api_create_loopback_t::mac_address
vl_api_mac_address_t mac_address
Definition: interface.api:589
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
vl_api_collect_detailed_interface_stats_t
Enable or disable detailed interface stats.
Definition: interface.api:651
API_ADMIN_DOWN_EVENT
@ API_ADMIN_DOWN_EVENT
Definition: interface_api.c:738
vl_api_create_loopback_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:601
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
vl_api_sw_interface_set_table_t
Associate the specified interface with a fib table.
Definition: interface.api:289
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_sw_interface_rx_placement_dump_t::context
u32 context
Definition: interface.api:486
vl_api_sw_interface_set_mtu_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:76
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:162
vl_api_sw_interface_tag_add_del_t_handler
static void vl_api_sw_interface_tag_add_del_t_handler(vl_api_sw_interface_tag_add_del_t *mp)
Definition: interface_api.c:894
vl_api_sw_interface_set_flags_t_handler
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
Definition: interface_api.c:82
vnet_interface_main_t::sw_if_index_by_sup_and_sub
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:1018
fib_table_unlock
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
Definition: fib_table.c:1342
VNET_SW_INTERFACE_TYPE_P2P
@ VNET_SW_INTERFACE_TYPE_P2P
Definition: interface.h:768
i
int i
Definition: flowhash_template.h:376
vl_api_sw_interface_clear_stats_t_handler
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
Definition: interface_api.c:686
vnet_hw_if_rx_queue_t::hw_if_index
u32 hw_if_index
Definition: interface.h:582
API_LINK_STATE_UP_EVENT
@ API_LINK_STATE_UP_EVENT
Definition: interface_api.c:735
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
vnet_hw_if_rx_queue_t
Definition: interface.h:579
vl_api_create_loopback_instance_t::mac_address
vl_api_mac_address_t mac_address
Definition: interface.api:615
vl_api_sw_interface_get_mac_address_t::context
u32 context
Definition: interface.api:404
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
context
u32 context
Definition: ip.api:852
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
vnet_sw_interface_t::hw_if_index
u32 hw_if_index
Definition: interface.h:887
IF_API_TYPE_SUB
@ IF_API_TYPE_SUB
Definition: interface_types.api:71
vl_api_sw_interface_event_t::flags
vl_api_if_status_flags_t flags
Definition: interface.api:106
rv
int __clib_unused rv
Definition: application.c:491
vl_api_create_vlan_subif_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:566
vl_api_hw_interface_set_mtu_t::mtu
u16 mtu
Definition: interface.api:68
vl_api_sw_interface_set_table_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:293
vl_api_sw_interface_set_mtu_t
Set interface L3 MTU.
Definition: interface.api:72
vl_api_sw_interface_add_del_mac_address_t
Add or delete a secondary MAC address on an interface.
Definition: interface.api:373
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
ip_interface_address_t
Definition: lookup.h:89
vl_api_sw_interface_event_t::deleted
bool deleted
Definition: interface.api:107
vl_api_sw_interface_set_rx_mode_t::queue_id
u32 queue_id
Definition: interface.api:436
API_LINK_STATE_DOWN_EVENT
@ API_LINK_STATE_DOWN_EVENT
Definition: interface_api.c:736
vl_api_sw_interface_get_mac_address_reply_t::mac_address
vl_api_mac_address_t mac_address
Definition: interface.api:417
vl_api_create_subif_t_handler
static void vl_api_create_subif_t_handler(vl_api_create_subif_t *mp)
Definition: interface_api.c:1288
vnet.h
vl_api_sw_interface_get_mac_address_t_handler
static void vl_api_sw_interface_get_mac_address_t_handler(vl_api_sw_interface_get_mac_address_t *mp)
Definition: interface_api.c:982
api_errno.h
VNET_SW_INTERFACE_TYPE_HARDWARE
@ VNET_SW_INTERFACE_TYPE_HARDWARE
Definition: interface.h:764
vl_api_sw_interface_get_mac_address_t
Get interface's MAC address.
Definition: interface.api:401
vl_api_sw_interface_get_table_t_handler
static void vl_api_sw_interface_get_table_t_handler(vl_api_sw_interface_get_table_t *mp)
Definition: interface_api.c:619
vlib_node_runtime_t
Definition: node.h:454
vl_api_sw_interface_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:154
vnet_get_sup_sw_interface
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:81
vl_api_sw_interface_add_del_address_t::prefix
vl_api_address_with_prefix_t prefix
Definition: interface.api:242
vl_api_sw_interface_set_ip_directed_broadcast_t::enable
bool enable
Definition: interface.api:91
vl_api_interface_name_renumber_t::new_show_dev_instance
u32 new_show_dev_instance
Definition: interface.api:521
fib_table_find
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1111
vl_api_create_vlan_subif_reply_t::retval
i32 retval
Definition: interface.api:565
vpe_client_registration_t
Definition: api_helper_macros.h:408
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vl_api_create_subif_t::sub_id
u32 sub_id
Definition: interface.api:529
vl_api_sw_interface_details_t::sub_outer_vlan_id
u16 sub_outer_vlan_id
Definition: interface.api:184
vl_api_sw_interface_rx_placement_details_t
show the interface's queue - thread placement This api is used to display the interface and queue wor...
Definition: interface.api:505
vlib_clear_simple_counters
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
Definition: counter.c:44
ethernet_interface::address
ethernet_interface_address_t address
Definition: ethernet.h:173
ip_types_api.h
ip_del_all_interface_addresses
void ip_del_all_interface_addresses(vlib_main_t *vm, u32 sw_if_index)
Definition: ip46_cli.c:82
VNET_MTU_L3
@ VNET_MTU_L3
Definition: interface.h:830
vnet_hw_interface_t::rx_queue_indices
u32 * rx_queue_indices
Definition: interface.h:726
vl_api_sw_interface_add_del_mac_address_t::addr
vl_api_mac_address_t addr
Definition: interface.api:378
sw_interface_add_del_function
static clib_error_t * sw_interface_add_del_function(vnet_main_t *vm, u32 sw_if_index, u32 flags)
Definition: interface_api.c:878
clib_mem_alloc
static void * clib_mem_alloc(uword size)
Definition: mem.h:256
vnet_delete_sub_interface
int vnet_delete_sub_interface(u32 sw_if_index)
Definition: interface.c:1095
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
vl_api_create_vlan_subif_t
Create a new subinterface with the given vlan id.
Definition: interface.api:549
ethernet_get_main
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Definition: init.c:125
vl_api_hw_interface_set_mtu_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:67
vl_api_sw_interface_set_unnumbered_t::is_add
bool is_add
Definition: interface.api:335
vnet_sw_interface_set_protocol_mtu
void vnet_sw_interface_set_protocol_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu[])
Definition: interface.c:721
vl_api_hw_interface_set_mtu_t_handler
static void vl_api_hw_interface_set_mtu_t_handler(vl_api_hw_interface_set_mtu_t *mp)
Definition: interface_api.c:139
format_vnet_sw_interface_name
format_function_t format_vnet_sw_interface_name
Definition: interface_funcs.h:456
vl_api_sw_interface_set_mac_address_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: interface.api:392
vl_api_create_loopback_instance_t::is_specified
bool is_specified
Definition: interface.api:616
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
vl_api_sw_interface_set_mac_address_t::mac_address
vl_api_mac_address_t mac_address
Definition: interface.api:393
swif
u32 swif
Definition: interface_output.c:1096
vl_api_sw_interface_set_unnumbered_t::unnumbered_sw_if_index
vl_api_interface_index_t unnumbered_sw_if_index
Definition: interface.api:334
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105