FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ping.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stddef.h>
17 
18 #include <vlib/vlib.h>
19 #include <vlib/unix/unix.h>
20 #include <vnet/fib/ip6_fib.h>
21 #include <vnet/fib/ip4_fib.h>
22 #include <vnet/fib/fib_sas.h>
23 #include <vnet/ip/ip6_link.h>
24 #include <vnet/plugin/plugin.h>
25 #include <vpp/app/version.h>
26 
27 #include <vnet/ip/icmp4.h>
28 #include <ping/ping.h>
29 
31 
32 /**
33  * @file
34  * @brief IPv4 and IPv6 ICMP Ping.
35  *
36  * This file contains code to support IPv4 or IPv6 ICMP ECHO_REQUEST to
37  * network hosts.
38  *
39  */
40 
41 typedef struct
42 {
48 
49 
50 u8 *
51 format_icmp_echo_trace (u8 * s, va_list * va)
52 {
53  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
54  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
55  icmp_echo_trace_t *t = va_arg (*va, icmp_echo_trace_t *);
56 
57  s =
58  format (s, "ICMP%s echo id %d seq %d", t->is_ip6 ? "6" : "4", t->id,
59  t->seq);
61  {
62  s = format (s, " (unknown)");
63  }
64  else
65  {
66  s = format (s, " send to cli node %d", t->cli_process_node);
67  }
68 
69  return s;
70 }
71 
72 
73 static u8 *
74 format_ip46_ping_result (u8 * s, va_list * args)
75 {
77 
78  switch (res)
79  {
80 #define _(v, n) case SEND_PING_##v: s = format(s, "%s", n);break;
82 #undef _
83  }
84 
85  return (s);
86 }
87 
88 
89 /*
90  * Poor man's get-set-clear functions
91  * for manipulation of icmp_id -> cli_process_id
92  * mappings.
93  *
94  * There should normally be very few (0..1..2) of these
95  * mappings, so the linear search is a good strategy.
96  *
97  * Make them thread-safe via a simple spinlock.
98  *
99  */
100 
101 
104 {
105  ping_main_t *pm = &ping_main;
106  uword cli_process_id = PING_CLI_UNKNOWN_NODE;
107  ping_run_t *pr;
108 
110  vec_foreach (pr, pm->active_ping_runs)
111  {
112  if (pr->icmp_id == icmp_id)
113  {
114  cli_process_id = pr->cli_process_id;
115  break;
116  }
117  }
119  return cli_process_id;
120 }
121 
122 
125  uword cli_process_id)
126 {
127  ping_main_t *pm = &ping_main;
128  ping_run_t *pr;
129 
131  vec_foreach (pr, pm->active_ping_runs)
132  {
133  if (pr->icmp_id == icmp_id)
134  {
135  pr->cli_process_id = cli_process_id;
136  goto have_found_and_set;
137  }
138  }
139  /* no such key yet - add a new one */
140  ping_run_t new_pr = {.icmp_id = icmp_id,.cli_process_id = cli_process_id };
141  vec_add1 (pm->active_ping_runs, new_pr);
142 have_found_and_set:
144 }
145 
146 
149 {
150  ping_main_t *pm = &ping_main;
151  ping_run_t *pr;
152 
154  vec_foreach (pr, pm->active_ping_runs)
155  {
156  if (pr->icmp_id == icmp_id)
157  {
159  break;
160  }
161  }
163 }
164 
167  u16 * out_icmp_id, u16 * out_icmp_seq, int is_ip6)
168 {
169  int l4_offset;
170  if (is_ip6)
171  {
173  if (ip6->protocol != IP_PROTOCOL_ICMP6)
174  {
175  return 0;
176  }
177  l4_offset = sizeof (*ip6); // IPv6 EH
178  }
179  else
180  {
182  l4_offset = ip4_header_bytes (ip4);
183 
184  }
185  icmp46_header_t *icmp46 = vlib_buffer_get_current (b0) + l4_offset;
186  icmp46_echo_request_t *icmp46_echo = (icmp46_echo_request_t *) (icmp46 + 1);
187 
188  *out_icmp_id = clib_net_to_host_u16 (icmp46_echo->id);
189  *out_icmp_seq = clib_net_to_host_u16 (icmp46_echo->seq);
190  return 1;
191 }
192 
193 /*
194  * post the buffer to a given cli process node - the caller should forget bi0 after return.
195  */
196 
199  int is_ip6)
200 {
201  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
202  u64 nowts = clib_cpu_time_now ();
203 
204  /* Pass the timestamp to the cli_process thanks to the vnet_buffer unused metadata field */
205 
206  /* Camping on unused data... just ensure statically that there is enough space */
207  STATIC_ASSERT (ARRAY_LEN (vnet_buffer (b0)->unused) *
208  sizeof (vnet_buffer (b0)->unused[0]) > sizeof (nowts),
209  "ping reply timestamp fits within remaining space of vnet_buffer unused data");
210  u64 *pnowts = (void *) &vnet_buffer (b0)->unused[0];
211  *pnowts = nowts;
212 
214  vlib_process_signal_event_mt (vm, cli_process_id, event_id, bi0);
215 }
216 
217 
221  uword cli_process_id, u16 id, u16 seq,
222  vlib_buffer_t * b0, int is_ip6)
223 {
224  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
225  {
226  icmp_echo_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
227  tr->id = id;
228  tr->seq = seq;
229  tr->cli_process_node = cli_process_id;
230  tr->is_ip6 = is_ip6;
231  }
232 }
233 
234 
238  vlib_frame_t * frame, int do_trace,
239  int is_ip6)
240 {
241  u32 n_left_from, *from, *to_next;
243 
245  n_left_from = frame->n_vectors;
246 
247  next_index = node->cached_next_index;
248 
249  while (n_left_from > 0)
250  {
251  u32 n_left_to_next;
252  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
253 
254  while (n_left_from > 0 && n_left_to_next > 0)
255  {
256  u32 bi0;
257  vlib_buffer_t *b0;
258  /*
259  * The buffers (replies) are either posted to the CLI thread
260  * awaiting for them for subsequent analysis and disposal,
261  * or are sent to the punt node.
262  *
263  * So the only "next" node is a punt, normally.
264  */
266 
267  bi0 = from[0];
268  b0 = vlib_get_buffer (vm, bi0);
269  from += 1;
270  n_left_from -= 1;
271 
272  u16 icmp_id = ~0;
273  u16 icmp_seq = ~0;
274  uword cli_process_id = PING_CLI_UNKNOWN_NODE;
275 
276  if (ip46_get_icmp_id_and_seq (vm, b0, &icmp_id, &icmp_seq, is_ip6))
277  {
278  cli_process_id = get_cli_process_id_by_icmp_id_mt (vm, icmp_id);
279  }
280 
281  if (do_trace)
282  ip46_echo_reply_maybe_trace_buffer (vm, node, cli_process_id,
283  icmp_id, icmp_seq, b0,
284  is_ip6);
285 
286  if (~0 == cli_process_id)
287  {
288  /* no outstanding requests for this reply, punt */
289  /* speculatively enqueue b0 to the current next frame */
290  to_next[0] = bi0;
291  to_next += 1;
292  n_left_to_next -= 1;
293  /* verify speculative enqueue, maybe switch current next frame */
295  to_next, n_left_to_next,
296  bi0, next0);
297  }
298  else
299  {
300  /* Post the buffer to CLI thread. It will take care of freeing it. */
301  ip46_post_icmp_reply_event (vm, cli_process_id, bi0, is_ip6);
302  }
303  }
304  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
305  }
306  return frame->n_vectors;
307 }
308 
309 /*
310  * select "with-trace" or "without-trace" codepaths upfront.
311  */
315  vlib_frame_t * frame, int is_ip6)
316 {
317  if (node->flags & VLIB_NODE_FLAG_TRACE)
319  1 /* do_trace */ , is_ip6);
320  else
322  0 /* do_trace */ , is_ip6);
323 }
324 
325 static uword
328 {
330  0 /* is_ip6 */ );
331 }
332 
333 static uword
336 {
338  1 /* is_ip6 */ );
339 }
340 
341 /* *INDENT-OFF* */
343 {
344  .function = ip6_icmp_echo_reply_node_fn,
345  .name = "ip6-icmp-echo-reply",
346  .vector_size = sizeof (u32),
347  .format_trace = format_icmp_echo_trace,
348  .n_next_nodes = ICMP46_ECHO_REPLY_N_NEXT,
349  .next_nodes = {
350  [ICMP46_ECHO_REPLY_NEXT_DROP] = "ip6-drop",
351  [ICMP46_ECHO_REPLY_NEXT_PUNT] = "ip6-punt",
352  },
353 };
354 
356 {
357  .function = ip4_icmp_echo_reply_node_fn,
358  .name = "ip4-icmp-echo-reply",
359  .vector_size = sizeof (u32),
360  .format_trace = format_icmp_echo_trace,
361  .n_next_nodes = ICMP46_ECHO_REPLY_N_NEXT,
362  .next_nodes = {
363  [ICMP46_ECHO_REPLY_NEXT_DROP] = "ip4-drop",
364  [ICMP46_ECHO_REPLY_NEXT_PUNT] = "ip4-punt",
365  },
366 };
367 /* *INDENT-ON* */
368 
369 static uword
372 {
373  uword n_packets = frame->n_vectors;
374  u32 *from, *to_next;
375  u32 n_left_from, n_left_to_next, next;
376  ip4_main_t *i4m = &ip4_main;
377  u16 *fragment_ids, *fid;
378  u8 host_config_ttl = i4m->host_config.ttl;
379 
381  n_left_from = n_packets;
382  next = node->cached_next_index;
383 
384  if (node->flags & VLIB_NODE_FLAG_TRACE)
386  /* stride */ 1,
387  sizeof (icmp_input_trace_t));
388 
389  /* Get random fragment IDs for replies. */
390  fid = fragment_ids = clib_random_buffer_get_data (&vm->random_buffer,
391  n_packets *
392  sizeof (fragment_ids[0]));
393 
394  while (n_left_from > 0)
395  {
396  vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
397 
398  while (n_left_from > 2 && n_left_to_next > 2)
399  {
400  vlib_buffer_t *p0, *p1;
401  ip4_header_t *ip0, *ip1;
402  icmp46_header_t *icmp0, *icmp1;
403  u32 bi0, src0, dst0;
404  u32 bi1, src1, dst1;
405  ip_csum_t sum0, sum1;
406 
407  bi0 = to_next[0] = from[0];
408  bi1 = to_next[1] = from[1];
409 
410  from += 2;
411  n_left_from -= 2;
412  to_next += 2;
413  n_left_to_next -= 2;
414 
415  p0 = vlib_get_buffer (vm, bi0);
416  p1 = vlib_get_buffer (vm, bi1);
417  ip0 = vlib_buffer_get_current (p0);
418  ip1 = vlib_buffer_get_current (p1);
419  icmp0 = ip4_next_header (ip0);
420  icmp1 = ip4_next_header (ip1);
421 
422  vnet_buffer (p0)->sw_if_index[VLIB_RX] =
424  vnet_buffer (p1)->sw_if_index[VLIB_RX] =
426 
427  /* Update ICMP checksum. */
428  sum0 = icmp0->checksum;
429  sum1 = icmp1->checksum;
430 
431  ASSERT (icmp0->type == ICMP4_echo_request);
432  ASSERT (icmp1->type == ICMP4_echo_request);
433  sum0 = ip_csum_update (sum0, ICMP4_echo_request, ICMP4_echo_reply,
434  icmp46_header_t, type);
435  sum1 = ip_csum_update (sum1, ICMP4_echo_request, ICMP4_echo_reply,
436  icmp46_header_t, type);
437  icmp0->type = ICMP4_echo_reply;
438  icmp1->type = ICMP4_echo_reply;
439 
440  icmp0->checksum = ip_csum_fold (sum0);
441  icmp1->checksum = ip_csum_fold (sum1);
442 
443  src0 = ip0->src_address.data_u32;
444  src1 = ip1->src_address.data_u32;
445  dst0 = ip0->dst_address.data_u32;
446  dst1 = ip1->dst_address.data_u32;
447 
448  /* Swap source and destination address.
449  Does not change checksum. */
450  ip0->src_address.data_u32 = dst0;
451  ip1->src_address.data_u32 = dst1;
452  ip0->dst_address.data_u32 = src0;
453  ip1->dst_address.data_u32 = src1;
454 
455  /* Update IP checksum. */
456  sum0 = ip0->checksum;
457  sum1 = ip1->checksum;
458 
459  sum0 = ip_csum_update (sum0, ip0->ttl, host_config_ttl,
460  ip4_header_t, ttl);
461  sum1 = ip_csum_update (sum1, ip1->ttl, host_config_ttl,
462  ip4_header_t, ttl);
463  ip0->ttl = host_config_ttl;
464  ip1->ttl = host_config_ttl;
465 
466  /* New fragment id. */
467  sum0 = ip_csum_update (sum0, ip0->fragment_id, fid[0],
468  ip4_header_t, fragment_id);
469  sum1 = ip_csum_update (sum1, ip1->fragment_id, fid[1],
470  ip4_header_t, fragment_id);
471  ip0->fragment_id = fid[0];
472  ip1->fragment_id = fid[1];
473  fid += 2;
474 
475  ip0->checksum = ip_csum_fold (sum0);
476  ip1->checksum = ip_csum_fold (sum1);
477 
480 
481  p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
482  p1->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
483  }
484 
485  while (n_left_from > 0 && n_left_to_next > 0)
486  {
487  vlib_buffer_t *p0;
488  ip4_header_t *ip0;
489  icmp46_header_t *icmp0;
490  u32 bi0, src0, dst0;
491  ip_csum_t sum0;
492 
493  bi0 = to_next[0] = from[0];
494 
495  from += 1;
496  n_left_from -= 1;
497  to_next += 1;
498  n_left_to_next -= 1;
499 
500  p0 = vlib_get_buffer (vm, bi0);
501  ip0 = vlib_buffer_get_current (p0);
502  icmp0 = ip4_next_header (ip0);
503 
504  vnet_buffer (p0)->sw_if_index[VLIB_RX] =
506 
507  /* Update ICMP checksum. */
508  sum0 = icmp0->checksum;
509 
510  ASSERT (icmp0->type == ICMP4_echo_request);
511  sum0 = ip_csum_update (sum0, ICMP4_echo_request, ICMP4_echo_reply,
512  icmp46_header_t, type);
513  icmp0->type = ICMP4_echo_reply;
514  icmp0->checksum = ip_csum_fold (sum0);
515 
516  src0 = ip0->src_address.data_u32;
517  dst0 = ip0->dst_address.data_u32;
518  ip0->src_address.data_u32 = dst0;
519  ip0->dst_address.data_u32 = src0;
520 
521  /* Update IP checksum. */
522  sum0 = ip0->checksum;
523 
524  sum0 = ip_csum_update (sum0, ip0->ttl, host_config_ttl,
525  ip4_header_t, ttl);
526  ip0->ttl = host_config_ttl;
527 
528  sum0 = ip_csum_update (sum0, ip0->fragment_id, fid[0],
529  ip4_header_t, fragment_id);
530  ip0->fragment_id = fid[0];
531  fid += 1;
532 
533  ip0->checksum = ip_csum_fold (sum0);
534 
536 
537  p0->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
538  }
539 
540  vlib_put_next_frame (vm, node, next, n_left_to_next);
541  }
542 
544  ICMP4_ERROR_ECHO_REPLIES_SENT, frame->n_vectors);
545 
546  return frame->n_vectors;
547 }
548 
549 static u8 *
550 format_icmp_input_trace (u8 * s, va_list * va)
551 {
552  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
553  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
554  icmp_input_trace_t *t = va_arg (*va, icmp_input_trace_t *);
555 
556  s = format (s, "%U",
557  format_ip4_header, t->packet_data, sizeof (t->packet_data));
558 
559  return s;
560 }
561 
562 /* *INDENT-OFF* */
564  .function = ip4_icmp_echo_request,
565  .name = "ip4-icmp-echo-request",
566 
567  .vector_size = sizeof (u32),
568 
569  .format_trace = format_icmp_input_trace,
570 
571  .n_next_nodes = 1,
572  .next_nodes = {
573  [0] = "ip4-load-balance",
574  },
575 };
576 /* *INDENT-ON* */
577 
578 /*
579  * A swarm of address-family agnostic helper functions
580  * for building and sending the ICMP echo request.
581  *
582  * Deliberately mostly "static" rather than "static inline"
583  * so one can trace them sanely if needed in debugger, if needed.
584  *
585  */
586 
589 {
590  return (offset % 256);
591 }
592 
593 /* Fill in the ICMP ECHO structure, return the safety-checked and possibly shrunk data_len */
594 static u16
596  int l4_header_offset,
597  icmp46_echo_request_t * icmp46_echo, u16 seq_host,
598  u16 id_host, u64 now, u16 data_len)
599 {
600  int i;
601 
602 
603  int l34_len =
604  l4_header_offset + sizeof (icmp46_header_t) +
605  offsetof (icmp46_echo_request_t, data);
606  int max_data_len = vlib_buffer_get_default_data_size (vm) - l34_len;
607 
608  int first_buf_data_len = data_len < max_data_len ? data_len : max_data_len;
609 
610  int payload_offset = 0;
611  for (i = 0; i < first_buf_data_len; i++)
612  icmp46_echo->data[i] = get_icmp_echo_payload_byte (payload_offset++);
613 
614  /* inspired by vlib_buffer_add_data */
615  vlib_buffer_t *hb = b0;
616  int remaining_data_len = data_len - first_buf_data_len;
617  while (remaining_data_len)
618  {
619  int this_buf_data_len =
620  remaining_data_len <
621  vlib_buffer_get_default_data_size (vm) ? remaining_data_len :
623  int n_alloc = vlib_buffer_alloc (vm, &b0->next_buffer, 1);
624  if (n_alloc < 1)
625  {
626  /* That is how much we have so far - return it... */
627  return (data_len - remaining_data_len);
628  }
629  b0->flags |= VLIB_BUFFER_NEXT_PRESENT;
630  /* move on to the newly acquired buffer */
631  b0 = vlib_get_buffer (vm, b0->next_buffer);
632  /* initialize the data */
633  for (i = 0; i < this_buf_data_len; i++)
634  {
635  b0->data[i] = get_icmp_echo_payload_byte (payload_offset++);
636  }
637  b0->current_length = this_buf_data_len;
638  b0->current_data = 0;
639  remaining_data_len -= this_buf_data_len;
640  }
641  hb->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
642  hb->current_length = l34_len + first_buf_data_len;
643  hb->total_length_not_including_first_buffer = data_len - first_buf_data_len;
644 
645  icmp46_echo->time_sent = now;
646  icmp46_echo->seq = clib_host_to_net_u16 (seq_host);
647  icmp46_echo->id = clib_host_to_net_u16 (id_host);
648  return data_len;
649 }
650 
651 
652 static u32
654 {
655  u32 fib_index = is_ip6 ?
658  return fib_index;
659 }
660 
661 static fib_node_index_t
662 ip46_fib_table_lookup_host (u32 fib_index, ip46_address_t * pa46, int is_ip6)
663 {
664  fib_node_index_t fib_entry_index = is_ip6 ?
665  ip6_fib_table_lookup (fib_index, &pa46->ip6, 128) :
666  ip4_fib_table_lookup (ip4_fib_get (fib_index), &pa46->ip4, 32);
667  return fib_entry_index;
668 }
669 
670 static u32
671 ip46_get_resolving_interface (u32 fib_index, ip46_address_t * pa46,
672  int is_ip6)
673 {
674  u32 sw_if_index = ~0;
675  if (~0 != fib_index)
676  {
677  fib_node_index_t fib_entry_index;
678  fib_entry_index = ip46_fib_table_lookup_host (fib_index, pa46, is_ip6);
680  }
681  return sw_if_index;
682 }
683 
684 static u32
686 {
687  u32 fib_table_index = is_ip6 ?
690  return fib_table_index;
691 
692 }
693 
694 
695 static int
696 ip46_fill_l3_header (ip46_address_t * pa46, vlib_buffer_t * b0, int is_ip6)
697 {
698  if (is_ip6)
699  {
701  /* Fill in ip6 header fields */
702  ip6->ip_version_traffic_class_and_flow_label =
703  clib_host_to_net_u32 (0x6 << 28);
704  ip6->payload_length = 0; /* will be set later */
705  ip6->protocol = IP_PROTOCOL_ICMP6;
706  ip6->hop_limit = 255;
707  ip6->dst_address = pa46->ip6;
708  ip6->src_address = pa46->ip6;
709  return (sizeof (ip6_header_t));
710  }
711  else
712  {
714  /* Fill in ip4 header fields */
715  ip4->checksum = 0;
716  ip4->ip_version_and_header_length = 0x45;
717  ip4->tos = 0;
718  ip4->length = 0; /* will be set later */
719  ip4->fragment_id = 0;
720  ip4->flags_and_fragment_offset = 0;
721  ip4->ttl = 0xff;
722  ip4->protocol = IP_PROTOCOL_ICMP;
723  ip4->src_address = pa46->ip4;
724  ip4->dst_address = pa46->ip4;
725  return (sizeof (ip4_header_t));
726  }
727 }
728 
729 static bool
731 {
732  bool res = false;
733 
734  if (is_ip6)
735  {
737 
738  res = fib_sas6_get (sw_if_index, &ip6->dst_address, &ip6->src_address);
739  }
740  else
741  {
743 
744  res = fib_sas4_get (sw_if_index, &ip4->dst_address, &ip4->src_address);
745  }
746  return res;
747 }
748 
749 static void
751  int is_ip6)
752 {
753  void *format_addr_func;
754  void *paddr;
755  if (is_ip6)
756  {
758  format_addr_func = format_ip6_address;
759  paddr = &ip6->src_address;
760  }
761  else
762  {
764  format_addr_func = format_ip4_address;
765  paddr = &ip4->src_address;
766  }
767  vlib_cli_output (vm, "Source address: %U ", format_addr_func, paddr);
768 }
769 
770 static u16
771 ip46_fill_icmp_request_at (vlib_main_t * vm, int l4_offset, u16 seq_host,
772  u16 id_host, u16 data_len, vlib_buffer_t * b0,
773  int is_ip6)
774 {
775  icmp46_header_t *icmp46 = vlib_buffer_get_current (b0) + l4_offset;
776 
777  icmp46->type = is_ip6 ? ICMP6_echo_request : ICMP4_echo_request;
778  icmp46->code = 0;
779  icmp46->checksum = 0;
780 
781  icmp46_echo_request_t *icmp46_echo = (icmp46_echo_request_t *) (icmp46 + 1);
782 
783  data_len =
784  init_icmp46_echo_request (vm, b0, l4_offset, icmp46_echo, seq_host,
785  id_host, clib_cpu_time_now (), data_len);
786  return data_len;
787 }
788 
789 
790 /* Compute ICMP4 checksum with multibuffer support. */
791 u16
793  ip4_header_t * ip0)
794 {
795  ip_csum_t sum0;
796  u32 ip_header_length, payload_length_host_byte_order;
797  u32 n_this_buffer, n_bytes_left, n_ip_bytes_this_buffer;
798  u16 sum16;
799  void *data_this_buffer;
800 
801  ip_header_length = ip4_header_bytes (ip0);
802  payload_length_host_byte_order =
803  clib_net_to_host_u16 (ip0->length) - ip_header_length;
804 
805  /* ICMP4 checksum does not include the IP header */
806  sum0 = 0;
807 
808  n_bytes_left = n_this_buffer = payload_length_host_byte_order;
809  data_this_buffer = (void *) ip0 + ip_header_length;
810  n_ip_bytes_this_buffer =
811  p0->current_length - (((u8 *) ip0 - p0->data) - p0->current_data);
812  if (n_this_buffer + ip_header_length > n_ip_bytes_this_buffer)
813  {
814  n_this_buffer = n_ip_bytes_this_buffer > ip_header_length ?
815  n_ip_bytes_this_buffer - ip_header_length : 0;
816  }
817  while (1)
818  {
819  sum0 = ip_incremental_checksum (sum0, data_this_buffer, n_this_buffer);
820  n_bytes_left -= n_this_buffer;
821  if (n_bytes_left == 0)
822  break;
823 
824  ASSERT (p0->flags & VLIB_BUFFER_NEXT_PRESENT);
825  p0 = vlib_get_buffer (vm, p0->next_buffer);
826  data_this_buffer = vlib_buffer_get_current (p0);
827  n_this_buffer = p0->current_length;
828  }
829 
830  sum16 = ~ip_csum_fold (sum0);
831 
832  return sum16;
833 }
834 
835 
836 static void
838  vlib_buffer_t * b0, int is_ip6)
839 {
840  u16 payload_length =
841  data_len + sizeof (icmp46_header_t) + offsetof (icmp46_echo_request_t,
842  data);
843  u16 total_length = payload_length + l4_offset;
844  icmp46_header_t *icmp46 = vlib_buffer_get_current (b0) + l4_offset;
845  icmp46->checksum = 0;
846 
847  if (is_ip6)
848  {
850  ip6->payload_length = clib_host_to_net_u16 (payload_length);
851 
852  int bogus_length = 0;
853  icmp46->checksum =
854  ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6, &bogus_length);
855  }
856  else
857  {
859  ip4->length = clib_host_to_net_u16 (total_length);
860 
861  ip4->checksum = ip4_header_checksum (ip4);
862  icmp46->checksum = ip4_icmp_compute_checksum (vm, b0, ip4);
863  }
864 }
865 
866 static u16
868 {
870 }
871 
872 static int
874  int is_ip6)
875 {
876  vlib_frame_t *f = 0;
877  u32 lookup_node_index =
878  is_ip6 ? ip6_lookup_node.index : ip4_lookup_node.index;
879  int n_sent = 0;
880 
881  u16 n_to_send;
882 
883  /*
884  * Enqueue the packet, possibly as one or more frames of copies to make
885  * bursts. We enqueue b0 as the very last buffer, when there is no possibility
886  * for error in vlib_buffer_copy, so as to allow the caller to free it
887  * in case we encounter the error in the middle of the loop.
888  */
889  for (n_to_send = at_most_a_frame (burst), burst -= n_to_send; n_to_send > 0;
890  n_to_send = at_most_a_frame (burst), burst -= n_to_send)
891  {
892  f = vlib_get_frame_to_node (vm, lookup_node_index);
893  /* f can not be NULL here - frame allocation failure causes panic */
894 
895  u32 *to_next = vlib_frame_vector_args (f);
896  f->n_vectors = n_to_send;
897 
898  while (n_to_send > 1)
899  {
900  vlib_buffer_t *b0copy = vlib_buffer_copy (vm, b0);
901  if (PREDICT_FALSE (b0copy == NULL))
902  goto ship_and_ret;
903  *to_next++ = vlib_get_buffer_index (vm, b0copy);
904  n_to_send--;
905  n_sent++;
906  }
907 
908  /* n_to_send is guaranteed to equal 1 here */
909  if (burst > 0)
910  {
911  /* not the last burst, so still make a copy for the last buffer */
912  vlib_buffer_t *b0copy = vlib_buffer_copy (vm, b0);
913  if (PREDICT_FALSE (b0copy == NULL))
914  goto ship_and_ret;
915  n_to_send--;
916  *to_next++ = vlib_get_buffer_index (vm, b0copy);
917  }
918  else
919  {
920  /* put the original buffer as the last one of an error-free run */
921  *to_next++ = vlib_get_buffer_index (vm, b0);
922  }
923  vlib_put_frame_to_node (vm, lookup_node_index, f);
924  n_sent += f->n_vectors;
925  }
926  return n_sent;
927  /*
928  * We reach here in case we already enqueued one or more buffers
929  * and maybe one or more frames but could not make more copies.
930  * There is an outstanding frame - so ship it and return.
931  * Caller will have to free the b0 in this case, since
932  * we did not enqueue it here yet.
933  */
934 ship_and_ret:
935  ASSERT (n_to_send <= f->n_vectors);
936  f->n_vectors -= n_to_send;
937  n_sent += f->n_vectors;
938  vlib_put_frame_to_node (vm, lookup_node_index, f);
939  return n_sent;
940 }
941 
942 
943 /*
944  * An address-family agnostic ping send function.
945  */
946 
947 #define ERROR_OUT(e) do { err = e; goto done; } while (0)
948 
951  u32 table_id,
952  ip46_address_t * pa46,
954  u16 seq_host, u16 id_host, u16 data_len, u32 burst,
955  u8 verbose, int is_ip6)
956 {
957  int err = SEND_PING_OK;
958  u32 bi0 = 0;
959  int n_buf0 = 0;
960  vlib_buffer_t *b0;
961 
962  n_buf0 = vlib_buffer_alloc (vm, &bi0, 1);
963  if (n_buf0 < 1)
964  ERROR_OUT (SEND_PING_ALLOC_FAIL);
965 
966  b0 = vlib_get_buffer (vm, bi0);
967 
968  /*
969  * if the user did not provide a source interface,
970  * perform a resolution and use an interface
971  * via which it succeeds.
972  */
973  u32 fib_index;
974  if (~0 == sw_if_index)
975  {
977  sw_if_index = ip46_get_resolving_interface (fib_index, pa46, is_ip6);
978  }
979  else
980  fib_index =
982 
983  if (~0 == fib_index)
984  ERROR_OUT (SEND_PING_NO_TABLE);
985  if (~0 == sw_if_index)
986  ERROR_OUT (SEND_PING_NO_INTERFACE);
987 
988  vnet_buffer (b0)->sw_if_index[VLIB_RX] = sw_if_index;
989  vnet_buffer (b0)->sw_if_index[VLIB_TX] = fib_index;
990 
991  int l4_header_offset = ip46_fill_l3_header (pa46, b0, is_ip6);
992 
993  /* set the src address in the buffer */
995  ERROR_OUT (SEND_PING_NO_SRC_ADDRESS);
996  if (verbose)
998 
999  data_len =
1000  ip46_fill_icmp_request_at (vm, l4_header_offset, seq_host, id_host,
1001  data_len, b0, is_ip6);
1002 
1003  ip46_fix_len_and_csum (vm, l4_header_offset, data_len, b0, is_ip6);
1004 
1005  int n_sent = ip46_enqueue_packet (vm, b0, burst, is_ip6);
1006  if (n_sent < burst)
1007  err = SEND_PING_NO_BUFFERS;
1008 
1009 done:
1010  if (err != SEND_PING_OK)
1011  {
1012  if (n_buf0 > 0)
1013  vlib_buffer_free (vm, &bi0, 1);
1014  }
1015  return err;
1016 }
1017 
1020  u32 table_id, ip6_address_t * pa6,
1021  u32 sw_if_index, u16 seq_host, u16 id_host, u16 data_len,
1022  u32 burst, u8 verbose)
1023 {
1024  ip46_address_t target;
1025  target.ip6 = *pa6;
1026  return send_ip46_ping (vm, table_id, &target, sw_if_index, seq_host,
1027  id_host, data_len, burst, verbose, 1 /* is_ip6 */ );
1028 }
1029 
1032  u32 table_id, ip4_address_t * pa4,
1033  u32 sw_if_index, u16 seq_host, u16 id_host, u16 data_len,
1034  u32 burst, u8 verbose)
1035 {
1036  ip46_address_t target;
1037  ip46_address_set_ip4 (&target, pa4);
1038  return send_ip46_ping (vm, table_id, &target, sw_if_index, seq_host,
1039  id_host, data_len, burst, verbose, 0 /* is_ip6 */ );
1040 }
1041 
1042 static void
1044 {
1045  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
1046  int l4_offset;
1047  void *paddr;
1048  void *format_addr_func;
1049  u16 payload_length;
1050  u8 ttl;
1051  if (is_ip6)
1052  {
1054  paddr = (void *) &ip6->src_address;
1055  format_addr_func = (void *) format_ip6_address;
1056  ttl = ip6->hop_limit;
1057  l4_offset = sizeof (ip6_header_t); // FIXME - EH processing ?
1058  payload_length = clib_net_to_host_u16 (ip6->payload_length);
1059  }
1060  else
1061  {
1063  paddr = (void *) &ip4->src_address;
1064  format_addr_func = (void *) format_ip4_address;
1065  ttl = ip4->ttl;
1066  l4_offset = ip4_header_bytes (ip4);
1067  payload_length =
1068  clib_net_to_host_u16 (ip4->length) + ip4_header_bytes (ip4);
1069  }
1070  icmp46_header_t *icmp = vlib_buffer_get_current (b0) + l4_offset;
1071  icmp46_echo_request_t *icmp_echo = (icmp46_echo_request_t *) (icmp + 1);
1072  u64 *dataplane_ts = (u64 *) & vnet_buffer (b0)->unused[0];
1073 
1074  f64 clocks_per_second = ((f64) vm->clib_time.clocks_per_second);
1075  f64 rtt =
1076  ((f64) (*dataplane_ts - icmp_echo->time_sent)) / clocks_per_second;
1077 
1079  "%d bytes from %U: icmp_seq=%d ttl=%d time=%.4f ms",
1080  payload_length,
1081  format_addr_func,
1082  paddr,
1083  clib_host_to_net_u16 (icmp_echo->seq), ttl, rtt * 1000.0);
1084 }
1085 
1086 /*
1087  * Perform the ping run with the given parameters in the current CLI process.
1088  * Depending on whether pa4 or pa6 is set, runs IPv4 or IPv6 ping.
1089  * The amusing side effect is of course if both are set, then both pings are sent.
1090  * This behavior can be used to ping a dualstack host over IPv4 and IPv6 at once.
1091  */
1092 
1093 static void
1095  ip6_address_t * pa6, u32 sw_if_index,
1096  f64 ping_interval, u32 ping_repeat, u32 data_len,
1097  u32 ping_burst, u32 verbose)
1098 {
1099  int i;
1100  uword curr_proc = vlib_current_process (vm);
1101  u32 n_replies = 0;
1102  u32 n_requests = 0;
1103  u16 icmp_id;
1104 
1105  static u32 rand_seed = 0;
1106 
1107  if (PREDICT_FALSE (!rand_seed))
1108  rand_seed = random_default_seed ();
1109 
1110  icmp_id = random_u32 (&rand_seed) & 0xffff;
1111 
1112  while (~0 != get_cli_process_id_by_icmp_id_mt (vm, icmp_id))
1113  {
1114  vlib_cli_output (vm, "ICMP ID collision at %d, incrementing", icmp_id);
1115  icmp_id++;
1116  }
1117 
1118  set_cli_process_id_by_icmp_id_mt (vm, icmp_id, curr_proc);
1119 
1120  for (i = 1; i <= ping_repeat; i++)
1121  {
1122  send_ip46_ping_result_t res = SEND_PING_OK;
1123  f64 sleep_interval;
1124  f64 time_ping_sent = vlib_time_now (vm);
1125  if (pa6)
1126  {
1127  res = send_ip6_ping (vm, table_id,
1128  pa6, sw_if_index, i, icmp_id,
1129  data_len, ping_burst, verbose);
1130  if (SEND_PING_OK == res)
1131  n_requests += ping_burst;
1132  else
1133  vlib_cli_output (vm, "Failed: %U", format_ip46_ping_result, res);
1134  }
1135  if (pa4)
1136  {
1137  res = send_ip4_ping (vm, table_id, pa4,
1138  sw_if_index, i, icmp_id, data_len,
1139  ping_burst, verbose);
1140  if (SEND_PING_OK == res)
1141  n_requests += ping_burst;
1142  else
1143  vlib_cli_output (vm, "Failed: %U", format_ip46_ping_result, res);
1144  }
1145 
1146  /* Collect and print the responses until it is time to send a next ping */
1147 
1148  while ((i <= ping_repeat)
1149  &&
1150  ((sleep_interval =
1151  time_ping_sent + ping_interval - vlib_time_now (vm)) > 0.0))
1152  {
1153  uword event_type, *event_data = 0;
1154  vlib_process_wait_for_event_or_clock (vm, sleep_interval);
1155  event_type = vlib_process_get_events (vm, &event_data);
1156  switch (event_type)
1157  {
1158  case ~0: /* no events => timeout */
1159  break;
1160  case PING_RESPONSE_IP6:
1161  /* fall-through */
1162  case PING_RESPONSE_IP4:
1163  {
1164  int ii;
1165  int is_ip6 = (event_type == PING_RESPONSE_IP6);
1166  for (ii = 0; ii < vec_len (event_data); ii++)
1167  {
1168  u32 bi0 = event_data[ii];
1170  n_replies++;
1171  if (0 != bi0)
1172  vlib_buffer_free (vm, &bi0, 1);
1173  }
1174  }
1175  break;
1178  /* someone pressed a key, abort */
1179  vlib_cli_output (vm, "Aborted due to a keypress.");
1180  goto double_break;
1181  }
1182  vec_free (event_data);
1183  }
1184  }
1185 double_break:
1186  vlib_cli_output (vm, "\n");
1187  {
1188  float loss =
1189  (0 ==
1190  n_requests) ? 0 : 100.0 * ((float) n_requests -
1191  (float) n_replies) / (float) n_requests;
1193  "Statistics: %u sent, %u received, %f%% packet loss\n",
1194  n_requests, n_replies, loss);
1196  }
1197 }
1198 
1199 
1200 
1201 static clib_error_t *
1203  unformat_input_t * input, vlib_cli_command_t * cmd)
1204 {
1205  ip4_address_t a4;
1206  ip6_address_t a6;
1207  clib_error_t *error = 0;
1208  u32 ping_repeat = 5;
1209  u32 ping_burst = 1;
1210  u8 ping_ip4, ping_ip6;
1211  vnet_main_t *vnm = vnet_get_main ();
1213  u32 verbose = 0;
1214  f64 ping_interval = PING_DEFAULT_INTERVAL;
1216 
1217  table_id = 0;
1218  ping_ip4 = ping_ip6 = 0;
1219  sw_if_index = ~0;
1220 
1221  if (unformat (input, "%U", unformat_ip4_address, &a4))
1222  {
1223  ping_ip4 = 1;
1224  }
1225  else if (unformat (input, "%U", unformat_ip6_address, &a6))
1226  {
1227  ping_ip6 = 1;
1228  }
1229  else if (unformat (input, "ipv4"))
1230  {
1231  if (unformat (input, "%U", unformat_ip4_address, &a4))
1232  {
1233  ping_ip4 = 1;
1234  }
1235  else
1236  {
1237  error =
1238  clib_error_return (0,
1239  "expecting IPv4 address but got `%U'",
1240  format_unformat_error, input);
1241  }
1242  }
1243  else if (unformat (input, "ipv6"))
1244  {
1245  if (unformat (input, "%U", unformat_ip6_address, &a6))
1246  {
1247  ping_ip6 = 1;
1248  }
1249  else
1250  {
1251  error =
1252  clib_error_return (0,
1253  "expecting IPv6 address but got `%U'",
1254  format_unformat_error, input);
1255  }
1256  }
1257  else
1258  {
1259  error =
1260  clib_error_return (0,
1261  "expecting IP4/IP6 address `%U'. Usage: ping <addr> [source <intf>] [size <datasz>] [repeat <count>] [verbose]",
1262  format_unformat_error, input);
1263  goto done;
1264  }
1265 
1266  /* allow for the second AF in the same ping */
1267  if (!ping_ip4 && (unformat (input, "ipv4")))
1268  {
1269  if (unformat (input, "%U", unformat_ip4_address, &a4))
1270  {
1271  ping_ip4 = 1;
1272  }
1273  }
1274  else if (!ping_ip6 && (unformat (input, "ipv6")))
1275  {
1276  if (unformat (input, "%U", unformat_ip6_address, &a6))
1277  {
1278  ping_ip6 = 1;
1279  }
1280  }
1281 
1282  /* parse the rest of the parameters in a cycle */
1283  while (!unformat_eof (input, NULL))
1284  {
1285  if (unformat (input, "source"))
1286  {
1287  if (!unformat_user
1288  (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
1289  {
1290  error =
1291  clib_error_return (0,
1292  "unknown interface `%U'",
1293  format_unformat_error, input);
1294  goto done;
1295  }
1296  }
1297  else if (unformat (input, "size"))
1298  {
1299  if (!unformat (input, "%u", &data_len))
1300  {
1301  error =
1302  clib_error_return (0,
1303  "expecting size but got `%U'",
1304  format_unformat_error, input);
1305  goto done;
1306  }
1308  {
1309  error =
1310  clib_error_return (0,
1311  "%d is bigger than maximum allowed payload size %d",
1313  goto done;
1314  }
1315  }
1316  else if (unformat (input, "table-id"))
1317  {
1318  if (!unformat (input, "%u", &table_id))
1319  {
1320  error =
1321  clib_error_return (0,
1322  "expecting table-id but got `%U'",
1323  format_unformat_error, input);
1324  goto done;
1325  }
1326  }
1327  else if (unformat (input, "interval"))
1328  {
1329  if (!unformat (input, "%f", &ping_interval))
1330  {
1331  error =
1332  clib_error_return (0,
1333  "expecting interval (floating point number) got `%U'",
1334  format_unformat_error, input);
1335  goto done;
1336  }
1337  }
1338  else if (unformat (input, "repeat"))
1339  {
1340  if (!unformat (input, "%u", &ping_repeat))
1341  {
1342  error =
1343  clib_error_return (0,
1344  "expecting repeat count but got `%U'",
1345  format_unformat_error, input);
1346  goto done;
1347  }
1348  }
1349  else if (unformat (input, "burst"))
1350  {
1351  if (!unformat (input, "%u", &ping_burst))
1352  {
1353  error =
1354  clib_error_return (0,
1355  "expecting burst count but got `%U'",
1356  format_unformat_error, input);
1357  goto done;
1358  }
1359  }
1360  else if (unformat (input, "verbose"))
1361  {
1362  verbose = 1;
1363  }
1364  else
1365  {
1366  error = clib_error_return (0, "unknown input `%U'",
1367  format_unformat_error, input);
1368  goto done;
1369  }
1370  }
1371 
1372 /*
1373  * Operationally, one won't (and shouldn't) need to send more than a frame worth of pings.
1374  * But it may be handy during the debugging.
1375  */
1376 
1377 #ifdef CLIB_DEBUG
1378 #define MAX_PING_BURST (10*VLIB_FRAME_SIZE)
1379 #else
1380 #define MAX_PING_BURST (VLIB_FRAME_SIZE)
1381 #endif
1382 
1383  if (ping_burst < 1 || ping_burst > MAX_PING_BURST)
1384  return clib_error_return (0, "burst size must be between 1 and %u",
1385  MAX_PING_BURST);
1386 
1387  run_ping_ip46_address (vm, table_id, ping_ip4 ? &a4 : NULL,
1388  ping_ip6 ? &a6 : NULL, sw_if_index, ping_interval,
1389  ping_repeat, data_len, ping_burst, verbose);
1390 done:
1391  return error;
1392 }
1393 
1394 /*?
1395  * This command sends an ICMP ECHO_REQUEST to network hosts. The address
1396  * can be an IPv4 or IPv6 address (or both at the same time).
1397  *
1398  * @cliexpar
1399  * @parblock
1400  * Example of how ping an IPv4 address:
1401  * @cliexstart{ping 172.16.1.2 source GigabitEthernet2/0/0 repeat 2}
1402  * 64 bytes from 172.16.1.2: icmp_seq=1 ttl=64 time=.1090 ms
1403  * 64 bytes from 172.16.1.2: icmp_seq=2 ttl=64 time=.0914 ms
1404  *
1405  * Statistics: 2 sent, 2 received, 0% packet loss
1406  * @cliexend
1407  *
1408  * Example of how ping both an IPv4 address and IPv6 address at the same time:
1409  * @cliexstart{ping 172.16.1.2 ipv6 fe80::24a5:f6ff:fe9c:3a36 source GigabitEthernet2/0/0 repeat 2 verbose}
1410  * Adjacency index: 10, sw_if_index: 1
1411  * Adj: ip6-discover-neighbor
1412  * Adj Interface: 0
1413  * Forced set interface: 1
1414  * Adjacency index: 0, sw_if_index: 4294967295
1415  * Adj: ip4-miss
1416  * Adj Interface: 0
1417  * Forced set interface: 1
1418  * Source address: 172.16.1.1
1419  * 64 bytes from 172.16.1.2: icmp_seq=1 ttl=64 time=.1899 ms
1420  * Adjacency index: 10, sw_if_index: 1
1421  * Adj: ip6-discover-neighbor
1422  * Adj Interface: 0
1423  * Forced set interface: 1
1424  * Adjacency index: 0, sw_if_index: 4294967295
1425  * Adj: ip4-miss
1426  * Adj Interface: 0
1427  * Forced set interface: 1
1428  * Source address: 172.16.1.1
1429  * 64 bytes from 172.16.1.2: icmp_seq=2 ttl=64 time=.0910 ms
1430  *
1431  * Statistics: 4 sent, 2 received, 50% packet loss
1432  * @cliexend
1433  * @endparblock
1434 ?*/
1435 /* *INDENT-OFF* */
1437 {
1438  .path = "ping",
1439  .function = ping_ip_address,
1440  .short_help = "ping {<ip-addr> | ipv4 <ip4-addr> | ipv6 <ip6-addr>}"
1441  " [ipv4 <ip4-addr> | ipv6 <ip6-addr>] [source <interface>]"
1442  " [size <pktsize:60>] [interval <sec:1>] [repeat <cnt:5>] [table-id <id:0>]"
1443  " [burst <count:1>] [verbose]",
1444  .is_mp_safe = 1,
1445 };
1446 /* *INDENT-ON* */
1447 
1448 static clib_error_t *
1450 {
1452  ping_main_t *pm = &ping_main;
1453 
1454  pm->ip6_main = &ip6_main;
1455  pm->ip4_main = &ip4_main;
1456  icmp6_register_type (vm, ICMP6_echo_reply, ip6_icmp_echo_reply_node.index);
1457  ip4_icmp_register_type (vm, ICMP4_echo_reply,
1458  ip4_icmp_echo_reply_node.index);
1459  if (tm->n_vlib_mains > 1)
1461 
1462  ip4_icmp_register_type (vm, ICMP4_echo_request,
1464 
1465  return 0;
1466 }
1467 
1469 
1470 /* *INDENT-OFF* */
1471 VLIB_PLUGIN_REGISTER () = {
1472  .version = VPP_BUILD_VER,
1473  .description = "Ping (ping)",
1474 };
1475 /* *INDENT-ON* */
1476 
1477 /*
1478  * fd.io coding-style-patch-verification: ON
1479  *
1480  * Local Variables:
1481  * eval: (c-set-style "gnu")
1482  * End:
1483  */
vlib_process_signal_event_mt
static void vlib_process_signal_event_mt(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Signal event to process from any thread.
Definition: node_funcs.h:1043
ICMP46_ECHO_REPLY_NEXT_DROP
@ ICMP46_ECHO_REPLY_NEXT_DROP
Definition: ping.h:86
vlib.h
ip4_main_t::ttl
u8 ttl
TTL to use for host generated packets.
Definition: ip4.h:160
ping_main_t::active_ping_runs
ping_run_t * active_ping_runs
Definition: ping.h:58
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
clear_cli_process_id_by_icmp_id_mt
static_always_inline void clear_cli_process_id_by_icmp_id_mt(vlib_main_t *vm, u16 icmp_id)
Definition: ping.c:148
vlib_buffer_t::next_buffer
u32 next_buffer
Next buffer for this linked-list of buffers.
Definition: buffer.h:149
ip4_lookup_node
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
Definition: ip4_forward.c:104
vlib_frame_t::n_vectors
u16 n_vectors
Definition: node.h:387
icmp_input_trace_t
Definition: icmp4.h:41
vlib_buffer_free
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:982
vlib_main_t::random_buffer
clib_random_buffer_t random_buffer
Definition: main.h:210
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
ip46_get_resolving_interface
static u32 ip46_get_resolving_interface(u32 fib_index, ip46_address_t *pa46, int is_ip6)
Definition: ping.c:671
ip4_icmp_echo_reply_node_fn
static uword ip4_icmp_echo_reply_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:326
ip46_icmp_echo_reply_inner_node_fn
static_always_inline uword ip46_icmp_echo_reply_inner_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace, int is_ip6)
Definition: ping.c:236
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
ip46_fill_l3_header
static int ip46_fill_l3_header(ip46_address_t *pa46, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:696
set_cli_process_id_by_icmp_id_mt
static_always_inline void set_cli_process_id_by_icmp_id_mt(vlib_main_t *vm, u16 icmp_id, uword cli_process_id)
Definition: ping.c:124
run_ping_ip46_address
static void run_ping_ip46_address(vlib_main_t *vm, u32 table_id, ip4_address_t *pa4, ip6_address_t *pa6, u32 sw_if_index, f64 ping_interval, u32 ping_repeat, u32 data_len, u32 ping_burst, u32 verbose)
Definition: ping.c:1094
vlib_main_t::clib_time
clib_time_t clib_time
Definition: main.h:106
init_icmp46_echo_request
static u16 init_icmp46_echo_request(vlib_main_t *vm, vlib_buffer_t *b0, int l4_header_offset, icmp46_echo_request_t *icmp46_echo, u16 seq_host, u16 id_host, u64 now, u16 data_len)
Definition: ping.c:595
ip6_tcp_udp_icmp_compute_checksum
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
Definition: ip6_forward.c:1098
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
vlib_buffer_copy
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer_funcs.h:1081
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
clib_spinlock_lock_if_init
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
Definition: lock.h:106
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
f
vlib_frame_t * f
Definition: interface_output.c:1080
ip6_icmp_echo_reply_node_fn
static uword ip6_icmp_echo_reply_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:334
ip46_address_set_ip4
static void ip46_address_set_ip4(ip46_address_t *ip46, const ip4_address_t *ip)
Definition: ip46_address.h:67
format_ip46_ping_result
static u8 * format_ip46_ping_result(u8 *s, va_list *args)
Definition: ping.c:74
ICMP46_ECHO_REPLY_NEXT_PUNT
@ ICMP46_ECHO_REPLY_NEXT_PUNT
Definition: ping.h:87
ttl
u8 ttl
Definition: fib_types.api:26
send_ip6_ping
static send_ip46_ping_result_t send_ip6_ping(vlib_main_t *vm, u32 table_id, ip6_address_t *pa6, u32 sw_if_index, u16 seq_host, u16 id_host, u16 data_len, u32 burst, u8 verbose)
Definition: ping.c:1019
ip4_header_checksum_is_valid
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
Definition: ip4_packet.h:396
next
u16 * next
Definition: nat44_ei_out2in.c:718
vlib_trace_frame_buffers_only
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
Definition: trace.c:48
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
icmp_input_trace_t::packet_data
u8 packet_data[64]
Definition: icmp4.h:43
icmp4.h
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
ip46_fill_icmp_request_at
static u16 ip46_fill_icmp_request_at(vlib_main_t *vm, int l4_offset, u16 seq_host, u16 id_host, u16 data_len, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:771
format_icmp_echo_trace
u8 * format_icmp_echo_trace(u8 *s, va_list *va)
Definition: ping.c:51
ip4_fib_table_get_index_for_sw_if_index
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: pnat_test_stubs.h:21
send_ip4_ping
static send_ip46_ping_result_t send_ip4_ping(vlib_main_t *vm, u32 table_id, ip4_address_t *pa4, u32 sw_if_index, u16 seq_host, u16 id_host, u16 data_len, u32 burst, u8 verbose)
Definition: ping.c:1031
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
vlib_current_process
static uword vlib_current_process(vlib_main_t *vm)
Definition: node_funcs.h:457
icmp_echo_trace_t::seq
u16 seq
Definition: ping.c:44
ping_run_t::cli_process_id
uword cli_process_id
Definition: ping.h:50
unformat_input_t
struct _unformat_input_t unformat_input_t
vlib_error_count
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
Definition: error_funcs.h:57
vlib_frame_t
Definition: node.h:372
vlib_get_frame_to_node
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:184
ip6_fib_index_from_table_id
static u32 ip6_fib_index_from_table_id(u32 table_id)
Definition: ip6_fib.h:220
ip6_lookup_node
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
Definition: ip6_forward.c:741
ip4_header_t
Definition: ip4_packet.h:87
get_icmp_echo_payload_byte
static_always_inline u8 get_icmp_echo_payload_byte(int offset)
Definition: ping.c:588
error
Definition: cJSON.c:88
at_most_a_frame
static u16 at_most_a_frame(u32 count)
Definition: ping.c:867
ip4_header_t::length
u16 length
Definition: ip4_packet.h:99
ip4_icmp_register_type
void ip4_icmp_register_type(vlib_main_t *vm, icmp4_type_t type, u32 node_index)
Definition: icmp4.c:538
ip4_icmp_echo_request
static uword ip4_icmp_echo_request(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:370
random_u32
static u32 random_u32(u32 *seed)
32-bit random number generator
Definition: random.h:69
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
icmp6_register_type
void icmp6_register_type(vlib_main_t *vm, icmp6_type_t type, u32 node_index)
Definition: icmp6.c:750
unformat_eof
unformat_function_t unformat_eof
Definition: format.h:285
vlib_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_put_frame_to_node
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:218
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:283
ip46_set_src_address
static bool ip46_set_src_address(u32 sw_if_index, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:730
ERROR_OUT
#define ERROR_OUT(e)
Definition: ping.c:947
count
u8 count
Definition: dhcp.api:208
ip6_icmp_echo_reply_node
static vlib_node_registration_t ip6_icmp_echo_reply_node
(constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node)
Definition: ping.c:342
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
ping.h
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
PING_MAXIMUM_DATA_SIZE
#define PING_MAXIMUM_DATA_SIZE
Definition: ping.h:68
vlib_buffer_alloc
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:708
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
ip4_main_t::host_config
struct ip4_main_t::@372 host_config
Template information for VPP generated packets.
ip_incremental_checksum
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
Definition: ip_packet.h:319
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_get_buffer_index
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
Definition: buffer_funcs.h:324
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
PING_CLI_UNKNOWN_NODE
#define PING_CLI_UNKNOWN_NODE
Definition: ping.h:70
PING_RESPONSE_IP6
@ PING_RESPONSE_IP6
Definition: ping.h:25
ip46_enqueue_packet
static int ip46_enqueue_packet(vlib_main_t *vm, vlib_buffer_t *b0, u32 burst, int is_ip6)
Definition: ping.c:873
static_always_inline
#define static_always_inline
Definition: clib.h:112
ip46_fix_len_and_csum
static void ip46_fix_len_and_csum(vlib_main_t *vm, int l4_offset, u16 data_len, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:837
ip4_icmp_echo_request_node
static vlib_node_registration_t ip4_icmp_echo_request_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_request_node)
Definition: ping.c:563
UNIX_CLI_PROCESS_EVENT_QUIT
@ UNIX_CLI_PROCESS_EVENT_QUIT
A CLI session wants to close.
Definition: unix.h:119
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
MAX_PING_BURST
#define MAX_PING_BURST
uword
u64 uword
Definition: types.h:112
ping_ip_address
static clib_error_t * ping_ip_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ping.c:1202
ip4_fib_table_lookup
fib_node_index_t ip4_fib_table_lookup(const ip4_fib_t *fib, const ip4_address_t *addr, u32 len)
Definition: ip4_fib.c:294
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
print_ip46_icmp_reply
static void print_ip46_icmp_reply(vlib_main_t *vm, u32 bi0, int is_ip6)
Definition: ping.c:1043
PING_RESPONSE_IP4
@ PING_RESPONSE_IP4
Definition: ping.h:26
f64
double f64
Definition: types.h:142
ip4_fib_get
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:113
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
ping_main_t::ping_run_check_lock
clib_spinlock_t ping_run_check_lock
Definition: ping.h:60
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
ip4_header_t::checksum
u16 checksum
Definition: ip4_packet.h:118
ip6_fib_table_get_index_for_sw_if_index
u32 ip6_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: ip6_fib.c:353
icmp_echo_trace_t::id
u16 id
Definition: ping.c:43
send_ip46_ping_result_t
send_ip46_ping_result_t
Definition: ping.h:37
ip4_address_t
Definition: ip4_packet.h:50
fib_sas6_get
bool fib_sas6_get(u32 sw_if_index, const ip6_address_t *dst, ip6_address_t *src)
Get an IPv6 Source address to use in a packet being sent out an interface.
Definition: fib_sas.c:87
fib_entry_get_resolving_interface
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
Definition: fib_entry.c:1474
STATIC_ASSERT
#define STATIC_ASSERT(truth,...)
Definition: error_bootstrap.h:111
foreach_ip46_ping_result
@ foreach_ip46_ping_result
Definition: ping.h:40
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
ip4_header_t::dst_address
ip4_address_t dst_address
Definition: ip4_packet.h:125
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
icmp_echo_trace_t::is_ip6
u8 is_ip6
Definition: ping.c:46
ICMP46_ECHO_REPLY_N_NEXT
@ ICMP46_ECHO_REPLY_N_NEXT
Definition: ping.h:88
ping_run_t
Definition: ping.h:47
ip4_header_t::fragment_id
u16 fragment_id
Definition: ip4_packet.h:102
plugin.h
clib_random_buffer_get_data
static void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
Definition: random_buffer.h:83
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
data
u8 data[128]
Definition: ipsec_types.api:92
clib_time_t::clocks_per_second
f64 clocks_per_second
Definition: time.h:54
id
u8 id[64]
Definition: dhcp.api:160
is_ip6
bool is_ip6
Definition: ip.api:43
send_ip46_ping
static send_ip46_ping_result_t send_ip46_ping(vlib_main_t *vm, u32 table_id, ip46_address_t *pa46, u32 sw_if_index, u16 seq_host, u16 id_host, u16 data_len, u32 burst, u8 verbose, int is_ip6)
Definition: ping.c:950
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_validate_buffer_enqueue_x1
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:224
ip46_post_icmp_reply_event
static_always_inline void ip46_post_icmp_reply_event(vlib_main_t *vm, uword cli_process_id, u32 bi0, int is_ip6)
Definition: ping.c:198
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
fib_sas.h
UNIX_CLI_PROCESS_EVENT_READ_READY
@ UNIX_CLI_PROCESS_EVENT_READ_READY
A file descriptor has data to be read.
Definition: unix.h:117
ip4_header_t::src_address
ip4_address_t src_address
Definition: ip4_packet.h:125
icmp_echo_trace_t::cli_process_node
u32 cli_process_node
Definition: ping.c:45
icmp
icmp
Definition: map.api:387
PING_DEFAULT_DATA_LEN
#define PING_DEFAULT_DATA_LEN
Definition: ping.h:65
fib_sas4_get
bool fib_sas4_get(u32 sw_if_index, const ip4_address_t *dst, ip4_address_t *src)
Get an IPv4 Source address to use in a packet being sent out an interface.
Definition: fib_sas.c:50
vnet_main_t::local_interface_sw_if_index
u32 local_interface_sw_if_index
Definition: vnet.h:79
u64
unsigned long u64
Definition: types.h:89
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
vlib_process_wait_for_event_or_clock
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:755
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
data_len
u8 data_len
Definition: ikev2_types.api:24
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
ip46_fib_index_from_table_id
static u32 ip46_fib_index_from_table_id(u32 table_id, int is_ip6)
Definition: ping.c:653
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
u32
unsigned int u32
Definition: types.h:88
ip46_print_buffer_src_address
static void ip46_print_buffer_src_address(vlib_main_t *vm, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:750
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
ping_main_t::ip4_main
ip4_main_t * ip4_main
Definition: ping.h:56
ip4_header_t::ttl
u8 ttl
Definition: ip4_packet.h:112
ip46_fib_table_lookup_host
static fib_node_index_t ip46_fib_table_lookup_host(u32 fib_index, ip46_address_t *pa46, int is_ip6)
Definition: ping.c:662
vlib_thread_main_t
Definition: threads.h:264
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
ip4_address_t::data_u32
u32 data_u32
Definition: ip4_packet.h:53
ip46_get_icmp_id_and_seq
static_always_inline int ip46_get_icmp_id_and_seq(vlib_main_t *vm, vlib_buffer_t *b0, u16 *out_icmp_id, u16 *out_icmp_seq, int is_ip6)
Definition: ping.c:166
table_id
u32 table_id
Definition: wireguard.api:102
ping_main
ping_main_t ping_main
Definition: ping.c:30
get_cli_process_id_by_icmp_id_mt
static_always_inline uword get_cli_process_id_by_icmp_id_mt(vlib_main_t *vm, u16 icmp_id)
Definition: ping.c:103
icmp46_echo_reply_next_t
icmp46_echo_reply_next_t
Definition: ping.h:84
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
n_vectors
return frame n_vectors
Definition: nat44_ei_hairpinning.c:485
ping_command
static vlib_cli_command_t ping_command
(constructor) VLIB_CLI_COMMAND (ping_command)
Definition: ping.c:1436
ip6_header_t
Definition: ip6_packet.h:294
ip4_fib.h
format_ip4_header
format_function_t format_ip4_header
Definition: format.h:81
ip6_fib.h
now
f64 now
Definition: nat44_ei_out2in.c:710
vnet_main
vnet_main_t vnet_main
Definition: misc.c:43
ip4_fib_index_from_table_id
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:145
vlib_main_t
Definition: main.h:102
ip4_icmp_echo_reply_node
static vlib_node_registration_t ip4_icmp_echo_reply_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node)
Definition: ping.c:355
ip_csum_update
#define ip_csum_update(sum, old, new, type, field)
Definition: ip_packet.h:295
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
ip6_fib_table_lookup
fib_node_index_t ip6_fib_table_lookup(u32 fib_index, const ip6_address_t *addr, u32 len)
Definition: ip6_fib.c:183
ip4_icmp_input_node
vlib_node_registration_t ip4_icmp_input_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_input_node)
Definition: icmp4.c:209
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
unix.h
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
ip4_header_checksum
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
PING_DEFAULT_INTERVAL
#define PING_DEFAULT_INTERVAL
Definition: ping.h:66
ip_csum_t
uword ip_csum_t
Definition: ip_packet.h:245
format_ip6_address
format_function_t format_ip6_address
Definition: format.h:91
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
ip4_icmp_compute_checksum
u16 ip4_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
Definition: ping.c:792
format_icmp_input_trace
static u8 * format_icmp_input_trace(u8 *s, va_list *va)
Definition: ping.c:550
ping_cli_init
static clib_error_t * ping_cli_init(vlib_main_t *vm)
Definition: ping.c:1449
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
ip4_header_bytes
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:190
icmp_echo_trace_t
Definition: ping.c:41
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
vlib_node_runtime_t
Definition: node.h:454
clib_spinlock_unlock_if_init
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
Definition: lock.h:129
ping_main_t::ip6_main
ip6_main_t * ip6_main
Definition: ping.h:55
ping_run_t::icmp_id
u16 icmp_id
Definition: ping.h:49
vlib_cli_command_t
Definition: cli.h:92
clib_cpu_time_now
static u64 clib_cpu_time_now(void)
Definition: time.h:81
from
from
Definition: nat44_ei_hairpinning.c:415
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
vlib_buffer_t::total_length_not_including_first_buffer
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
Definition: buffer.h:176
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vlib_get_next_frame
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:395
ip46_echo_reply_maybe_trace_buffer
static_always_inline void ip46_echo_reply_maybe_trace_buffer(vlib_main_t *vm, vlib_node_runtime_t *node, uword cli_process_id, u16 id, u16 seq, vlib_buffer_t *b0, int is_ip6)
Definition: ping.c:219
ip_csum_fold
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:301
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
ip46_icmp_echo_reply_outer_node_fn
static_always_inline uword ip46_icmp_echo_reply_outer_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip6)
Definition: ping.c:313
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
ip46_fib_table_get_index_for_sw_if_index
static u32 ip46_fib_table_get_index_for_sw_if_index(u32 sw_if_index, int is_ip6)
Definition: ping.c:685
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896
ip4_next_header
static void * ip4_next_header(ip4_header_t *i)
Definition: ip4_packet.h:196
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
random_default_seed
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)
Definition: random.h:91
ping_main_t
Definition: ping.h:53