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