FD.io VPP  v17.04-9-g99c0734
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/mfib/mfib_table.h>
29 #include <vnet/l2/l2_vtr.h>
30 #include <vnet/vnet_msg_enum.h>
31 #include <vnet/fib/fib_api.h>
32 #include <vnet/mfib/mfib_table.h>
33 
34 #define vl_typedefs /* define message structures */
35 #include <vnet/vnet_all_api_h.h>
36 #undef vl_typedefs
37 
38 #define vl_endianfun /* define message structures */
39 #include <vnet/vnet_all_api_h.h>
40 #undef vl_endianfun
41 
42 /* instantiate all the print functions we know about */
43 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
44 #define vl_printfun
45 #include <vnet/vnet_all_api_h.h>
46 #undef vl_printfun
47 
49 
50 #define foreach_vpe_api_msg \
51 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
52 _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \
53 _(WANT_INTERFACE_EVENTS, want_interface_events) \
54 _(SW_INTERFACE_DUMP, sw_interface_dump) \
55 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
56 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
57 _(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
58 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
59 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
60 _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del)
61 
62 static void
64 {
66  vnet_main_t *vnm = vnet_get_main ();
67  int rv = 0;
68  clib_error_t *error;
69  u16 flags;
70 
72 
74 
75  error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
76  if (error)
77  {
78  rv = -1;
79  clib_error_report (error);
80  }
81 
83  REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
84 }
85 
86 static void
88 {
90  vnet_main_t *vnm = vnet_get_main ();
92  u32 sw_if_index = ntohl (mp->sw_if_index);
93  u16 mtu = ntohs (mp->mtu);
95  int rv = 0;
96 
98 
99  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
100  ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index);
101 
102  if (!eif)
103  {
104  rv = VNET_API_ERROR_FEATURE_DISABLED;
105  goto bad_sw_if_index;
106  }
107 
108  if (mtu < hi->min_supported_packet_bytes)
109  {
110  rv = VNET_API_ERROR_INVALID_VALUE;
111  goto bad_sw_if_index;
112  }
113 
114  if (mtu > hi->max_supported_packet_bytes)
115  {
116  rv = VNET_API_ERROR_INVALID_VALUE;
117  goto bad_sw_if_index;
118  }
119 
120  if (hi->max_packet_bytes != mtu)
121  {
122  hi->max_packet_bytes = mtu;
123  ethernet_set_flags (vnm, sw_if_index, flags);
124  }
125 
127  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY);
128 }
129 
130 static void
133  vnet_sw_interface_t * swif,
134  u8 * interface_name, u32 context)
135 {
138 
139  vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
140  memset (mp, 0, sizeof (*mp));
141  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
142  mp->sw_if_index = ntohl (swif->sw_if_index);
143  mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
144  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
145  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
150  mp->link_mtu = ntohs (hi->max_packet_bytes);
151  mp->context = context;
152 
153  strncpy ((char *) mp->interface_name,
154  (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
155 
156  /* Send the L2 address for ethernet physical intfcs */
157  if (swif->sup_sw_if_index == swif->sw_if_index
159  {
162 
163  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
164  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
165  clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
166  mp->l2_address_length = ntohl (sizeof (ei->address));
167  }
168  else if (swif->sup_sw_if_index != swif->sw_if_index)
169  {
170  vnet_sub_interface_t *sub = &swif->sub;
171  mp->sub_id = ntohl (sub->id);
172  mp->sub_dot1ad = sub->eth.flags.dot1ad;
173  mp->sub_number_of_tags =
174  sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
175  mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
176  mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
177  mp->sub_exact_match = sub->eth.flags.exact_match;
178  mp->sub_default = sub->eth.flags.default_sub;
179  mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
180  mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
181 
182  /* vlan tag rewrite data */
183  u32 vtr_op = L2_VTR_DISABLED;
184  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
185 
186  if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
187  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
188  {
189  // error - default to disabled
190  mp->vtr_op = ntohl (L2_VTR_DISABLED);
191  clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
192  swif->sw_if_index);
193  }
194  else
195  {
196  mp->vtr_op = ntohl (vtr_op);
197  mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
198  mp->vtr_tag1 = ntohl (vtr_tag1);
199  mp->vtr_tag2 = ntohl (vtr_tag2);
200  }
201  }
202 
203  /* pbb tag rewrite data */
204  ethernet_header_t eth_hdr;
205  u32 vtr_op = L2_VTR_DISABLED;
206  u16 outer_tag = 0;
207  u16 b_vlanid = 0;
208  u32 i_sid = 0;
209  memset (&eth_hdr, 0, sizeof (eth_hdr));
210 
211  if (!l2pbb_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
212  &vtr_op, &outer_tag, &eth_hdr, &b_vlanid, &i_sid))
213  {
214  mp->sub_dot1ah = 1;
215  clib_memcpy (mp->b_dmac, eth_hdr.dst_address,
216  sizeof (eth_hdr.dst_address));
217  clib_memcpy (mp->b_smac, eth_hdr.src_address,
218  sizeof (eth_hdr.src_address));
219  mp->b_vlanid = b_vlanid;
220  mp->i_sid = i_sid;
221  }
222 
224  if (tag)
225  strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
226 
227  vl_msg_api_send_shmem (q, (u8 *) & mp);
228 }
229 
230 static void
232 {
234  vnet_sw_interface_t *swif;
236 
239  if (q == 0)
240  return;
241 
242  u8 *filter = 0, *name = 0;
243  if (mp->name_filter_valid)
244  {
245  mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
246  filter = format (0, "%s%c", mp->name_filter, 0);
247  }
248 
249  char *strcasestr (char *, char *); /* lnx hdr file botch */
250  /* *INDENT-OFF* */
251  pool_foreach (swif, im->sw_interfaces,
252  ({
253  if (!vnet_swif_is_api_visible (swif))
254  continue;
255  vec_reset_length(name);
256  name = format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main,
257  swif, 0);
258 
259  if (filter && !strcasestr((char *) name, (char *) filter))
260  continue;
261 
262  send_sw_interface_details (am, q, swif, name, mp->context);
263  }));
264  /* *INDENT-ON* */
265 
266  vec_free (name);
267  vec_free (filter);
268 }
269 
270 static void
273 {
274  vlib_main_t *vm = vlib_get_main ();
276  int rv = 0;
277  u32 is_del;
278 
280 
281  is_del = mp->is_add == 0;
282 
283  if (mp->del_all)
285  else if (mp->is_ipv6)
287  (void *) mp->address,
288  mp->address_length, is_del);
289  else
291  (void *) mp->address,
292  mp->address_length, is_del);
293 
295 
296  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
297 }
298 
299 void stats_dslock_with_hint (int hint, int tag) __attribute__ ((weak));
300 void
301 stats_dslock_with_hint (int hint, int tag)
302 {
303 }
304 
305 void stats_dsunlock (void) __attribute__ ((weak));
306 void
308 {
309 }
310 
311 static void
313 {
314  int rv = 0;
315  u32 table_id = ntohl (mp->vrf_id);
316  u32 sw_if_index = ntohl (mp->sw_if_index);
319  u32 fib_index;
320 
322 
323  stats_dslock_with_hint (1 /* release hint */ , 4 /* tag */ );
324 
325  if (mp->is_ipv6)
326  {
327  /* *INDENT-OFF* */
329  ia, sw_if_index,
330  1 /* honor unnumbered */ ,
331  ({
332  rv = VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE;
333  goto done;
334  }));
335  /* *INDENT-ON* */
336 
338  table_id);
340  ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
341 
343  table_id);
345  ip6_main.mfib_index_by_sw_if_index[sw_if_index] = fib_index;
346  }
347  else
348  {
349  /* *INDENT-OFF* */
351  ia, sw_if_index,
352  1 /* honor unnumbered */ ,
353  ({
354  rv = VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE;
355  goto done;
356  }));
357  /* *INDENT-ON* */
358 
360  table_id);
362  ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
363 
365  table_id);
367  ip4_main.mfib_index_by_sw_if_index[sw_if_index] = fib_index;
368  }
369 
370 done:
371  stats_dsunlock ();
372 
374 
375  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
376 }
377 
378 static void
380  u32 context, int retval, u32 vrf_id)
381 {
383 
384  mp = vl_msg_api_alloc (sizeof (*mp));
385  memset (mp, 0, sizeof (*mp));
386  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY);
387  mp->context = context;
388  mp->retval = htonl (retval);
389  mp->vrf_id = htonl (vrf_id);
390 
391  vl_msg_api_send_shmem (q, (u8 *) & mp);
392 }
393 
394 static void
396 {
398  fib_table_t *fib_table = 0;
399  u32 sw_if_index = ~0;
400  u32 fib_index = ~0;
401  u32 table_id = ~0;
402  fib_protocol_t fib_proto = FIB_PROTOCOL_IP4;
403  int rv = 0;
404 
406  if (q == 0)
407  return;
408 
410 
411  sw_if_index = ntohl (mp->sw_if_index);
412 
413  if (mp->is_ipv6)
414  fib_proto = FIB_PROTOCOL_IP6;
415 
416  fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
417  if (fib_index != ~0)
418  {
419  fib_table = fib_table_get (fib_index, fib_proto);
420  table_id = fib_table->ft_table_id;
421  }
422 
424 
425  send_sw_interface_get_table_reply (q, mp->context, rv, table_id);
426 }
427 
430 {
432  int rv = 0;
433  vnet_main_t *vnm = vnet_get_main ();
434  u32 sw_if_index = ntohl (mp->sw_if_index);
435  u32 unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
436  u32 was_unnum;
437 
438  /*
439  * The API message field names are backwards from
440  * the underlying data structure names.
441  * It's not worth changing them now.
442  */
443  if (!vnet_sw_interface_is_api_valid (vnm, unnumbered_sw_if_index))
444  {
445  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
446  goto done;
447  }
448 
449  /* Only check the "use loop0" field when setting the binding */
450  if (mp->is_add && !vnet_sw_interface_is_api_valid (vnm, sw_if_index))
451  {
452  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
453  goto done;
454  }
455 
456  vnet_sw_interface_t *si =
457  vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
458  was_unnum = (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED);
459 
460  if (mp->is_add)
461  {
463  si->unnumbered_sw_if_index = sw_if_index;
464 
466  [unnumbered_sw_if_index] =
467  ip4_main.
468  lookup_main.if_address_pool_index_by_sw_if_index[sw_if_index];
469  ip6_main.
470  lookup_main.if_address_pool_index_by_sw_if_index
471  [unnumbered_sw_if_index] =
472  ip6_main.
473  lookup_main.if_address_pool_index_by_sw_if_index[sw_if_index];
474  }
475  else
476  {
478  si->unnumbered_sw_if_index = (u32) ~ 0;
479 
481  [unnumbered_sw_if_index] = ~0;
483  [unnumbered_sw_if_index] = ~0;
484  }
485 
486  if (was_unnum != (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
487  {
488  ip4_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
489  ip6_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
490  }
491 
492 done:
493  REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
494 }
495 
496 static void
498  mp)
499 {
501 
502  vnet_main_t *vnm = vnet_get_main ();
506  static vnet_main_t **my_vnet_mains;
507  int i, j, n_counters;
508  int rv = 0;
509 
510  if (mp->sw_if_index != ~0)
512 
513  vec_reset_length (my_vnet_mains);
514 
515  for (i = 0; i < vec_len (vnet_mains); i++)
516  {
517  if (vnet_mains[i])
518  vec_add1 (my_vnet_mains, vnet_mains[i]);
519  }
520 
521  if (vec_len (vnet_mains) == 0)
522  vec_add1 (my_vnet_mains, vnm);
523 
524  n_counters = vec_len (im->combined_sw_if_counters);
525 
526  for (j = 0; j < n_counters; j++)
527  {
528  for (i = 0; i < vec_len (my_vnet_mains); i++)
529  {
530  im = &my_vnet_mains[i]->interface_main;
531  cm = im->combined_sw_if_counters + j;
532  if (mp->sw_if_index == (u32) ~ 0)
534  else
535  vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index));
536  }
537  }
538 
539  n_counters = vec_len (im->sw_if_counters);
540 
541  for (j = 0; j < n_counters; j++)
542  {
543  for (i = 0; i < vec_len (my_vnet_mains); i++)
544  {
545  im = &my_vnet_mains[i]->interface_main;
546  sm = im->sw_if_counters + j;
547  if (mp->sw_if_index == (u32) ~ 0)
549  else
550  vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
551  }
552  }
553 
555 
556  REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
557 }
558 
559 #define API_LINK_STATE_EVENT 1
560 #define API_ADMIN_UP_DOWN_EVENT 2
561 
562 static int
563 event_data_cmp (void *a1, void *a2)
564 {
565  uword *e1 = a1;
566  uword *e2 = a2;
567 
568  return (word) e1[0] - (word) e2[0];
569 }
570 
571 static void
574  vnet_sw_interface_t * swif)
575 {
577  vnet_main_t *vnm = am->vnet_main;
578 
580  swif->sw_if_index);
581  mp = vl_msg_api_alloc (sizeof (*mp));
582  memset (mp, 0, sizeof (*mp));
583  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
584  mp->sw_if_index = ntohl (swif->sw_if_index);
585 
586  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
587  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
588  vl_msg_api_send_shmem (q, (u8 *) & mp);
589 }
590 
591 static uword
594 {
596  vnet_main_t *vnm = vam->vnet_main;
597  vnet_sw_interface_t *swif;
598  uword *event_data = 0;
600  int i;
601  u32 prev_sw_if_index;
603 
604  vam->link_state_process_up = 1;
605 
606  while (1)
607  {
609 
610  /* Unified list of changed link or admin state sw_if_indices */
612  (vm, &event_data, API_LINK_STATE_EVENT);
614  (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
615 
616  /* Sort, so we can eliminate duplicates */
618 
619  prev_sw_if_index = ~0;
620 
621  for (i = 0; i < vec_len (event_data); i++)
622  {
623  /* Only one message per swif */
624  if (prev_sw_if_index == event_data[i])
625  continue;
626  prev_sw_if_index = event_data[i];
627 
628  /* *INDENT-OFF* */
629  pool_foreach(reg, vam->interface_events_registrations,
630  ({
631  q = vl_api_client_index_to_input_queue (reg->client_index);
632  if (q)
633  {
634  /* sw_interface may be deleted already */
635  if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
636  event_data[i]))
637  {
638  swif = vnet_get_sw_interface (vnm, event_data[i]);
639  send_sw_interface_flags (vam, q, swif);
640  }
641  }
642  }));
643  /* *INDENT-ON* */
644  }
645  vec_reset_length (event_data);
646  }
647 
648  return 0;
649 }
650 
651 static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
652  u32 flags);
654  u32 hw_if_index, u32 flags);
655 
656 /* *INDENT-OFF* */
657 VLIB_REGISTER_NODE (link_state_process_node,static) = {
658  .function = link_state_process,
659  .type = VLIB_NODE_TYPE_PROCESS,
660  .name = "vpe-link-state-process",
661 };
662 /* *INDENT-ON* */
663 
664 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
665 VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
666 
667 static clib_error_t *
668 link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
669 {
671  vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
672 
673  if (vam->link_state_process_up)
675  link_state_process_node.index,
677  return 0;
678 }
679 
680 static clib_error_t *
681 admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
682 {
684 
685  /*
686  * Note: it's perfectly fair to set a subif admin up / admin down.
687  * Note the subtle distinction between this routine and the previous
688  * routine.
689  */
690  if (vam->link_state_process_up)
692  link_state_process_node.index,
693  API_ADMIN_UP_DOWN_EVENT, sw_if_index);
694  return 0;
695 }
696 
699 {
700  vnet_main_t *vnm = vnet_get_main ();
702  int rv = 0;
703  u8 *tag;
704  u32 sw_if_index = ntohl (mp->sw_if_index);
705 
707 
708  if (mp->is_add)
709  {
710  if (mp->tag[0] == 0)
711  {
712  rv = VNET_API_ERROR_INVALID_VALUE;
713  goto out;
714  }
715 
716  mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
717  tag = format (0, "%s%c", mp->tag, 0);
718  vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
719  }
720  else
721  vnet_clear_sw_interface_tag (vnm, sw_if_index);
722 
724 out:
725  REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
726 }
727 
728 /*
729  * vpe_api_hookup
730  * Add vpe's API message handlers to the table.
731  * vlib has alread mapped shared memory and
732  * added the client registration handlers.
733  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
734  */
735 #define vl_msg_name_crc_list
736 #include <vnet/interface.api.h>
737 #undef vl_msg_name_crc_list
738 
739 static void
741 {
742 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
743  foreach_vl_msg_name_crc_interface;
744 #undef _
745 }
746 
747 pub_sub_handler (interface_events, INTERFACE_EVENTS);
748 
749 static clib_error_t *
751 {
752  api_main_t *am = &api_main;
753 
754 #define _(N,n) \
755  vl_msg_api_set_handlers(VL_API_##N, #n, \
756  vl_api_##n##_t_handler, \
757  vl_noop_handler, \
758  vl_api_##n##_t_endian, \
759  vl_api_##n##_t_print, \
760  sizeof(vl_api_##n##_t), 1);
762 #undef _
763 
764  /*
765  * Set up the (msg_name, crc, message-id) table
766  */
768 
769  return 0;
770 }
771 
773 
774 /*
775  * fd.io coding-style-patch-verification: ON
776  *
777  * Local Variables:
778  * eval: (c-set-style "gnu")
779  * End:
780  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:417
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:543
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
#define CLIB_UNUSED(x)
Definition: clib.h:79
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:603
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip6.h:166
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
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:892
u8 src_address[6]
Definition: packet.h:54
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:522
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)
ip_lookup_main_t lookup_main
Definition: ip4.h:109
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:318
vlib_main_t * vlib_main
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:120
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:379
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:384
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:344
api_main_t api_main
Definition: api_shared.c:35
static void send_sw_interface_get_table_reply(unix_shared_memory_queue_t *q, u32 context, int retval, u32 vrf_id)
struct vnet_sub_interface_t::@117::@118::@120 flags
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:396
ethernet_main_t ethernet_main
Definition: ethernet.h:273
u32 * mfib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:123
Reply to sw_interface_set_table.
Definition: interface.api:229
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:60
Clear interface statistics.
Definition: interface.api:307
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:626
u8 dst_address[6]
Definition: packet.h:53
Get VRF id assigned to interface.
Definition: interface.api:240
A collection of simple counters.
Definition: counter.h:58
u32 max_supported_packet_bytes
Definition: interface.h:437
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:941
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:381
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
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:276
vnet_sub_interface_t sub
Definition: interface.h:569
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip4_forward.c:826
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:930
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Definition: interface.h:389
Set interface MTU.
Definition: interface.api:36
Reply to get_sw_interface_vrf.
Definition: interface.api:252
#define REPLY_MACRO(t)
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:625
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:296
Set or delete one or all ip addresses on a specified interface.
Definition: interface.api:187
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:581
#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:63
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:340
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_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ETHERNET_INTERFACE_FLAG_MTU
Definition: ethernet.h:118
struct vnet_sub_interface_t::@117 eth
#define ARRAY_LEN(x)
Definition: clib.h:59
#define foreach_vpe_api_msg
Definition: interface_api.c:50
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
Definition: lookup.h:344
foreach_registration_hash u8 link_state_process_up
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:536
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:2846
ip_lookup_main_t lookup_main
Definition: ip6.h:151
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
#define clib_error_report(e)
Definition: error.h:125
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:954
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:123
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 vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
static void vl_api_sw_interface_set_mtu_t_handler(vl_api_sw_interface_set_mtu_t *mp)
Definition: interface_api.c:87
u64 uword
Definition: types.h:112
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
unsigned short u16
Definition: types.h:57
i64 word
Definition: types.h:111
u32 mfib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:420
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:672
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:960
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:617
Reply to sw_interface_add_del_address.
Definition: interface.api:203
Set unnumbered interface add / del request.
Definition: interface.api:283
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:180
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
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1117
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:538
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:447
Interface details structure (fix this)
Definition: interface.api:107
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
u32 flags
Definition: vhost-user.h:78
Set / clear software interface tag.
Definition: interface.api:331
ethernet_interface_t * interfaces
Definition: ethernet.h:243
vpe_api_main_t vpe_api_main
Definition: api.c:161
Associate the specified interface with a fib table.
Definition: interface.api:216
u32 * fib_index_by_sw_if_index
Definition: ip6.h:163
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip6_forward.c:395
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:689
#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:339