FD.io VPP  v17.01-9-ge7dcee4
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>
24 #include <vnet/api_errno.h>
25 #include <vnet/ethernet/ethernet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/fib/fib_table.h>
28 #include <vnet/l2/l2_vtr.h>
29 #include <vnet/vnet_msg_enum.h>
30 #include <vnet/fib/fib_api.h>
31 
32 #define vl_typedefs /* define message structures */
33 #include <vnet/vnet_all_api_h.h>
34 #undef vl_typedefs
35 
36 #define vl_endianfun /* define message structures */
37 #include <vnet/vnet_all_api_h.h>
38 #undef vl_endianfun
39 
40 /* instantiate all the print functions we know about */
41 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
42 #define vl_printfun
43 #include <vnet/vnet_all_api_h.h>
44 #undef vl_printfun
45 
47 
48 #define foreach_vpe_api_msg \
49 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
50 _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \
51 _(WANT_INTERFACE_EVENTS, want_interface_events) \
52 _(SW_INTERFACE_DUMP, sw_interface_dump) \
53 _(SW_INTERFACE_DETAILS, sw_interface_details) \
54 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
55 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
56 _(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
57 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
58 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
59 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)
60 
61 static void
63 {
65  vnet_main_t *vnm = vnet_get_main ();
66  int rv = 0;
67  clib_error_t *error;
68  u16 flags;
69 
71 
73 
74  error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
75  if (error)
76  {
77  rv = -1;
78  clib_error_report (error);
79  }
80 
82  REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
83 }
84 
85 static void
87 {
89  vnet_main_t *vnm = vnet_get_main ();
91  u32 sw_if_index = ntohl (mp->sw_if_index);
92  u16 mtu = ntohs (mp->mtu);
94  int rv = 0;
95 
97 
98  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
99  ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index);
100 
101  if (!eif)
102  {
103  rv = VNET_API_ERROR_FEATURE_DISABLED;
104  goto bad_sw_if_index;
105  }
106 
107  if (mtu < hi->min_supported_packet_bytes)
108  {
109  rv = VNET_API_ERROR_INVALID_VALUE;
110  goto bad_sw_if_index;
111  }
112 
113  if (mtu > hi->max_supported_packet_bytes)
114  {
115  rv = VNET_API_ERROR_INVALID_VALUE;
116  goto bad_sw_if_index;
117  }
118 
119  if (hi->max_packet_bytes != mtu)
120  {
121  hi->max_packet_bytes = mtu;
122  ethernet_set_flags (vnm, sw_if_index, flags);
123  }
124 
126  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY);
127 }
128 
129 static void
132  vnet_sw_interface_t * swif,
133  u8 * interface_name, u32 context)
134 {
136  vnet_main_t *vnm = vnet_get_main ();
138  u8 *tag;
139 
141 
142  mp = vl_msg_api_alloc (sizeof (*mp));
143  memset (mp, 0, sizeof (*mp));
144  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
145  mp->sw_if_index = ntohl (swif->sw_if_index);
146  mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
147  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
148  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
153  mp->link_mtu = ntohs (hi->max_packet_bytes);
154  mp->context = context;
155 
156  strncpy ((char *) mp->interface_name,
157  (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
158 
159  /* Send the L2 address for ethernet physical intfcs */
160  if (swif->sup_sw_if_index == swif->sw_if_index
162  {
165 
166  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
167  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
168  clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
169  mp->l2_address_length = ntohl (sizeof (ei->address));
170  }
171  else if (swif->sup_sw_if_index != swif->sw_if_index)
172  {
173  vnet_sub_interface_t *sub = &swif->sub;
174  mp->sub_id = ntohl (sub->id);
175  mp->sub_dot1ad = sub->eth.flags.dot1ad;
176  mp->sub_number_of_tags =
177  sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
178  mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
179  mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
180  mp->sub_exact_match = sub->eth.flags.exact_match;
181  mp->sub_default = sub->eth.flags.default_sub;
182  mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
183  mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
184 
185  /* vlan tag rewrite data */
186  u32 vtr_op = L2_VTR_DISABLED;
187  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
188 
189  if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
190  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
191  {
192  // error - default to disabled
193  mp->vtr_op = ntohl (L2_VTR_DISABLED);
194  clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
195  swif->sw_if_index);
196  }
197  else
198  {
199  mp->vtr_op = ntohl (vtr_op);
200  mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
201  mp->vtr_tag1 = ntohl (vtr_tag1);
202  mp->vtr_tag2 = ntohl (vtr_tag2);
203  }
204  }
205 
206  tag = vnet_get_sw_interface_tag (vnm, swif->sw_if_index);
207  if (tag)
208  strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
209 
210  vl_msg_api_send_shmem (q, (u8 *) & mp);
211 }
212 
213 static void
215 {
217  vnet_sw_interface_t *swif;
219  u8 *filter_string = 0, *name_string = 0;
221  char *strcasestr (char *, char *); /* lnx hdr file botch */
222 
224 
225  if (q == 0)
226  return;
227 
228  if (mp->name_filter_valid)
229  {
230  mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
231  filter_string = format (0, "%s%c", mp->name_filter, 0);
232  }
233 
234  /* *INDENT-OFF* */
235  pool_foreach (swif, im->sw_interfaces,
236  ({
237  name_string = format (name_string, "%U%c",
238  format_vnet_sw_interface_name,
239  am->vnet_main, swif, 0);
240 
241  if (mp->name_filter_valid == 0 ||
242  strcasestr((char *) name_string, (char *) filter_string)) {
243 
244  send_sw_interface_details (am, q, swif, name_string, mp->context);
245  }
246  _vec_len (name_string) = 0;
247  }));
248  /* *INDENT-ON* */
249 
250  vec_free (name_string);
251  vec_free (filter_string);
252 }
253 
254 static void
257 {
258  vlib_main_t *vm = vlib_get_main ();
260  int rv = 0;
261  u32 is_del;
262 
264 
265  is_del = mp->is_add == 0;
266 
267  if (mp->del_all)
269  else if (mp->is_ipv6)
271  (void *) mp->address,
272  mp->address_length, is_del);
273  else
275  (void *) mp->address,
276  mp->address_length, is_del);
277 
279 
280  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
281 }
282 
283 void stats_dslock_with_hint (int hint, int tag) __attribute__ ((weak));
284 void
285 stats_dslock_with_hint (int hint, int tag)
286 {
287 }
288 
289 void stats_dsunlock (void) __attribute__ ((weak));
290 void
292 {
293 }
294 
295 static void
297 {
298  int rv = 0;
299  u32 table_id = ntohl (mp->vrf_id);
300  u32 sw_if_index = ntohl (mp->sw_if_index);
302  u32 fib_index;
303 
305 
306  stats_dslock_with_hint (1 /* release hint */ , 4 /* tag */ );
307 
308  if (mp->is_ipv6)
309  {
311  table_id);
312 
314  ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
315  }
316  else
317  {
318 
320  table_id);
321 
323  ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
324  }
325  stats_dsunlock ();
326 
328 
329  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
330 }
331 
332 static void
334  u32 context, int retval, u32 vrf_id)
335 {
337 
338  mp = vl_msg_api_alloc (sizeof (*mp));
339  memset (mp, 0, sizeof (*mp));
340  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY);
341  mp->context = context;
342  mp->retval = htonl (retval);
343  mp->vrf_id = htonl (vrf_id);
344 
345  vl_msg_api_send_shmem (q, (u8 *) & mp);
346 }
347 
348 static void
350 {
352  fib_table_t *fib_table = 0;
353  u32 sw_if_index = ~0;
354  u32 fib_index = ~0;
355  u32 table_id = ~0;
356  fib_protocol_t fib_proto = FIB_PROTOCOL_IP4;
357  int rv = 0;
358 
360  if (q == 0)
361  return;
362 
364 
365  sw_if_index = ntohl (mp->sw_if_index);
366 
367  if (mp->is_ipv6)
368  fib_proto = FIB_PROTOCOL_IP6;
369 
370  fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
371  if (fib_index != ~0)
372  {
373  fib_table = fib_table_get (fib_index, fib_proto);
374  table_id = fib_table->ft_table_id;
375  }
376 
378 
379  send_sw_interface_get_table_reply (q, mp->context, rv, table_id);
380 }
381 
384 {
386  int rv = 0;
388  vnet_main_t *vnm = vnet_get_main ();
389  u32 sw_if_index, unnumbered_sw_if_index;
390 
391  sw_if_index = ntohl (mp->sw_if_index);
392  unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
393 
394  /*
395  * The API message field names are backwards from
396  * the underlying data structure names.
397  * It's not worth changing them now.
398  */
400  unnumbered_sw_if_index))
401  {
402  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
403  goto done;
404  }
405 
406  /* Only check the "use loop0" field when setting the binding */
407  if (mp->is_add &&
408  pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
409  {
410  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
411  goto done;
412  }
413 
414  si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
415 
416  if (mp->is_add)
417  {
419  si->unnumbered_sw_if_index = sw_if_index;
420  ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
421  ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
422  }
423  else
424  {
426  si->unnumbered_sw_if_index = (u32) ~ 0;
427  ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
428  ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
429  }
430 
431 done:
432  REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
433 }
434 
435 static void
437  mp)
438 {
440 
441  vnet_main_t *vnm = vnet_get_main ();
445  static vnet_main_t **my_vnet_mains;
446  int i, j, n_counters;
447  int rv = 0;
448 
449  if (mp->sw_if_index != ~0)
451 
452  vec_reset_length (my_vnet_mains);
453 
454  for (i = 0; i < vec_len (vnet_mains); i++)
455  {
456  if (vnet_mains[i])
457  vec_add1 (my_vnet_mains, vnet_mains[i]);
458  }
459 
460  if (vec_len (vnet_mains) == 0)
461  vec_add1 (my_vnet_mains, vnm);
462 
463  n_counters = vec_len (im->combined_sw_if_counters);
464 
465  for (j = 0; j < n_counters; j++)
466  {
467  for (i = 0; i < vec_len (my_vnet_mains); i++)
468  {
469  im = &my_vnet_mains[i]->interface_main;
470  cm = im->combined_sw_if_counters + j;
471  if (mp->sw_if_index == (u32) ~ 0)
473  else
474  vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index));
475  }
476  }
477 
478  n_counters = vec_len (im->sw_if_counters);
479 
480  for (j = 0; j < n_counters; j++)
481  {
482  for (i = 0; i < vec_len (my_vnet_mains); i++)
483  {
484  im = &my_vnet_mains[i]->interface_main;
485  sm = im->sw_if_counters + j;
486  if (mp->sw_if_index == (u32) ~ 0)
488  else
489  vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
490  }
491  }
492 
494 
495  REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
496 }
497 
498 #define API_LINK_STATE_EVENT 1
499 #define API_ADMIN_UP_DOWN_EVENT 2
500 
501 static int
502 event_data_cmp (void *a1, void *a2)
503 {
504  uword *e1 = a1;
505  uword *e2 = a2;
506 
507  return (word) e1[0] - (word) e2[0];
508 }
509 
510 static void
513  vnet_sw_interface_t * swif)
514 {
516  vnet_main_t *vnm = am->vnet_main;
517 
519  swif->sw_if_index);
520  mp = vl_msg_api_alloc (sizeof (*mp));
521  memset (mp, 0, sizeof (*mp));
522  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
523  mp->sw_if_index = ntohl (swif->sw_if_index);
524 
525  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
526  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
527  vl_msg_api_send_shmem (q, (u8 *) & mp);
528 }
529 
530 static uword
533 {
535  vnet_main_t *vnm = vam->vnet_main;
536  vnet_sw_interface_t *swif;
537  uword *event_data = 0;
539  int i;
540  u32 prev_sw_if_index;
542 
543  vam->link_state_process_up = 1;
544 
545  while (1)
546  {
548 
549  /* Unified list of changed link or admin state sw_if_indices */
551  (vm, &event_data, API_LINK_STATE_EVENT);
553  (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
554 
555  /* Sort, so we can eliminate duplicates */
557 
558  prev_sw_if_index = ~0;
559 
560  for (i = 0; i < vec_len (event_data); i++)
561  {
562  /* Only one message per swif */
563  if (prev_sw_if_index == event_data[i])
564  continue;
565  prev_sw_if_index = event_data[i];
566 
567  /* *INDENT-OFF* */
568  pool_foreach(reg, vam->interface_events_registrations,
569  ({
570  q = vl_api_client_index_to_input_queue (reg->client_index);
571  if (q)
572  {
573  /* sw_interface may be deleted already */
574  if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
575  event_data[i]))
576  {
577  swif = vnet_get_sw_interface (vnm, event_data[i]);
578  send_sw_interface_flags (vam, q, swif);
579  }
580  }
581  }));
582  /* *INDENT-ON* */
583  }
584  vec_reset_length (event_data);
585  }
586 
587  return 0;
588 }
589 
590 static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
591  u32 flags);
593  u32 hw_if_index, u32 flags);
594 
595 /* *INDENT-OFF* */
596 VLIB_REGISTER_NODE (link_state_process_node,static) = {
597  .function = link_state_process,
598  .type = VLIB_NODE_TYPE_PROCESS,
599  .name = "vpe-link-state-process",
600 };
601 /* *INDENT-ON* */
602 
603 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
604 VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
605 
606 static clib_error_t *
607 link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
608 {
610  vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
611 
612  if (vam->link_state_process_up)
614  link_state_process_node.index,
616  return 0;
617 }
618 
619 static clib_error_t *
620 admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
621 {
623 
624  /*
625  * Note: it's perfectly fair to set a subif admin up / admin down.
626  * Note the subtle distinction between this routine and the previous
627  * routine.
628  */
629  if (vam->link_state_process_up)
631  link_state_process_node.index,
632  API_ADMIN_UP_DOWN_EVENT, sw_if_index);
633  return 0;
634 }
635 
638 {
639  vnet_main_t *vnm = vnet_get_main ();
641  int rv = 0;
642  u8 *tag;
643  u32 sw_if_index = ntohl (mp->sw_if_index);
644 
646 
647  if (mp->is_add)
648  {
649  if (mp->tag[0] == 0)
650  {
651  rv = VNET_API_ERROR_INVALID_VALUE;
652  goto out;
653  }
654 
655  mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
656  tag = format (0, "%s%c", mp->tag, 0);
657  vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
658  }
659  else
660  vnet_clear_sw_interface_tag (vnm, sw_if_index);
661 
663 out:
664  REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
665 }
666 
667 static void
669 {
670  clib_warning ("BUG");
671 }
672 
673 /*
674  * vpe_api_hookup
675  * Add vpe's API message handlers to the table.
676  * vlib has alread mapped shared memory and
677  * added the client registration handlers.
678  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
679  */
680 #define vl_msg_name_crc_list
681 #include <vnet/interface.api.h>
682 #undef vl_msg_name_crc_list
683 
684 static void
686 {
687 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
688  foreach_vl_msg_name_crc_interface;
689 #undef _
690 }
691 
692 pub_sub_handler (interface_events, INTERFACE_EVENTS);
693 
694 static clib_error_t *
696 {
697  api_main_t *am = &api_main;
698 
699 #define _(N,n) \
700  vl_msg_api_set_handlers(VL_API_##N, #n, \
701  vl_api_##n##_t_handler, \
702  vl_noop_handler, \
703  vl_api_##n##_t_endian, \
704  vl_api_##n##_t_print, \
705  sizeof(vl_api_##n##_t), 1);
707 #undef _
708 
709  /*
710  * Set up the (msg_name, crc, message-id) table
711  */
713 
714  return 0;
715 }
716 
718 
719 /*
720  * fd.io coding-style-patch-verification: ON
721  *
722  * Local Variables:
723  * eval: (c-set-style "gnu")
724  * End:
725  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:535
static int event_data_cmp(void *a1, void *a2)
vmrglw vmrglh hi
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
vnet_main_t * vnet_main
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:604
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
void stats_dsunlock(void)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(link_up_down_function)
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Definition: init.c:116
Set flags on the interface.
Definition: interface.api:9
vnet_interface_main_t interface_main
Definition: vnet.h:57
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
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:902
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t ** vnet_mains
Definition: vnet.h:83
add_epi add_epi sub
Definition: vector_sse2.h:289
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
VLIB_API_INIT_FUNCTION(interface_api_hookup)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Reply to sw_interface_clear_stats.
Definition: interface.api:303
vlib_main_t * vlib_main
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:105
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
#define clib_error_report(e)
Definition: error.h:125
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:377
static void send_sw_interface_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:382
static clib_error_t * interface_api_hookup(vlib_main_t *vm)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static uword link_state_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Reply to set / clear software interface tag.
Definition: interface.api:329
api_main_t api_main
Definition: api_shared.c:39
static void send_sw_interface_get_table_reply(unix_shared_memory_queue_t *q, u32 context, int retval, u32 vrf_id)
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:394
ethernet_main_t ethernet_main
Definition: ethernet.h:270
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
Reply to sw_interface_set_table.
Definition: interface.api:214
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:67
Clear interface statistics.
Definition: interface.api:292
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
struct vnet_sub_interface_t::@154::@155::@157 flags
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:615
Get VRF id assigned to interface.
Definition: interface.api:225
#define clib_warning(format, args...)
Definition: error.h:59
A collection of simple counters.
Definition: counter.h:59
u32 max_supported_packet_bytes
Definition: interface.h:435
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:921
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
Definition: interface.h:379
#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
vnet_sub_interface_t sub
Definition: interface.h:558
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip4_forward.c:807
static void vl_api_sw_interface_get_table_t_handler(vl_api_sw_interface_get_table_t *mp)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:931
static void vl_api_sw_interface_details_t_handler(vl_api_sw_interface_details_t *mp)
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Definition: interface.h:387
Set interface MTU.
Definition: interface.api:36
Reply to get_sw_interface_vrf.
Definition: interface.api:237
#define REPLY_MACRO(t)
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:614
void ip_del_all_interface_addresses(vlib_main_t *vm, u32 sw_if_index)
Definition: ip46_cli.c:80
Set unnumbered interface add / del response.
Definition: interface.api:281
Set or delete one or all ip addresses on a specified interface.
Definition: interface.api:172
Reply to sw_interface_set_flags.
Definition: interface.api:24
vnet_hw_interface_class_t ethernet_hw_interface_class
static void setup_message_id_table(api_main_t *am)
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
Definition: node_funcs.h:582
#define BAD_SW_IF_INDEX_LABEL
void * vl_msg_api_alloc(int nbytes)
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
Definition: interface_api.c:62
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
void stats_dslock_with_hint(int hint, int tag)
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
static clib_error_t * admin_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
#define API_ADMIN_UP_DOWN_EVENT
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ETHERNET_INTERFACE_FLAG_MTU
Definition: ethernet.h:118
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
#define ARRAY_LEN(x)
Definition: clib.h:59
#define foreach_vpe_api_msg
Definition: interface_api.c:48
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
foreach_registration_hash u8 link_state_process_up
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:528
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:2828
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
static void vl_api_sw_interface_tag_add_del_t_handler(vl_api_sw_interface_tag_add_del_t *mp)
#define API_LINK_STATE_EVENT
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:964
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
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
static void vl_api_sw_interface_set_mtu_t_handler(vl_api_sw_interface_set_mtu_t *mp)
Definition: interface_api.c:86
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
i64 word
Definition: types.h:111
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:563
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
struct vnet_sub_interface_t::@154 eth
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:606
Reply to sw_interface_add_del_address.
Definition: interface.api:188
Set unnumbered interface add / del request.
Definition: interface.api:268
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:27
A collection of combined counters.
Definition: counter.h:212
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:350
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
Definition: counter.c:43
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1099
pub_sub_handler(interface_events, INTERFACE_EVENTS)
static void send_sw_interface_flags(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:539
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:445
Interface details structure (fix this)
Definition: interface.api:101
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
u32 flags
Definition: vhost-user.h:75
Set / clear software interface tag.
Definition: interface.api:316
ethernet_interface_t * interfaces
Definition: ethernet.h:243
vpe_api_main_t vpe_api_main
Definition: api.c:324
Associate the specified interface with a fib table.
Definition: interface.api:201
u32 * fib_index_by_sw_if_index
Definition: ip6.h:144
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip6_forward.c:391
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
Definition: fib_table.h:29
struct _unix_shared_memory_queue unix_shared_memory_queue_t
Reply to sw_interface_set_mtu.
Definition: interface.api:48
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:319