FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * api.c - message handler registration
4  *
5  * Copyright (c) 2010-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 <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/mman.h>
25 #include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <signal.h>
28 #include <pthread.h>
29 #include <unistd.h>
30 #include <time.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <pwd.h>
34 #include <grp.h>
35 
36 #include <vppinfra/clib.h>
37 #include <vppinfra/vec.h>
38 #include <vppinfra/hash.h>
39 #include <vppinfra/bitmap.h>
40 #include <vppinfra/fifo.h>
41 #include <vppinfra/time.h>
42 #include <vppinfra/mheap.h>
43 #include <vppinfra/heap.h>
44 #include <vppinfra/pool.h>
45 #include <vppinfra/format.h>
46 #include <vppinfra/error.h>
47 
48 #include <vnet/api_errno.h>
49 #include <vnet/vnet.h>
50 #include <vnet/l2/l2_input.h>
51 #include <vnet/l2/l2_bd.h>
52 #include <vnet/ip/ip.h>
53 #include <vnet/ip/ip6.h>
54 #include <vnet/ip/ip6_neighbor.h>
55 #if WITH_LIBSSL > 0
56 #include <vnet/sr/sr.h>
57 #endif
58 #include <vlib/vlib.h>
59 #include <vlib/unix/unix.h>
60 #include <vlibapi/api.h>
61 #include <vlibmemory/api.h>
63 #include <vnet/l2/l2_classify.h>
64 #include <vnet/map/map.h>
65 #include <vnet/ip/ip6_hop_by_hop.h>
67 #include <vnet/ip/punt.h>
68 #include <vnet/feature/feature.h>
69 
70 #undef BIHASH_TYPE
71 #undef __included_bihash_template_h__
72 #include <vnet/l2/l2_fib.h>
73 
74 #include <vpp/stats/stats.h>
75 #include <vpp/oam/oam.h>
76 
77 #include <vnet/ethernet/ethernet.h>
79 #include <vnet/interface.h>
80 #include <vnet/l2/l2_fib.h>
81 #include <vnet/l2/l2_bd.h>
82 #include <vpp/api/vpe_msg_enum.h>
83 #include <vnet/span/span.h>
84 #include <vnet/fib/ip6_fib.h>
85 #include <vnet/fib/ip4_fib.h>
86 #include <vnet/fib/fib_api.h>
87 #include <vnet/dpo/drop_dpo.h>
88 #include <vnet/dpo/receive_dpo.h>
89 #include <vnet/dpo/lookup_dpo.h>
90 #include <vnet/dpo/classify_dpo.h>
91 #include <vnet/dpo/ip_null_dpo.h>
92 #define vl_typedefs /* define message structures */
93 #include <vpp/api/vpe_all_api_h.h>
94 #undef vl_typedefs
95 #define vl_endianfun /* define message structures */
96 #include <vpp/api/vpe_all_api_h.h>
97 #undef vl_endianfun
98 /* instantiate all the print functions we know about */
99 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
100 #define vl_printfun
101 #include <vpp/api/vpe_all_api_h.h>
102 #undef vl_printfun
104 #define foreach_vpe_api_msg \
105 _(WANT_OAM_EVENTS, want_oam_events) \
106 _(OAM_ADD_DEL, oam_add_del) \
107 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
108 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
109 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
110 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
111 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
112 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
113 _(CREATE_SUBIF, create_subif) \
114 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
115 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
116 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
117 _(RESET_FIB, reset_fib) \
118 _(CREATE_LOOPBACK, create_loopback) \
119 _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
120 _(CONTROL_PING, control_ping) \
121 _(CLI_REQUEST, cli_request) \
122 _(CLI_INBAND, cli_inband) \
123 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
124 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
125 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
126 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
127 _(GET_NODE_INDEX, get_node_index) \
128 _(ADD_NODE_NEXT, add_node_next) \
129 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
130 _(SHOW_VERSION, show_version) \
131 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
132 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
133 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \
134 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
135 _(DELETE_LOOPBACK, delete_loopback) \
136 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
137 _(GET_NODE_GRAPH, get_node_graph) \
138 _(IOAM_ENABLE, ioam_enable) \
139 _(IOAM_DISABLE, ioam_disable) \
140 _(GET_NEXT_INDEX, get_next_index) \
141 _(PG_CREATE_INTERFACE, pg_create_interface) \
142 _(PG_CAPTURE, pg_capture) \
143 _(PG_ENABLE_DISABLE, pg_enable_disable) \
144 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
145  ip_source_and_port_range_check_add_del) \
146 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
147  ip_source_and_port_range_check_interface_add_del) \
148 _(DELETE_SUBIF, delete_subif) \
149 _(PUNT, punt) \
150 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)
151 
152 #define QUOTE_(x) #x
153 #define QUOTE(x) QUOTE_(x)
154 typedef enum
155 {
158 } resolve_t;
159 
162 
163 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
164 static int nd_change_delete_callback (u32 pool_index, u8 * notused);
165 
166 /* Clean up all registrations belonging to the indicated client */
167 static clib_error_t *
169 {
172  uword *p;
173  int stats_memclnt_delete_callback (u32 client_index);
174 
175  stats_memclnt_delete_callback (client_index);
176 
177 #define _(a) \
178  p = hash_get (vam->a##_registration_hash, client_index); \
179  if (p) { \
180  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
181  pool_put (vam->a##_registrations, rp); \
182  hash_unset (vam->a##_registration_hash, client_index); \
183  }
185 #undef _
186  return 0;
187 }
188 
190 
191 pub_sub_handler (oam_events, OAM_EVENTS);
192 
193 #define RESOLUTION_EVENT 1
194 #define RESOLUTION_PENDING_EVENT 2
195 #define IP4_ARP_EVENT 3
196 #define IP6_ND_EVENT 4
197 
199 
201 
202 void
204 {
206  vnet_main_t *vnm = vam->vnet_main;
207  vlib_main_t *vm = vam->vlib_main;
208  vl_api_ip4_arp_event_t *event;
211 
212  /* Client can cancel, die, etc. */
213  if (pool_is_free_index (vam->arp_events, pool_index))
214  return;
215 
216  event = pool_elt_at_index (vam->arp_events, pool_index);
217 
219  if (!q)
220  {
223  event->pid, &event->address,
224  vpe_resolver_process_node.index, IP4_ARP_EVENT,
225  ~0 /* pool index, notused */ , 0 /* is_add */ );
226  return;
227  }
228 
229  if (q->cursize < q->maxsize)
230  {
231  mp = vl_msg_api_alloc (sizeof (*mp));
232  clib_memcpy (mp, event, sizeof (*mp));
233  vl_msg_api_send_shmem (q, (u8 *) & mp);
234  }
235  else
236  {
237  static f64 last_time;
238  /*
239  * Throttle syslog msgs.
240  * It's pretty tempting to just revoke the registration...
241  */
242  if (vlib_time_now (vm) > last_time + 10.0)
243  {
244  clib_warning ("arp event for %U to pid %d: queue stuffed!",
245  format_ip4_address, &event->address, event->pid);
246  last_time = vlib_time_now (vm);
247  }
248  }
249 }
250 
251 void
253 {
255  vnet_main_t *vnm = vam->vnet_main;
256  vlib_main_t *vm = vam->vlib_main;
257  vl_api_ip6_nd_event_t *event;
260 
261  /* Client can cancel, die, etc. */
262  if (pool_is_free_index (vam->nd_events, pool_index))
263  return;
264 
265  event = pool_elt_at_index (vam->nd_events, pool_index);
266 
268  if (!q)
269  {
272  event->pid, &event->address,
273  vpe_resolver_process_node.index, IP6_ND_EVENT,
274  ~0 /* pool index, notused */ , 0 /* is_add */ );
275  return;
276  }
277 
278  if (q->cursize < q->maxsize)
279  {
280  mp = vl_msg_api_alloc (sizeof (*mp));
281  clib_memcpy (mp, event, sizeof (*mp));
282  vl_msg_api_send_shmem (q, (u8 *) & mp);
283  }
284  else
285  {
286  static f64 last_time;
287  /*
288  * Throttle syslog msgs.
289  * It's pretty tempting to just revoke the registration...
290  */
291  if (vlib_time_now (vm) > last_time + 10.0)
292  {
293  clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
294  format_ip6_address, &event->address, event->pid);
295  last_time = vlib_time_now (vm);
296  }
297  }
298 }
299 
300 static uword
303 {
304  uword event_type;
305  uword *event_data = 0;
306  f64 timeout = 100.0;
307  int i;
308 
309  while (1)
310  {
312 
313  event_type = vlib_process_get_events (vm, &event_data);
314 
315  switch (event_type)
316  {
318  timeout = 1.0;
319  break;
320 
321  case RESOLUTION_EVENT:
322  clib_warning ("resolver: BOGUS TYPE");
323  break;
324 
325  case IP4_ARP_EVENT:
326  for (i = 0; i < vec_len (event_data); i++)
327  handle_ip4_arp_event (event_data[i]);
328  break;
329 
330  case IP6_ND_EVENT:
331  for (i = 0; i < vec_len (event_data); i++)
332  handle_ip6_nd_event (event_data[i]);
333  break;
334 
335  case ~0: /* timeout */
336  break;
337  }
338 
339  vec_reset_length (event_data);
340  }
341  return 0; /* or not */
342 }
343 
344 /* *INDENT-OFF* */
345 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
346  .function = resolver_process,
347  .type = VLIB_NODE_TYPE_PROCESS,
348  .name = "vpe-route-resolver-process",
349 };
350 /* *INDENT-ON* */
351 
352 static void
354 {
356  int rv = 0;
357  u32 sw_if_index = ntohl (mp->sw_if_index);
358 
360 
361  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
362  vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
363  sw_if_index, mp->enable, 0, 0);
364  vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
365  sw_if_index, mp->enable, 0, 0);
366  vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
367  sw_if_index, mp->enable, 0, 0);
368  vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
369  sw_if_index, mp->enable, 0, 0);
370 
372 
373  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
374 }
375 
376 static void
379 {
381  int rv = 0;
382  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
383  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
385  vnet_main_t *vnm = vnet_get_main ();
386 
388 
389  if (mp->enable)
390  {
392  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
393  rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
394  }
395  else
396  {
397  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
398  }
399 
402 
403  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
404 }
405 
406 static void
409 {
410  bd_main_t *bdm = &bd_main;
412  int rv = 0;
413  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
414  u32 bd_id = ntohl (mp->bd_id);
415  u32 bd_index;
416  u32 bvi = mp->bvi;
417  u8 shg = mp->shg;
419  vnet_main_t *vnm = vnet_get_main ();
420 
422 
423  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
424 
425  if (mp->enable)
426  {
427  //VALIDATE_TX_SW_IF_INDEX(mp);
428  rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
429  rx_sw_if_index, bd_index, bvi, shg, 0);
430  }
431  else
432  {
433  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
434  }
435 
437 
438  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
439 }
440 
441 static void
443 {
444  bd_main_t *bdm = &bd_main;
446  int rv = 0;
447  u32 bd_id = ntohl (mp->bd_id);
448  u32 bd_index;
449  uword *p;
450 
451  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
452  if (p == 0)
453  {
454  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
455  goto out;
456  }
457 
458  bd_index = p[0];
459  if (bd_add_del_ip_mac (bd_index, mp->ip_address,
460  mp->mac_address, mp->is_ipv6, mp->is_add))
461  rv = VNET_API_ERROR_UNSPECIFIED;
462 
463 out:
464  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
465 }
466 
467 static void
469 {
471  vnet_main_t *vnm = vnet_get_main ();
472  u32 sw_if_index = (u32) ~ 0;
474  int rv = 0;
475  u32 id;
476  vnet_sw_interface_t template;
477  uword *p;
479  u64 sup_and_sub_key;
481  clib_error_t *error;
482 
484 
485  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
486 
488  {
489  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
490  goto out;
491  }
492 
493  id = ntohl (mp->vlan_id);
494  if (id == 0 || id > 4095)
495  {
496  rv = VNET_API_ERROR_INVALID_VLAN;
497  goto out;
498  }
499 
500  sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
501 
502  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
503  if (p)
504  {
505  rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
506  goto out;
507  }
508 
509  memset (&template, 0, sizeof (template));
510  template.type = VNET_SW_INTERFACE_TYPE_SUB;
511  template.sup_sw_if_index = hi->sw_if_index;
512  template.sub.id = id;
513  template.sub.eth.raw_flags = 0;
514  template.sub.eth.flags.one_tag = 1;
515  template.sub.eth.outer_vlan_id = id;
516  template.sub.eth.flags.exact_match = 1;
517 
518  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
519  if (error)
520  {
521  clib_error_report (error);
522  rv = VNET_API_ERROR_INVALID_REGISTRATION;
523  goto out;
524  }
525 
526  u64 *kp = clib_mem_alloc (sizeof (*kp));
527  *kp = sup_and_sub_key;
528 
529  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
530  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
531 
533 
534 out:
536  if (!q)
537  return;
538 
539  rmp = vl_msg_api_alloc (sizeof (*rmp));
540  rmp->_vl_msg_id = htons (VL_API_CREATE_VLAN_SUBIF_REPLY);
541  rmp->context = mp->context;
542  rmp->retval = htonl (rv);
543  rmp->sw_if_index = htonl (sw_if_index);
544  vl_msg_api_send_shmem (q, (u8 *) & rmp);
545 }
546 
547 static void
549 {
551  vnet_main_t *vnm = vnet_get_main ();
552  u32 sw_if_index = ~0;
553  int rv = 0;
554  u32 sub_id;
557  vnet_sw_interface_t template;
558  uword *p;
560  u64 sup_and_sub_key;
561  clib_error_t *error;
562 
564 
565  si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
566  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
567 
569  {
570  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
571  goto out;
572  }
573 
574  sw_if_index = si->sw_if_index;
575  sub_id = ntohl (mp->sub_id);
576 
577  sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
578 
579  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
580  if (p)
581  {
582  if (CLIB_DEBUG > 0)
583  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
584  sw_if_index, sub_id);
585  rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
586  goto out;
587  }
588 
589  memset (&template, 0, sizeof (template));
590  template.type = VNET_SW_INTERFACE_TYPE_SUB;
591  template.sup_sw_if_index = sw_if_index;
592  template.sub.id = sub_id;
593  template.sub.eth.flags.no_tags = mp->no_tags;
594  template.sub.eth.flags.one_tag = mp->one_tag;
595  template.sub.eth.flags.two_tags = mp->two_tags;
596  template.sub.eth.flags.dot1ad = mp->dot1ad;
597  template.sub.eth.flags.exact_match = mp->exact_match;
598  template.sub.eth.flags.default_sub = mp->default_sub;
599  template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
600  template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
601  template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
602  template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
603 
604  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
605  if (error)
606  {
607  clib_error_report (error);
608  rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
609  goto out;
610  }
611 
612  u64 *kp = clib_mem_alloc (sizeof (*kp));
613  *kp = sup_and_sub_key;
614 
615  hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
616  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
617 
619 
620 out:
621 
622  /* *INDENT-OFF* */
623  REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
624  ({
625  rmp->sw_if_index = ntohl(sw_if_index);
626  }));
627  /* *INDENT-ON* */
628 }
629 
630 static void
632 {
634  u32 fib_index;
635  int rv;
636  ip4_main_t *im = &ip4_main;
637  stats_main_t *sm = &stats_main;
638  int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
639  ip4_address_t * hi_addr,
640  u32 fib_index, int is_del);
641  uword *p;
642 
643  dslock (sm, 1 /* release hint */ , 6 /* tag */ );
644 
645  p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
646 
647  if (!p)
648  {
649  rv = VNET_API_ERROR_NO_SUCH_FIB;
650  goto out;
651  }
652 
653  fib_index = p[0];
654 
656  (ip4_address_t *) mp->hi_address,
657  fib_index, mp->is_add == 0);
658 
659 out:
660  dsunlock (sm);
661  REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
662 }
663 
664 static void
667 {
668  int rv = 0;
669  vnet_main_t *vnm = vnet_get_main ();
671 
673 
674  vnet_sw_interface_t *si =
675  vnet_get_sw_interface (vnm, ntohl (mp->sw_if_index));
676 
677  ASSERT (si);
678 
679  if (mp->enable_disable)
681  else
683 
685 
686 out:
687  REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
688 }
689 
690 static void
692 {
693 #if 0
694  vpe_main_t *rm = &vpe_main;
695  ip4_main_t *im4 = &ip4_main;
696  ip6_main_t *im6 = &ip6_main;
697  ip_lookup_main_t *lm;
698  union
699  {
700  ip4_address_t ip4;
701  ip6_address_t ip6;
702  } addr;
703  u32 adj_index, sw_if_index;
705  ip_adjacency_t *adj;
707 
709  if (!q)
710  {
711  increment_missing_api_client_counter (rm->vlib_main);
712  return;
713  }
714 
715  rmp = vl_msg_api_alloc (sizeof (*rmp));
716  clib_memcpy (rmp, mp, sizeof (*rmp));
717 
718  sw_if_index = mp->next_hop_sw_if_index;
719  clib_memcpy (&addr, mp->address, sizeof (addr));
720  if (mp->is_ipv6)
721  {
722  lm = &im6->lookup_main;
723  adj_index = ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
724  }
725  else
726  {
727  lm = &im4->lookup_main;
728  // FIXME NOT an ADJ
729  adj_index = ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
730  }
731  if (adj_index == ~0)
732  {
733  rmp->is_error = 1;
734  goto send;
735  }
736  adj = ip_get_adjacency (lm, adj_index);
737 
739  && adj->rewrite_header.sw_if_index == sw_if_index)
740  {
741  rmp->is_known = 1;
742  }
743  else
744  {
746  && adj->rewrite_header.sw_if_index == sw_if_index)
747  {
748  if (mp->is_ipv6)
749  ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
750  else
751  ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
752  }
753  else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP)
754  {
755  rmp->is_known = 1;
756  goto send;
757  }
758  rmp->is_known = 0;
759  }
760 
761 send:
762  vl_msg_api_send_shmem (q, (u8 *) & rmp);
763 #endif
764 }
765 
766 static void
769 {
771  int rv = 0;
772 
774 
776  ntohl (mp->sw_if_index), mp->enable);
777 
779  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
780 }
781 
782 void
784 {
788  vl_api_oam_event_t *mp;
789 
790  /* *INDENT-OFF* */
791  pool_foreach(reg, vam->oam_events_registrations,
792  ({
793  q = vl_api_client_index_to_input_queue (reg->client_index);
794  if (q)
795  {
796  mp = vl_msg_api_alloc (sizeof (*mp));
797  mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
798  clib_memcpy (mp->dst_address, &t->dst_address,
799  sizeof (mp->dst_address));
800  mp->state = t->state;
801  vl_msg_api_send_shmem (q, (u8 *)&mp);
802  }
803  }));
804  /* *INDENT-ON* */
805 }
806 
807 static void
809 {
811  int rv;
812 
814  (ip4_address_t *) mp->dst_address,
815  ntohl (mp->vrf_id), (int) (mp->is_add));
816 
817  REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
818 }
819 
820 static void
822 {
823  stats_main_t *sm = &stats_main;
828  int i, which;
829  u64 total_pkts[VLIB_N_RX_TX];
830  u64 total_bytes[VLIB_N_RX_TX];
831 
834 
835  if (!q)
836  return;
837 
838  rmp = vl_msg_api_alloc (sizeof (*rmp));
839  rmp->_vl_msg_id = ntohs (VL_API_VNET_SUMMARY_STATS_REPLY);
840  rmp->context = mp->context;
841  rmp->retval = 0;
842 
843  memset (total_pkts, 0, sizeof (total_pkts));
844  memset (total_bytes, 0, sizeof (total_bytes));
845 
847 
849  {
850  which = cm - im->combined_sw_if_counters;
851 
852  for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
853  {
854  vlib_get_combined_counter (cm, i, &v);
855  total_pkts[which] += v.packets;
856  total_bytes[which] += v.bytes;
857  }
858  }
860 
861  rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
862  rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
863  rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
864  rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
865  rmp->vector_rate =
866  clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
867 
868  vl_msg_api_send_shmem (q, (u8 *) & rmp);
869 }
870 
871 /* *INDENT-OFF* */
872 typedef CLIB_PACKED (struct {
873  ip4_address_t address;
874  u32 address_length: 6;
875  u32 index:26;
876 }) ip4_route_t;
877 /* *INDENT-ON* */
878 
879 static int
880 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
881 {
882  vnet_main_t *vnm = vnet_get_main ();
884  ip4_main_t *im4 = &ip4_main;
885  static u32 *sw_if_indices_to_shut;
886  stats_main_t *sm = &stats_main;
887  fib_table_t *fib_table;
888  ip4_fib_t *fib;
889  u32 sw_if_index;
890  int i;
891  int rv = VNET_API_ERROR_NO_SUCH_FIB;
892  u32 target_fib_id = ntohl (mp->vrf_id);
893 
894  dslock (sm, 1 /* release hint */ , 8 /* tag */ );
895 
896  /* *INDENT-OFF* */
897  pool_foreach (fib_table, im4->fibs,
898  ({
899  fib = &fib_table->v4;
900  vnet_sw_interface_t * si;
901 
902  if (fib->table_id != target_fib_id)
903  continue;
904 
905  /* remove any mpls encap/decap labels */
906  mpls_fib_reset_labels (fib->table_id);
907 
908  /* remove any proxy arps in this fib */
909  vnet_proxy_arp_fib_reset (fib->table_id);
910 
911  /* Set the flow hash for this fib to the default */
912  vnet_set_ip4_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
913 
914  vec_reset_length (sw_if_indices_to_shut);
915 
916  /* Shut down interfaces in this FIB / clean out intfc routes */
917  pool_foreach (si, im->sw_interfaces,
918  ({
919  u32 sw_if_index = si->sw_if_index;
920 
921  if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
922  && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
923  fib->index))
924  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
925  }));
926 
927  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
928  sw_if_index = sw_if_indices_to_shut[i];
929 
930  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
932  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
933  }
934 
936 
937  rv = 0;
938  break;
939  })); /* pool_foreach (fib) */
940  /* *INDENT-ON* */
941 
942  dsunlock (sm);
943  return rv;
944 }
945 
946 static int
948 {
949  vnet_main_t *vnm = vnet_get_main ();
951  ip6_main_t *im6 = &ip6_main;
952  stats_main_t *sm = &stats_main;
953  static u32 *sw_if_indices_to_shut;
954  fib_table_t *fib_table;
955  ip6_fib_t *fib;
956  u32 sw_if_index;
957  int i;
958  int rv = VNET_API_ERROR_NO_SUCH_FIB;
959  u32 target_fib_id = ntohl (mp->vrf_id);
960 
961  dslock (sm, 1 /* release hint */ , 9 /* tag */ );
962 
963  /* *INDENT-OFF* */
964  pool_foreach (fib_table, im6->fibs,
965  ({
966  vnet_sw_interface_t * si;
967  fib = &(fib_table->v6);
968 
969  if (fib->table_id != target_fib_id)
970  continue;
971 
972  vec_reset_length (sw_if_indices_to_shut);
973 
974  /* Shut down interfaces in this FIB / clean out intfc routes */
975  pool_foreach (si, im->sw_interfaces,
976  ({
977  if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
978  fib->index)
979  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
980  }));
981 
982  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
983  sw_if_index = sw_if_indices_to_shut[i];
984 
985  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
987  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
988  }
989 
991 
992  rv = 0;
993  break;
994  })); /* pool_foreach (fib) */
995  /* *INDENT-ON* */
996 
997  dsunlock (sm);
998  return rv;
999 }
1000 
1001 static void
1003 {
1004  int rv;
1006 
1007  if (mp->is_ipv6)
1008  rv = ip6_reset_fib_t_handler (mp);
1009  else
1010  rv = ip4_reset_fib_t_handler (mp);
1011 
1012  REPLY_MACRO (VL_API_RESET_FIB_REPLY);
1013 }
1014 
1015 static void
1017 {
1019  u32 sw_if_index;
1020  int rv;
1021 
1022  rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0);
1023 
1024  /* *INDENT-OFF* */
1025  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
1026  ({
1027  rmp->sw_if_index = ntohl (sw_if_index);
1028  }));
1029  /* *INDENT-ON* */
1030 }
1031 
1034 {
1036  u32 sw_if_index;
1037  u8 is_specified = mp->is_specified;
1038  u32 user_instance = ntohl (mp->user_instance);
1039  int rv;
1040 
1041  rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address,
1042  is_specified, user_instance);
1043 
1044  /* *INDENT-OFF* */
1045  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY,
1046  ({
1047  rmp->sw_if_index = ntohl (sw_if_index);
1048  }));
1049  /* *INDENT-ON* */
1050 }
1051 
1052 static void
1054 {
1056  u32 sw_if_index;
1057  int rv;
1058 
1059  sw_if_index = ntohl (mp->sw_if_index);
1060  rv = vnet_delete_loopback_interface (sw_if_index);
1061 
1062  REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
1063 }
1064 
1065 static void
1067 {
1069  int rv = 0;
1070 
1071  /* *INDENT-OFF* */
1072  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
1073  ({
1074  rmp->vpe_pid = ntohl (getpid());
1075  }));
1076  /* *INDENT-ON* */
1077 }
1078 
1079 static void
1080 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1081 {
1082  u8 **shmem_vecp = (u8 **) arg;
1083  u8 *shmem_vec;
1084  void *oldheap;
1085  api_main_t *am = &api_main;
1086  u32 offset;
1087 
1088  shmem_vec = *shmem_vecp;
1089 
1090  offset = vec_len (shmem_vec);
1091 
1092  pthread_mutex_lock (&am->vlib_rp->mutex);
1093  oldheap = svm_push_data_heap (am->vlib_rp);
1094 
1095  vec_validate (shmem_vec, offset + buffer_bytes - 1);
1096 
1097  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
1098 
1099  svm_pop_heap (oldheap);
1100  pthread_mutex_unlock (&am->vlib_rp->mutex);
1101 
1102  *shmem_vecp = shmem_vec;
1103 }
1104 
1105 
1106 static void
1108 {
1109  vl_api_cli_reply_t *rp;
1112  api_main_t *am = &api_main;
1113  unformat_input_t input;
1114  u8 *shmem_vec = 0;
1115  void *oldheap;
1116 
1118  if (!q)
1119  return;
1120 
1121  rp = vl_msg_api_alloc (sizeof (*rp));
1122  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
1123  rp->context = mp->context;
1124 
1125  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
1126 
1127  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
1128 
1129  pthread_mutex_lock (&am->vlib_rp->mutex);
1130  oldheap = svm_push_data_heap (am->vlib_rp);
1131 
1132  vec_add1 (shmem_vec, 0);
1133 
1134  svm_pop_heap (oldheap);
1135  pthread_mutex_unlock (&am->vlib_rp->mutex);
1136 
1137  rp->reply_in_shmem = (uword) shmem_vec;
1138 
1139  vl_msg_api_send_shmem (q, (u8 *) & rp);
1140 }
1141 
1142 static void
1143 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1144 {
1145  u8 **mem_vecp = (u8 **) arg;
1146  u8 *mem_vec = *mem_vecp;
1147  u32 offset = vec_len (mem_vec);
1148 
1149  vec_validate (mem_vec, offset + buffer_bytes - 1);
1150  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
1151  *mem_vecp = mem_vec;
1152 }
1153 
1154 static void
1156 {
1158  int rv = 0;
1161  unformat_input_t input;
1162  u8 *out_vec = 0;
1163 
1165  if (!q)
1166  return;
1167 
1168  unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
1169  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
1170 
1171  u32 len = vec_len (out_vec);
1172  /* *INDENT-OFF* */
1173  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
1174  ({
1175  rmp->length = htonl (len);
1176  clib_memcpy (rmp->reply, out_vec, len);
1177  }));
1178  /* *INDENT-ON* */
1179  vec_free (out_vec);
1180 }
1181 
1182 static void
1184 {
1185  int rv;
1187  vnet_main_t *vnm = vnet_get_main ();
1188  clib_error_t *error;
1189 
1190  vnm->api_errno = 0;
1191 
1192  if (mp->is_ipv6)
1193  error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
1194  else
1195  error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
1196 
1197  if (error)
1198  {
1199  clib_error_report (error);
1200  rv = VNET_API_ERROR_UNSPECIFIED;
1201  }
1202  else
1203  {
1204  rv = vnm->api_errno;
1205  }
1206 
1207  REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
1208 }
1209 
1212 {
1215  int rv;
1216 
1217  VALIDATE_SW_IF_INDEX (mp);
1218 
1219  u32 table_index = ntohl (mp->table_index);
1220  u32 sw_if_index = ntohl (mp->sw_if_index);
1221 
1222  if (mp->is_ipv6)
1223  rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
1224  else
1225  rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
1226 
1228 
1229  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
1230 }
1231 
1234 {
1236  int rv;
1237  u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
1238  int enable;
1239 
1240  ip4_table_index = ntohl (mp->ip4_table_index);
1241  ip6_table_index = ntohl (mp->ip6_table_index);
1242  other_table_index = ntohl (mp->other_table_index);
1243  sw_if_index = ntohl (mp->sw_if_index);
1244 
1245  VALIDATE_SW_IF_INDEX (mp);
1246 
1247  if (mp->is_input)
1248  rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
1249  ip6_table_index,
1250  other_table_index);
1251  else
1252  rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
1253  ip6_table_index,
1254  other_table_index);
1255 
1256  if (rv == 0)
1257  {
1258  if (ip4_table_index != ~0 || ip6_table_index != ~0
1259  || other_table_index != ~0)
1260  enable = 1;
1261  else
1262  enable = 0;
1263 
1264  if (mp->is_input)
1265  vnet_l2_input_classify_enable_disable (sw_if_index, enable);
1266  else
1267  vnet_l2_output_classify_enable_disable (sw_if_index, enable);
1268  }
1269 
1271 
1272  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
1273 }
1274 
1275 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
1276  u32 sw_if_index, u32 enable);
1277 
1278 static void
1280  mp)
1281 {
1282  int rv;
1284  vnet_main_t *vnm = vnet_get_main ();
1285 
1286  // enable/disable the feature
1288  rv = vnm->api_errno;
1289 
1290  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
1291 }
1292 
1293 static void
1295 {
1297  int rv = 0;
1298  char *vpe_api_get_build_directory (void);
1299  char *vpe_api_get_version (void);
1300  char *vpe_api_get_build_date (void);
1301 
1304 
1305  if (!q)
1306  return;
1307 
1308  /* *INDENT-OFF* */
1309  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
1310  ({
1311  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
1312  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
1313  ARRAY_LEN(rmp->build_directory)-1);
1314  strncpy ((char *) rmp->version, vpe_api_get_version(),
1315  ARRAY_LEN(rmp->version)-1);
1316  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
1317  ARRAY_LEN(rmp->build_date)-1);
1318  }));
1319  /* *INDENT-ON* */
1320 }
1321 
1322 static void
1324 {
1327  vlib_node_t *n;
1328  int rv = 0;
1329  u32 node_index = ~0;
1330 
1331  n = vlib_get_node_by_name (vm, mp->node_name);
1332 
1333  if (n == 0)
1334  rv = VNET_API_ERROR_NO_SUCH_NODE;
1335  else
1336  node_index = n->index;
1337 
1338  /* *INDENT-OFF* */
1339  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1340  ({
1341  rmp->node_index = ntohl(node_index);
1342  }));
1343  /* *INDENT-ON* */
1344 }
1345 
1346 static void
1348 {
1351  vlib_node_t *node, *next_node;
1352  int rv = 0;
1353  u32 next_node_index = ~0, next_index = ~0;
1354  uword *p;
1355 
1356  node = vlib_get_node_by_name (vm, mp->node_name);
1357 
1358  if (node == 0)
1359  {
1360  rv = VNET_API_ERROR_NO_SUCH_NODE;
1361  goto out;
1362  }
1363 
1364  next_node = vlib_get_node_by_name (vm, mp->next_name);
1365 
1366  if (next_node == 0)
1367  {
1368  rv = VNET_API_ERROR_NO_SUCH_NODE2;
1369  goto out;
1370  }
1371  else
1372  next_node_index = next_node->index;
1373 
1374  p = hash_get (node->next_slot_by_node, next_node_index);
1375 
1376  if (p == 0)
1377  {
1378  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1379  goto out;
1380  }
1381  else
1382  next_index = p[0];
1383 
1384 out:
1385  /* *INDENT-OFF* */
1386  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
1387  ({
1388  rmp->next_index = ntohl(next_index);
1389  }));
1390  /* *INDENT-ON* */
1391 }
1392 
1393 static void
1395 {
1398  vlib_node_t *n, *next;
1399  int rv = 0;
1400  u32 next_index = ~0;
1401 
1402  n = vlib_get_node_by_name (vm, mp->node_name);
1403 
1404  if (n == 0)
1405  {
1406  rv = VNET_API_ERROR_NO_SUCH_NODE;
1407  goto out;
1408  }
1409 
1410  next = vlib_get_node_by_name (vm, mp->next_name);
1411 
1412  if (next == 0)
1413  rv = VNET_API_ERROR_NO_SUCH_NODE2;
1414  else
1415  next_index = vlib_node_add_next (vm, n->index, next->index);
1416 
1417 out:
1418  /* *INDENT-OFF* */
1419  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1420  ({
1421  rmp->next_index = ntohl(next_index);
1422  }));
1423  /* *INDENT-ON* */
1424 }
1425 
1426 static void
1428 {
1429  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1430  int is_add);
1432  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1433  int is_add);
1434  int rv = 0;
1435 
1438 
1439  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
1440  ntohl (mp->tx_sw_if_index),
1441  (int) (mp->is_add != 0));
1442 
1445 
1446  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
1447 }
1448 
1449 static void
1451  mp)
1452 {
1454  int rv = 0;
1455 
1456  VALIDATE_SW_IF_INDEX (mp);
1457 
1459  (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
1460 
1462 
1463  REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
1464 }
1465 
1466 static int
1467 arp_change_data_callback (u32 pool_index, u8 * new_mac,
1468  u32 sw_if_index, u32 address)
1469 {
1471  vlib_main_t *vm = am->vlib_main;
1472  vl_api_ip4_arp_event_t *event;
1473  static f64 arp_event_last_time;
1474  f64 now = vlib_time_now (vm);
1475 
1476  if (pool_is_free_index (am->arp_events, pool_index))
1477  return 1;
1478 
1479  event = pool_elt_at_index (am->arp_events, pool_index);
1480  /* *INDENT-OFF* */
1481  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
1482  {
1483  clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
1484  }
1485  else
1486  { /* same mac */
1487  if (sw_if_index == ntohl(event->sw_if_index) &&
1488  (!event->mac_ip ||
1489  /* for BD case, also check IP address with 10 sec timeout */
1490  (address == event->address &&
1491  (now - arp_event_last_time) < 10.0)))
1492  return 1;
1493  }
1494  /* *INDENT-ON* */
1495 
1496  arp_event_last_time = now;
1497  event->sw_if_index = htonl (sw_if_index);
1498  if (event->mac_ip)
1499  event->address = address;
1500  return 0;
1501 }
1502 
1503 static int
1504 nd_change_data_callback (u32 pool_index, u8 * new_mac,
1505  u32 sw_if_index, ip6_address_t * address)
1506 {
1508  vlib_main_t *vm = am->vlib_main;
1509  vl_api_ip6_nd_event_t *event;
1510  static f64 nd_event_last_time;
1511  f64 now = vlib_time_now (vm);
1512 
1513  if (pool_is_free_index (am->nd_events, pool_index))
1514  return 1;
1515 
1516  event = pool_elt_at_index (am->nd_events, pool_index);
1517 
1518  /* *INDENT-OFF* */
1519  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
1520  {
1521  clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
1522  }
1523  else
1524  { /* same mac */
1525  if (sw_if_index == ntohl(event->sw_if_index) &&
1526  (!event->mac_ip ||
1527  /* for BD case, also check IP address with 10 sec timeout */
1528  (ip6_address_is_equal (address,
1529  (ip6_address_t *) event->address) &&
1530  (now - nd_event_last_time) < 10.0)))
1531  return 1;
1532  }
1533  /* *INDENT-ON* */
1534 
1535  nd_event_last_time = now;
1536  event->sw_if_index = htonl (sw_if_index);
1537  if (event->mac_ip)
1538  clib_memcpy (event->address, address, sizeof (event->address));
1539  return 0;
1540 }
1541 
1542 static int
1543 arp_change_delete_callback (u32 pool_index, u8 * notused)
1544 {
1546 
1547  if (pool_is_free_index (am->arp_events, pool_index))
1548  return 1;
1549 
1550  pool_put_index (am->arp_events, pool_index);
1551  return 0;
1552 }
1553 
1554 static int
1555 nd_change_delete_callback (u32 pool_index, u8 * notused)
1556 {
1558 
1559  if (pool_is_free_index (am->nd_events, pool_index))
1560  return 1;
1561 
1562  pool_put_index (am->nd_events, pool_index);
1563  return 0;
1564 }
1565 
1566 static void
1568 {
1570  vnet_main_t *vnm = vnet_get_main ();
1572  vl_api_ip4_arp_event_t *event;
1573  int rv;
1574 
1575  if (mp->enable_disable)
1576  {
1577  pool_get (am->arp_events, event);
1578  memset (event, 0, sizeof (*event));
1579 
1580  event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
1581  event->client_index = mp->client_index;
1582  event->context = mp->context;
1583  event->address = mp->address;
1584  event->pid = mp->pid;
1585  if (mp->address == 0)
1586  event->mac_ip = 1;
1587 
1590  mp->pid, &mp->address /* addr, in net byte order */ ,
1591  vpe_resolver_process_node.index,
1592  IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
1593  }
1594  else
1595  {
1598  mp->pid, &mp->address /* addr, in net byte order */ ,
1599  vpe_resolver_process_node.index,
1600  IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
1601  }
1602  REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
1603 }
1604 
1605 static void
1607 {
1609  vnet_main_t *vnm = vnet_get_main ();
1611  vl_api_ip6_nd_event_t *event;
1612  int rv;
1613 
1614  if (mp->enable_disable)
1615  {
1616  pool_get (am->nd_events, event);
1617  memset (event, 0, sizeof (*event));
1618 
1619  event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
1620  event->client_index = mp->client_index;
1621  event->context = mp->context;
1622  clib_memcpy (event->address, mp->address, 16);
1623  event->pid = mp->pid;
1625  event->mac_ip = 1;
1626 
1629  mp->pid, mp->address /* addr, in net byte order */ ,
1630  vpe_resolver_process_node.index,
1631  IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
1632  }
1633  else
1634  {
1637  mp->pid, mp->address /* addr, in net byte order */ ,
1638  vpe_resolver_process_node.index,
1639  IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
1640  }
1641  REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY);
1642 }
1643 
1646 {
1649  int rv;
1650 
1651  VALIDATE_SW_IF_INDEX (mp);
1652 
1653  u32 ip4_table_index = ntohl (mp->ip4_table_index);
1654  u32 ip6_table_index = ntohl (mp->ip6_table_index);
1655  u32 l2_table_index = ntohl (mp->l2_table_index);
1656  u32 sw_if_index = ntohl (mp->sw_if_index);
1657 
1658  rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
1659  ip6_table_index, l2_table_index, mp->is_add);
1660 
1662 
1663  REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
1664 }
1665 
1666 static void
1668 {
1669  int rv = 0;
1670  u8 *vector = 0;
1671  api_main_t *am = &api_main;
1673  void *oldheap;
1675 
1676  pthread_mutex_lock (&am->vlib_rp->mutex);
1677  oldheap = svm_push_data_heap (am->vlib_rp);
1678 
1679  /*
1680  * Keep the number of memcpy ops to a minimum (e.g. 1).
1681  */
1682  vec_validate (vector, 16384);
1683  vec_reset_length (vector);
1684 
1685  /* $$$$ FIXME */
1686  vector = vlib_node_serialize (&vm->node_main, vector,
1687  (u32) ~ 0 /* all threads */ ,
1688  1 /* include nexts */ ,
1689  1 /* include stats */ );
1690 
1691  svm_pop_heap (oldheap);
1692  pthread_mutex_unlock (&am->vlib_rp->mutex);
1693 
1694  /* *INDENT-OFF* */
1695  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
1696  ({
1697  rmp->reply_in_shmem = (uword) vector;
1698  }));
1699  /* *INDENT-ON* */
1700 }
1701 
1702 static void
1704 {
1705  int rv = 0;
1707  clib_error_t *error;
1708 
1709  /* Ignoring the profile id as currently a single profile
1710  * is supported */
1711  error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
1712  mp->seqno, mp->analyse);
1713  if (error)
1714  {
1715  clib_error_report (error);
1716  rv = clib_error_get_code (error);
1717  }
1718 
1719  REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
1720 }
1721 
1722 static void
1724 {
1725  int rv = 0;
1727  clib_error_t *error;
1728 
1729  error = clear_ioam_rewrite_fn ();
1730  if (error)
1731  {
1732  clib_error_report (error);
1733  rv = clib_error_get_code (error);
1734  }
1735 
1736  REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
1737 }
1738 
1739 static void
1741 {
1743  int rv = 0;
1744 
1745  pg_main_t *pg = &pg_main;
1746  u32 pg_if_id = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
1747  pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id);
1748 
1749  /* *INDENT-OFF* */
1750  REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
1751  ({
1752  rmp->sw_if_index = ntohl(pi->sw_if_index);
1753  }));
1754  /* *INDENT-ON* */
1755 }
1756 
1757 static void
1759 {
1761  int rv = 0;
1762 
1763  vnet_main_t *vnm = vnet_get_main ();
1765  vnet_hw_interface_t *hi = 0;
1766 
1767  u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
1768  u32 hw_if_index = ~0;
1769  uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
1770  if (p)
1771  hw_if_index = *p;
1772  vec_free (intf_name);
1773 
1774  if (hw_if_index != ~0)
1775  {
1776  pg_capture_args_t _a, *a = &_a;
1777 
1778  u32 len = ntohl (mp->pcap_name_length);
1779  u8 *pcap_file_name = vec_new (u8, len);
1780  clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
1781 
1782  hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
1783  a->hw_if_index = hw_if_index;
1784  a->dev_instance = hi->dev_instance;
1785  a->is_enabled = mp->is_enabled;
1786  a->pcap_file_name = pcap_file_name;
1787  a->count = ntohl (mp->count);
1788 
1789  clib_error_t *e = pg_capture (a);
1790  if (e)
1791  {
1792  clib_error_report (e);
1793  rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
1794  }
1795 
1796  vec_free (pcap_file_name);
1797  }
1798  REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
1799 }
1800 
1801 static void
1803 {
1805  int rv = 0;
1806 
1807  pg_main_t *pg = &pg_main;
1808  u32 stream_index = ~0;
1809 
1810  int is_enable = mp->is_enabled != 0;
1811  u32 len = ntohl (mp->stream_name_length) - 1;
1812 
1813  if (len > 0)
1814  {
1815  u8 *stream_name = vec_new (u8, len);
1816  clib_memcpy (stream_name, mp->stream_name, len);
1817  uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
1818  if (p)
1819  stream_index = *p;
1820  vec_free (stream_name);
1821  }
1822 
1823  pg_enable_disable (stream_index, is_enable);
1824 
1825  REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
1826 }
1827 
1828 static void
1831 {
1833  int rv = 0;
1834 
1835  u8 is_ipv6 = mp->is_ipv6;
1836  u8 is_add = mp->is_add;
1837  u8 mask_length = mp->mask_length;
1838  ip4_address_t ip4_addr;
1839  ip6_address_t ip6_addr;
1840  u16 *low_ports = 0;
1841  u16 *high_ports = 0;
1842  u32 vrf_id;
1843  u16 tmp_low, tmp_high;
1844  u8 num_ranges;
1845  int i;
1846 
1847  // Validate port range
1848  num_ranges = mp->number_of_ranges;
1849  if (num_ranges > 32)
1850  { // This is size of array in VPE.API
1851  rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
1852  goto reply;
1853  }
1854 
1855  vec_reset_length (low_ports);
1856  vec_reset_length (high_ports);
1857 
1858  for (i = 0; i < num_ranges; i++)
1859  {
1860  tmp_low = mp->low_ports[i];
1861  tmp_high = mp->high_ports[i];
1862  // If tmp_low <= tmp_high then only need to check tmp_low = 0
1863  // If tmp_low <= tmp_high then only need to check tmp_high > 65535
1864  if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
1865  {
1866  rv = VNET_API_ERROR_INVALID_VALUE;
1867  goto reply;
1868  }
1869  vec_add1 (low_ports, tmp_low);
1870  vec_add1 (high_ports, tmp_high + 1);
1871  }
1872 
1873  // Validate mask_length
1874  if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
1875  {
1876  rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
1877  goto reply;
1878  }
1879 
1880  vrf_id = ntohl (mp->vrf_id);
1881 
1882  if (vrf_id < 1)
1883  {
1884  rv = VNET_API_ERROR_INVALID_VALUE;
1885  goto reply;
1886  }
1887 
1888 
1889  if (is_ipv6)
1890  {
1891  clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
1893  mask_length,
1894  vrf_id,
1895  low_ports,
1896  high_ports, is_add);
1897  }
1898  else
1899  {
1900  clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
1902  mask_length,
1903  vrf_id,
1904  low_ports,
1905  high_ports, is_add);
1906  }
1907 
1908 reply:
1909  vec_free (low_ports);
1910  vec_free (high_ports);
1911  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
1912 }
1913 
1914 static void
1917 {
1920  ip4_main_t *im = &ip4_main;
1921  int rv;
1922  u32 sw_if_index;
1925  uword *p = 0;
1926  int i;
1927 
1929  ntohl (mp->tcp_out_vrf_id);
1931  ntohl (mp->udp_out_vrf_id);
1933  ntohl (mp->tcp_in_vrf_id);
1935  ntohl (mp->udp_in_vrf_id);
1936 
1937 
1938  for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
1939  {
1940  if (vrf_id[i] != 0 && vrf_id[i] != ~0)
1941  {
1942  p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
1943 
1944  if (p == 0)
1945  {
1946  rv = VNET_API_ERROR_INVALID_VALUE;
1947  goto reply;
1948  }
1949 
1950  fib_index[i] = p[0];
1951  }
1952  else
1953  fib_index[i] = ~0;
1954  }
1955  sw_if_index = ntohl (mp->sw_if_index);
1956 
1957  VALIDATE_SW_IF_INDEX (mp);
1958 
1959  rv =
1960  set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
1961  mp->is_add);
1962 
1964 reply:
1965 
1966  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
1967 }
1968 
1969 static void
1971 {
1973  int rv;
1974 
1975  rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
1976 
1977  REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
1978 }
1979 
1980 static void
1982 {
1983  vl_api_punt_reply_t *rmp;
1985  int rv = 0;
1986  clib_error_t *error;
1987 
1988  error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
1989  ntohs (mp->l4_port), mp->is_add);
1990  if (error)
1991  {
1992  rv = -1;
1993  clib_error_report (error);
1994  }
1995 
1996  REPLY_MACRO (VL_API_PUNT_REPLY);
1997 }
1998 
1999 static void
2001 {
2003  int rv = 0;
2004 
2005  VALIDATE_SW_IF_INDEX (mp);
2006 
2007  u8 *arc_name = format (0, "%s%c", mp->arc_name, 0);
2008  u8 *feature_name = format (0, "%s%c", mp->feature_name, 0);
2009 
2011  vnet_get_feature_reg ((const char *) arc_name,
2012  (const char *) feature_name);
2013  if (reg == 0)
2014  rv = VNET_API_ERROR_INVALID_VALUE;
2015  else
2016  {
2017  u32 sw_if_index = ntohl (mp->sw_if_index);
2018  clib_error_t *error = 0;
2019 
2020  if (reg->enable_disable_cb)
2021  error = reg->enable_disable_cb (sw_if_index, mp->enable);
2022  if (!error)
2023  vnet_feature_enable_disable ((const char *) arc_name,
2024  (const char *) feature_name,
2025  sw_if_index, mp->enable, 0, 0);
2026  else
2027  {
2028  clib_error_report (error);
2029  rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
2030  }
2031  }
2032 
2033  vec_free (feature_name);
2034  vec_free (arc_name);
2035 
2037 
2038  REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
2039 }
2040 
2041 #define BOUNCE_HANDLER(nn) \
2042 static void vl_api_##nn##_t_handler ( \
2043  vl_api_##nn##_t *mp) \
2044 { \
2045  vpe_client_registration_t *reg; \
2046  vpe_api_main_t * vam = &vpe_api_main; \
2047  unix_shared_memory_queue_t * q; \
2048  \
2049  /* One registration only... */ \
2050  pool_foreach(reg, vam->nn##_registrations, \
2051  ({ \
2052  q = vl_api_client_index_to_input_queue (reg->client_index); \
2053  if (q) { \
2054  /* \
2055  * If the queue is stuffed, turf the msg and complain \
2056  * It's unlikely that the intended recipient is \
2057  * alive; avoid deadlock at all costs. \
2058  */ \
2059  if (q->cursize == q->maxsize) { \
2060  clib_warning ("ERROR: receiver queue full, drop msg"); \
2061  vl_msg_api_free (mp); \
2062  return; \
2063  } \
2064  vl_msg_api_send_shmem (q, (u8 *)&mp); \
2065  return; \
2066  } \
2067  })); \
2068  vl_msg_api_free (mp); \
2069 }
2070 
2071 static void setup_message_id_table (api_main_t * am);
2072 
2073 /*
2074  * vpe_api_hookup
2075  * Add vpe's API message handlers to the table.
2076  * vlib has alread mapped shared memory and
2077  * added the client registration handlers.
2078  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
2079  */
2080 static clib_error_t *
2082 {
2083  api_main_t *am = &api_main;
2084 
2085 #define _(N,n) \
2086  vl_msg_api_set_handlers(VL_API_##N, #n, \
2087  vl_api_##n##_t_handler, \
2088  vl_noop_handler, \
2089  vl_api_##n##_t_endian, \
2090  vl_api_##n##_t_print, \
2091  sizeof(vl_api_##n##_t), 1);
2093 #undef _
2094 
2095  /*
2096  * Trace space for classifier mask+match
2097  */
2098  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
2099  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
2100  += 5 * sizeof (u32x4);
2101 
2102  /*
2103  * Thread-safe API messages
2104  */
2105  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
2106  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
2107 
2108  /*
2109  * Set up the (msg_name, crc, message-id) table
2110  */
2112 
2113  return 0;
2114 }
2115 
2117 
2118 static clib_error_t *
2120 {
2122 
2123  am->vlib_main = vm;
2124  am->vnet_main = vnet_get_main ();
2125  am->interface_events_registration_hash = hash_create (0, sizeof (uword));
2126  am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2127  am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2128  am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2129  am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2130  am->oam_events_registration_hash = hash_create (0, sizeof (uword));
2131  am->bfd_events_registration_hash = hash_create (0, sizeof (uword));
2132 
2133  vl_set_memory_region_name ("/vpe-api");
2134  vl_enable_disable_memory_api (vm, 1 /* enable it */ );
2135 
2136  return 0;
2137 }
2138 
2140 
2141 
2142 static clib_error_t *
2144 {
2145  u8 *chroot_path;
2146  u64 baseva, size, pvt_heap_size;
2147  int uid, gid, rv;
2148  const int max_buf_size = 4096;
2149  char *s, *buf;
2150  struct passwd _pw, *pw;
2151  struct group _grp, *grp;
2152  clib_error_t *e;
2153  buf = vec_new (char, 128);
2154  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2155  {
2156  if (unformat (input, "prefix %s", &chroot_path))
2157  {
2158  vec_add1 (chroot_path, 0);
2159  vl_set_memory_root_path ((char *) chroot_path);
2160  }
2161  else if (unformat (input, "uid %d", &uid))
2162  vl_set_memory_uid (uid);
2163  else if (unformat (input, "gid %d", &gid))
2164  vl_set_memory_gid (gid);
2165  else if (unformat (input, "baseva %llx", &baseva))
2166  vl_set_global_memory_baseva (baseva);
2167  else if (unformat (input, "global-size %lldM", &size))
2168  vl_set_global_memory_size (size * (1ULL << 20));
2169  else if (unformat (input, "global-size %lldG", &size))
2170  vl_set_global_memory_size (size * (1ULL << 30));
2171  else if (unformat (input, "global-size %lld", &size))
2173  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
2174  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2175  else if (unformat (input, "global-pvt-heap-size size %lld",
2176  &pvt_heap_size))
2177  vl_set_global_pvt_heap_size (pvt_heap_size);
2178  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
2179  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2180  else if (unformat (input, "api-pvt-heap-size size %lld",
2181  &pvt_heap_size))
2182  vl_set_api_pvt_heap_size (pvt_heap_size);
2183  else if (unformat (input, "api-size %lldM", &size))
2184  vl_set_api_memory_size (size * (1ULL << 20));
2185  else if (unformat (input, "api-size %lldG", &size))
2186  vl_set_api_memory_size (size * (1ULL << 30));
2187  else if (unformat (input, "api-size %lld", &size))
2188  vl_set_api_memory_size (size);
2189  else if (unformat (input, "uid %s", &s))
2190  {
2191  /* lookup the username */
2192  pw = NULL;
2193  while (((rv =
2194  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
2195  && (vec_len (buf) <= max_buf_size))
2196  {
2197  vec_resize (buf, vec_len (buf) * 2);
2198  }
2199  if (rv < 0)
2200  {
2201  e = clib_error_return_code (0, rv,
2204  "cannot fetch username %s", s);
2205  vec_free (s);
2206  vec_free (buf);
2207  return e;
2208  }
2209  if (pw == NULL)
2210  {
2211  e =
2212  clib_error_return_fatal (0, "username %s does not exist", s);
2213  vec_free (s);
2214  vec_free (buf);
2215  return e;
2216  }
2217  vec_free (s);
2218  vl_set_memory_uid (pw->pw_uid);
2219  }
2220  else if (unformat (input, "gid %s", &s))
2221  {
2222  /* lookup the group name */
2223  grp = NULL;
2224  while (((rv =
2225  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
2226  && (vec_len (buf) <= max_buf_size))
2227  {
2228  vec_resize (buf, vec_len (buf) * 2);
2229  }
2230  if (rv != 0)
2231  {
2232  e = clib_error_return_code (0, rv,
2235  "cannot fetch group %s", s);
2236  vec_free (s);
2237  vec_free (buf);
2238  return e;
2239  }
2240  if (grp == NULL)
2241  {
2242  e = clib_error_return_fatal (0, "group %s does not exist", s);
2243  vec_free (s);
2244  vec_free (buf);
2245  return e;
2246  }
2247  vec_free (s);
2248  vec_free (buf);
2249  vl_set_memory_gid (grp->gr_gid);
2250  }
2251  else
2252  return clib_error_return (0, "unknown input `%U'",
2253  format_unformat_error, input);
2254  }
2255  return 0;
2256 }
2257 
2259 
2260 void *
2262 {
2263  return (void *) &unformat_vnet_sw_interface;
2264 }
2265 
2266 static u8 *
2267 format_arp_event (u8 * s, va_list * args)
2268 {
2269  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
2270 
2271  s = format (s, "pid %d: ", event->pid);
2272  if (event->mac_ip)
2273  s = format (s, "bd mac/ip4 binding events");
2274  else
2275  s = format (s, "resolution for %U", format_ip4_address, &event->address);
2276  return s;
2277 }
2278 
2279 static u8 *
2280 format_nd_event (u8 * s, va_list * args)
2281 {
2282  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
2283 
2284  s = format (s, "pid %d: ", event->pid);
2285  if (event->mac_ip)
2286  s = format (s, "bd mac/ip6 binding events");
2287  else
2288  s = format (s, "resolution for %U", format_ip6_address, event->address);
2289  return s;
2290 }
2291 
2292 static clib_error_t *
2294  unformat_input_t * input, vlib_cli_command_t * cmd)
2295 {
2297  vl_api_ip4_arp_event_t *arp_event;
2298  vl_api_ip6_nd_event_t *nd_event;
2299 
2300  if ((pool_elts (am->arp_events) == 0) && (pool_elts (am->nd_events) == 0))
2301  {
2302  vlib_cli_output (vm, "No active arp or nd event registrations");
2303  return 0;
2304  }
2305 
2306  /* *INDENT-OFF* */
2307  pool_foreach (arp_event, am->arp_events,
2308  ({
2309  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
2310  }));
2311 
2312  pool_foreach (nd_event, am->nd_events,
2313  ({
2314  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
2315  }));
2316  /* *INDENT-ON* */
2317 
2318  return 0;
2319 }
2320 
2321 /* *INDENT-OFF* */
2322 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
2323  .path = "show arp-nd-event registrations",
2324  .function = show_ip_arp_nd_events_fn,
2325  .short_help = "Show ip4 arp and ip6 nd event registrations",
2326 };
2327 /* *INDENT-ON* */
2328 
2329 #define vl_msg_name_crc_list
2330 #include <vpp/api/vpe_all_api_h.h>
2331 #undef vl_msg_name_crc_list
2332 
2333 static void
2335 {
2336 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
2337  foreach_vl_msg_name_crc_memclnt;
2338  foreach_vl_msg_name_crc_vpe;
2339 #undef _
2340 }
2341 
2342 
2343 /*
2344  * fd.io coding-style-patch-verification: ON
2345  *
2346  * Local Variables:
2347  * eval: (c-set-style "gnu")
2348  * End:
2349  */
static u32 ip4_fib_lookup(ip4_main_t *im, u32 sw_if_index, ip4_address_t *dst)
Definition: ip4_fib.h:86
u32 sw_if_index
Definition: pg.h:294
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
static void vl_api_create_loopback_t_handler(vl_api_create_loopback_t *mp)
Definition: api.c:1016
static void vl_api_feature_enable_disable_t_handler(vl_api_feature_enable_disable_t *mp)
Definition: api.c:2000
vmrglw vmrglh hi
#define BAD_RX_SW_IF_INDEX_LABEL
Proxy ARP add / del request.
Definition: vpe.api:109
clib_error_t * pg_capture(pg_capture_args_t *a)
Definition: cli.c:81
void mpls_sw_interface_enable_disable(mpls_main_t *mm, u32 sw_if_index, u8 is_enable)
Definition: interface.c:38
static clib_error_t * memclnt_delete_callback(u32 client_index)
Definition: api.c:168
static void vl_api_want_ip4_arp_events_t_handler(vl_api_want_ip4_arp_events_t *mp)
Definition: api.c:1567
#define hash_set(h, key, value)
Definition: hash.h:254
Register for ip6 nd resolution events.
Definition: vpe.api:952
#define VALIDATE_TX_SW_IF_INDEX(mp)
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
vnet_main_t * vnet_main
void vl_enable_disable_memory_api(vlib_main_t *vm, int yesno)
Definition: memory_vlib.c:794
static void vl_api_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:1002
Reset fib table request.
Definition: vpe.api:386
static void svm_pop_heap(void *oldheap)
Definition: svm.h:190
Reply for get next node index.
Definition: vpe.api:1114
static void vl_api_interface_name_renumber_t_handler(vl_api_interface_name_renumber_t *mp)
Definition: api.c:1450
vpe parser cli string response
Definition: vpe.api:526
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:683
static void vl_api_vnet_get_summary_stats_t_handler(vl_api_vnet_get_summary_stats_t *mp)
Definition: api.c:821
#define foreach_vpe_api_msg
Definition: api.c:104
a
Definition: bitmap.h:516
iOAM disable response
Definition: vpe.api:1089
void vl_set_memory_gid(int gid)
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:540
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
iOAM Trace profile add / del response
Definition: vpe.api:1067
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)
Definition: pg.h:310
static int arp_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, u32 address)
Definition: api.c:1467
void vl_set_global_pvt_heap_size(u64 size)
int vnet_set_ip6_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip6_forward.c:3288
vnet_interface_main_t interface_main
Definition: vnet.h:57
Control ping from client to api server request.
Definition: vpe.api:482
int size
Definition: api.h:71
u8 as_u8[16]
Definition: ip6_packet.h:48
OAM event structure.
Definition: vpe.api:322
Fixed length block allocator.
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:55
iOAM disable
Definition: vpe.api:1078
u32 index
Definition: node.h:237
Request for a single block of summary stats.
Definition: vpe.api:296
Set max allowed ARP or ip6 neighbor entries request.
Definition: vpe.api:546
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:185
IP unicast adjacency.
Definition: lookup.h:193
int vnet_add_del_ip6_nd_change_event(vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
uword * stream_index_by_name
Definition: pg.h:319
clib_error_t * ip4_set_arp_limit(u32 arp_limit)
Definition: arp.c:1489
static void vl_api_sw_interface_set_mpls_enable_t_handler(vl_api_sw_interface_set_mpls_enable_t *mp)
Definition: api.c:768
vlib_main_t * vlib_main
Definition: stats.h:57
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:2143
static void vl_api_is_address_reachable_t_handler(vl_api_is_address_reachable_t *mp)
Definition: api.c:691
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1249
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void vl_api_punt_t_handler(vl_api_punt_t *mp)
Definition: api.c:1981
Combined counter to hold both packets and byte differences.
Definition: counter.h:139
struct _vlib_node_registration vlib_node_registration_t
void vnet_l2_input_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
static void vl_api_set_arp_neighbor_limit_t_handler(vl_api_set_arp_neighbor_limit_t *mp)
Definition: api.c:1183
u8 cmd[length]
Definition: vpe.api:518
u32 hw_if_index
Definition: pg.h:366
#define hash_set_mem(h, key, value)
Definition: hash.h:274
ip_lookup_main_t lookup_main
Definition: ip4.h:109
void vl_set_global_memory_baseva(u64 baseva)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:454
vlib_main_t * vlib_main
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
unformat_function_t unformat_vnet_sw_interface
void vl_set_api_pvt_heap_size(u64 size)
Set bridge domain ip to mac entry response.
Definition: vpe.api:694
u8 * vlib_node_serialize(vlib_node_main_t *nm, u8 *vector, u32 max_threads, int include_nexts, int include_stats)
Enable / disable packet generator request.
Definition: vpe.api:1179
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
L2 interface ethernet flow point filtering response.
Definition: vpe.api:824
static void vl_api_proxy_arp_add_del_t_handler(vl_api_proxy_arp_add_del_t *mp)
Definition: api.c:631
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1065
trace_cfg_t * api_trace_cfg
Definition: api.h:140
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: api.c:1427
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Delete sub interface response.
Definition: vpe.api:1279
Adjacency to drop this packet.
Definition: lookup.h:63
Interface bridge mode response.
Definition: vpe.api:664
u32 index
Definition: ip4.h:60
resolve_t
Definition: api.c:154
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:276
OAM add / del target response.
Definition: vpe.api:374
api_main_t api_main
Definition: api_shared.c:35
pub_sub_handler(oam_events, OAM_EVENTS)
u8 pcap_file_name[pcap_name_length]
Definition: vpe.api:1160
PacketGenerator capture packets on given interface request.
Definition: vpe.api:1152
format_function_t format_ip4_address
Definition: format.h:79
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:1347
Get node index using name request.
Definition: vpe.api:773
Proxy ARP add / del request.
Definition: vpe.api:135
#define VNET_SW_INTERFACE_FLAG_PROXY_ARP
Definition: interface.h:541
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
void vl_set_global_memory_size(u64 size)
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
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:526
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:1667
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:182
#define MODE_L2_BRIDGE
Definition: l2_input.h:182
void vl_set_memory_uid(int uid)
vnet_feature_registration_t * vnet_get_feature_reg(const char *arc_name, const char *node_name)
Definition: feature.c:138
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:310
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:626
static uword ip6_address_is_equal(ip6_address_t *a, ip6_address_t *b)
Definition: ip6_packet.h:208
Set interface source and L4 port-range request.
Definition: vpe.api:1242
Reply for the vlan subinterface create request.
Definition: vpe.api:70
unsigned long long u32x4
Definition: ixge.c:28
#define clib_error_return_fatal(e, args...)
Definition: error.h:117
struct _vl_api_ip4_arp_event * arp_events
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
void fib_table_flush(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Flush all entries from a table for the source.
Definition: fib_table.c:1139
#define clib_error_return(e, args...)
Definition: error.h:111
svm_region_t * vlib_rp
Definition: api.h:142
get_node_graph_reply
Definition: vpe.api:1037
unsigned long u64
Definition: types.h:89
Set/unset input ACL interface.
Definition: vpe.api:1002
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
static void vl_api_want_ip6_nd_events_t_handler(vl_api_want_ip6_nd_events_t *mp)
Definition: api.c:1606
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:241
static clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:2119
static int ip6_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:947
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip4_forward.c:3148
uword * bd_index_by_bd_id
Definition: l2_bd.h:27
#define IP6_ND_EVENT
Definition: api.c:196
u8 * pcap_file_name
Definition: pg.h:369
stats_main_t stats_main
Definition: stats.c:24
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:523
clib_error_t * ip6_probe_neighbor(vlib_main_t *vm, ip6_address_t *dst, u32 sw_if_index)
Definition: ip6_forward.c:1807
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1022
Configure IP source and L4 port-range check.
Definition: vpe.api:1211
Interface set vpath response.
Definition: vpe.api:608
uword * hw_interface_by_name
Definition: interface.h:606
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
Definition: ip4_forward.c:2246
vnet_api_error_t api_errno
Definition: vnet.h:77
void dsunlock(stats_main_t *sm)
Definition: stats.c:99
void vl_set_memory_root_path(char *root_path)
static uword resolver_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: api.c:301
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
static void vl_api_pg_enable_disable_t_handler(vl_api_pg_enable_disable_t *mp)
Definition: api.c:1802
Set/unset input ACL interface response.
Definition: vpe.api:1017
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:130
Configure IP source and L4 port-range check reply.
Definition: vpe.api:1229
counter_t packets
packet counter
Definition: counter.h:141
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:1080
Set/unset l2 classification tables for an interface response.
Definition: vpe.api:750
static void vl_api_pg_create_interface_t_handler(vl_api_pg_create_interface_t *mp)
Definition: api.c:1740
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:1323
char * vpe_api_get_version(void)
Definition: version.c:75
static void vl_api_bd_ip_mac_add_del_t_handler(vl_api_bd_ip_mac_add_del_t *mp)
Definition: api.c:442
#define v
Definition: acl.c:246
u32 vlib_combined_counter_n_counters(const vlib_combined_counter_main_t *cm)
The number of counters (not the number of per-thread counters)
Definition: counter.c:100
struct _unformat_input_t unformat_input_t
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: api.c:408
Set/unset l2 classification tables for an interface request.
Definition: vpe.api:734
void send_oam_event(oam_target_t *t)
Definition: api.c:783
static u8 * format_nd_event(u8 *s, va_list *args)
Definition: api.c:2280
Set bridge domain ip to mac entry request.
Definition: vpe.api:679
u8 stream_name[stream_name_length]
Definition: vpe.api:1185
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:620
Reply to the eature path enable/disable request.
Definition: vpe.api:1330
static void vl_api_pg_capture_t_handler(vl_api_pg_capture_t *mp)
Definition: api.c:1758
#define REPLY_MACRO(t)
#define BAD_TX_SW_IF_INDEX_LABEL
Create loopback interface instance response.
Definition: vpe.api:449
u32 index
Definition: ip6.h:73
u32 pg_interface_add_or_get(pg_main_t *pg, uword stream_index)
Definition: stream.c:182
u8 l4_protocol
Definition: vpe.api:1297
clib_error_t * vnet_punt_add_del(vlib_main_t *vm, u8 ipv, u8 protocol, u16 port, int is_add)
Request IP traffic punt to the local TCP/IP stack.
Definition: punt.c:219
Tell client about an ip4 arp resolution event.
Definition: vpe.api:934
static void vl_api_classify_set_interface_ip_table_t_handler(vl_api_classify_set_interface_ip_table_t *mp)
Definition: api.c:1211
Enable or Disable MPLS on and interface.
Definition: vpe.api:83
Set/unset interface classification table response.
Definition: vpe.api:720
IOAM enable : Enable in-band OAM.
Definition: vpe.api:1051
#define REPLY_MACRO3(t, n, body)
struct _vl_api_ip6_nd_event * nd_events
IP Set the next node for a given node response.
Definition: vpe.api:799
Get node index using name request.
Definition: vpe.api:761
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1030
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address, u8 is_specified, u32 user_instance)
Definition: interface.c:530
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:1394
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:465
#define BAD_SW_IF_INDEX_LABEL
Delete loopback interface response.
Definition: vpe.api:472
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:140
PacketGenerator create interface request.
Definition: vpe.api:1126
static int nd_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, ip6_address_t *address)
Definition: api.c:1504
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
void * vl_msg_api_alloc(int nbytes)
Reply for Proxy ARP interface enable / disable request.
Definition: vpe.api:148
Reply for interface events registration.
Definition: vpe.api:919
mpls_main_t mpls_main
Definition: mpls.c:25
format_function_t format_ip6_address
Definition: format.h:95
static void vl_api_proxy_arp_intfc_enable_disable_t_handler(vl_api_proxy_arp_intfc_enable_disable_t *mp)
Definition: api.c:666
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:250
vlib_main_t * vm
Definition: buffer.c:276
L2 interface patch add / del response.
Definition: vpe.api:584
int vnet_delete_sub_interface(u32 sw_if_index)
Definition: interface.c:709
static vlib_node_registration_t vpe_resolver_process_node
(constructor) VLIB_REGISTER_NODE (vpe_resolver_process_node)
Definition: api.c:160
u32 bd_add_del_ip_mac(u32 bd_index, u8 *ip_addr, u8 *mac_addr, u8 is_ip6, u8 is_add)
Add/delete IP address to MAC address mapping.
Definition: l2_bd.c:697
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:682
Definition: ip6.h:67
static void vl_api_ioam_disable_t_handler(vl_api_ioam_disable_t *mp)
Definition: api.c:1723
Set/unset the classification table for an interface request.
Definition: vpe.api:707
Definition: ip4.h:48
#define clib_warning(format, args...)
Definition: error.h:59
char * vpe_api_get_build_directory(void)
Definition: version.c:69
#define clib_memcpy(a, b, c)
Definition: string.h:69
Feature path enable/disable request.
Definition: vpe.api:1317
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:1143
clib_error_t * ip6_ioam_enable(int has_trace_option, int has_pot_option, int has_seqno_option, int has_analyse_option)
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:1294
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:651
Definitions for punt infrastructure.
int vnet_l2_input_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface input classification tables.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:238
Delete sub interface request.
Definition: vpe.api:1269
#define ARRAY_LEN(x)
Definition: clib.h:59
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
static void vl_api_cli_request_t_handler(vl_api_cli_request_t *mp)
Definition: api.c:1107
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: lookup.h:73
#define VALIDATE_RX_SW_IF_INDEX(mp)
PacketGenerator capture packets response.
Definition: vpe.api:1167
int vnet_proxy_arp_add_del(ip4_address_t *lo_addr, ip4_address_t *hi_addr, u32 fib_index, int is_del)
Definition: arp.c:1865
Delete loopback interface request.
Definition: vpe.api:461
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: api.c:353
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
Set L2 XConnect between two interfaces request.
Definition: vpe.api:621
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:643
#define hash_create(elts, value_bytes)
Definition: hash.h:658
Reset fib response.
Definition: vpe.api:398
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:536
Set L2 XConnect response.
Definition: vpe.api:634
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:255
#define ASSERT(truth)
Reply for vnet_get_summary_stats request.
Definition: vpe.api:309
static void vl_api_ip_source_and_port_range_check_interface_add_del_t_handler(vl_api_ip_source_and_port_range_check_interface_add_del_t *mp)
Definition: api.c:1916
static uword ip6_address_is_zero(ip6_address_t *a)
Definition: ip6_packet.h:266
static clib_error_t * show_ip_arp_nd_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: api.c:2293
unsigned int u32
Definition: types.h:88
static void vl_api_classify_set_interface_l2_tables_t_handler(vl_api_classify_set_interface_l2_tables_t *mp)
Definition: api.c:1233
int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:1155
ip6_main_t ip6_main
Definition: ip6_forward.c:2846
Reply for enable / disable packet generator.
Definition: vpe.api:1192
ip_lookup_main_t lookup_main
Definition: ip6.h:151
#define RESOLUTION_EVENT
Definition: api.c:193
static void setup_message_id_table(api_main_t *am)
Definition: api.c:2334
int vpe_oam_add_del_target(ip4_address_t *src_address, ip4_address_t *dst_address, u32 fib_id, int is_add)
Definition: oam.c:60
void pg_enable_disable(u32 stream_index, int is_enable)
Definition: cli.c:58
IPv4 main type.
Definition: ip4.h:107
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:1287
u64 size
Definition: vhost-user.h:77
u16 l4_port
Definition: vpe.api:1298
Reply for proxy arp add / del request.
Definition: vpe.api:123
Control ping from the client to the server response.
Definition: vpe.api:494
static void vl_api_create_vlan_subif_t_handler(vl_api_create_vlan_subif_t *mp)
Definition: api.c:468
Bitmaps built as vectors of machine words.
Set the next node for a given node request.
Definition: vpe.api:786
uword * next_slot_by_node
Definition: node.h:302
void handle_ip6_nd_event(u32 pool_index)
Definition: api.c:252
#define clib_error_report(e)
Definition: error.h:125
Query relative index via node names.
Definition: vpe.api:1101
Is Address Reachable request - DISABLED.
Definition: vpe.api:186
show version
Definition: vpe.api:861
Set max allowed ARP or ip6 neighbor entries response.
Definition: vpe.api:558
From the control plane API.
Definition: fib_entry.h:58
void l2_efp_filter_configure(vnet_main_t *vnet_main, u32 sw_if_index, u32 enable)
Enable/disable the EFP Filter check on the subinterface.
OAM add / del target request.
Definition: vpe.api:360
static void * clib_mem_alloc(uword size)
Definition: mem.h:109
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
#define MODE_L2_XC
Definition: l2_input.h:183
static void vl_api_delete_subif_t_handler(vl_api_delete_subif_t *mp)
Definition: api.c:1970
static void vl_api_ioam_enable_t_handler(vl_api_ioam_enable_t *mp)
Definition: api.c:1703
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u64 uword
Definition: types.h:112
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: api.c:1279
u32 l2input_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:482
void vl_set_memory_region_name(char *name)
Definition: memory_vlib.c:1205
void dslock(stats_main_t *sm, int release_hint, int tag)
Definition: stats.c:66
template key/value backing page structure
Definition: bihash_doc.h:44
Add / del route request.
Definition: ip.api:425
counter_t bytes
byte counter
Definition: counter.h:142
static void vl_api_create_loopback_instance_t_handler(vl_api_create_loopback_instance_t *mp)
Definition: api.c:1033
Interface bridge mode request.
Definition: vpe.api:649
Definition: defs.h:47
void handle_ip4_arp_event(u32 pool_index)
Definition: api.c:203
unsigned short u16
Definition: types.h:57
Create loopback interface instance request.
Definition: vpe.api:435
u64 reply_in_shmem
Definition: vpe.api:530
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.c:68
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
vnet_interface_main_t * interface_main
Definition: stats.h:59
unsigned char u8
Definition: types.h:56
ip_lookup_next_t lookup_next_index
Definition: lookup.h:204
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: api.c:378
vlib_node_main_t node_main
Definition: main.h:115
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:2261
Process a vpe parser cli string request.
Definition: vpe.api:507
static void vl_api_create_subif_t_handler(vl_api_create_subif_t *mp)
Definition: api.c:548
L2 interface ethernet flow point filtering enable/disable request.
Definition: vpe.api:812
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:2267
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:247
PacketGenerator create interface response.
Definition: vpe.api:1137
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
Create loopback interface request.
Definition: vpe.api:409
#define clib_error_get_code(err)
Definition: error.h:89
show version response
Definition: vpe.api:874
int ip4_source_and_port_range_check_add_del(ip4_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
static void vl_api_delete_loopback_t_handler(vl_api_delete_loopback_t *mp)
Definition: api.c:1053
A collection of combined counters.
Definition: counter.h:180
vpe_api_main_t vpe_api_main
Definition: api.c:161
Create a new subinterface with the given vlan id.
Definition: vpe.api:57
Create loopback interface response.
Definition: vpe.api:421
u32 dev_instance
Definition: pg.h:367
L2 interface patch add / del request.
Definition: vpe.api:571
#define hash_get_mem(h, key)
Definition: hash.h:268
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:1066
Tell client about an ip6 nd resolution or mac/ip event.
Definition: vpe.api:980
struct clib_bihash_value offset
template key/value backing page structure
Interface set vpath request.
Definition: vpe.api:596
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
char * vpe_api_get_build_date(void)
Definition: version.c:81
Segment Routing data structures definitions.
u8 * is_mp_safe
Definition: api.h:132
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1117
static void vl_api_input_acl_set_interface_t_handler(vl_api_input_acl_set_interface_t *mp)
Definition: api.c:1645
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:105
Register for ip4 arp resolution events.
Definition: vpe.api:906
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:112
pg_main_t pg_main
Definition: init.c:44
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:83
u8 is_enabled
Definition: pg.h:368
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * clear_ioam_rewrite_fn(void)
Reply for ip6 nd resolution events registration.
Definition: vpe.api:965
int vnet_set_input_acl_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
Definition: input_acl.c:59
static int nd_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:1555
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:538
#define IP4_ARP_EVENT
Definition: api.c:195
static void vl_api_oam_add_del_t_handler(vl_api_oam_add_del_t *mp)
Definition: api.c:808
vhost_vring_addr_t addr
Definition: vhost-user.h:84
Set interface source and L4 port-range response.
Definition: vpe.api:1258
static void vl_api_ip_source_and_port_range_check_add_del_t_handler(vl_api_ip_source_and_port_range_check_add_del_t *mp)
Definition: api.c:1830
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:590
static int arp_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:1543
u32 flags
Definition: vhost-user.h:78
Reply for MPLS state on an interface.
Definition: vpe.api:95
bd_main_t bd_main
Definition: l2_bd.c:44
int ip6_source_and_port_range_check_add_del(ip6_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
static uword vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
#define RESOLUTION_PENDING_EVENT
Definition: api.c:194
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:2081
void vl_set_api_memory_size(u64 size)
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;})
Definition: api.c:872
struct fib_table_t_ * fibs
Definition: ip6.h:154
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:577
Reply to the punt request.
Definition: vpe.api:1305
int vnet_add_del_ip4_arp_change_event(vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
Definition: arp.c:695
Punt traffic to the host.
Definition: vpe.api:1292
pg_interface_t * interfaces
Definition: pg.h:322
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971
#define foreach_registration_hash
Definition: defs.h:46
pthread_mutex_t mutex
Definition: svm.h:42
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:225
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:377
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
Definition: fib_table.h:29
struct _vnet_feature_registration vnet_feature_registration_t
feature registration object
#define MODE_L3
Definition: l2_input.h:181
struct _unix_shared_memory_queue unix_shared_memory_queue_t
clib_error_t * ip6_set_neighbor_limit(u32 neighbor_limit)
int set_ip_source_and_port_range_check(vlib_main_t *vm, u32 *fib_index, u32 sw_if_index, u32 is_add)
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109