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