FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ping.c File Reference

IPv4 and IPv6 ICMP Ping. More...

+ Include dependency graph for ping.c:

Go to the source code of this file.

Data Structures

struct  icmp_echo_trace_t
 

Macros

#define ERROR_OUT(e)   do { err = e; goto done; } while (0)
 
#define MAX_PING_BURST   (10*VLIB_FRAME_SIZE)
 

Functions

u8format_icmp_echo_trace (u8 *s, va_list *va)
 
static u8format_ip46_ping_result (u8 *s, va_list *args)
 
static_always_inline uword get_cli_process_id_by_icmp_id_mt (vlib_main_t *vm, u16 icmp_id)
 
static_always_inline void set_cli_process_id_by_icmp_id_mt (vlib_main_t *vm, u16 icmp_id, uword cli_process_id)
 
static_always_inline void clear_cli_process_id_by_icmp_id_mt (vlib_main_t *vm, u16 icmp_id)
 
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)
 
static_always_inline void ip46_post_icmp_reply_event (vlib_main_t *vm, uword cli_process_id, u32 bi0, int is_ip6)
 
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)
 
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)
 
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)
 
static uword ip4_icmp_echo_reply_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static uword ip6_icmp_echo_reply_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static uword ip4_icmp_echo_request (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static u8format_icmp_input_trace (u8 *s, va_list *va)
 
static_always_inline u8 get_icmp_echo_payload_byte (int offset)
 
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)
 
static u32 ip46_fib_index_from_table_id (u32 table_id, int is_ip6)
 
static fib_node_index_t ip46_fib_table_lookup_host (u32 fib_index, ip46_address_t *pa46, int is_ip6)
 
static u32 ip46_get_resolving_interface (u32 fib_index, ip46_address_t *pa46, int is_ip6)
 
static u32 ip46_fib_table_get_index_for_sw_if_index (u32 sw_if_index, int is_ip6)
 
static int ip46_fill_l3_header (ip46_address_t *pa46, vlib_buffer_t *b0, int is_ip6)
 
static bool ip46_set_src_address (u32 sw_if_index, vlib_buffer_t *b0, int is_ip6)
 
static void ip46_print_buffer_src_address (vlib_main_t *vm, vlib_buffer_t *b0, int is_ip6)
 
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)
 
u16 ip4_icmp_compute_checksum (vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
 
static void ip46_fix_len_and_csum (vlib_main_t *vm, int l4_offset, u16 data_len, vlib_buffer_t *b0, int is_ip6)
 
static u16 at_most_a_frame (u32 count)
 
static int ip46_enqueue_packet (vlib_main_t *vm, vlib_buffer_t *b0, u32 burst, int is_ip6)
 
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)
 
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)
 
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)
 
static void print_ip46_icmp_reply (vlib_main_t *vm, u32 bi0, int is_ip6)
 
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)
 
static clib_error_tping_ip_address (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tping_cli_init (vlib_main_t *vm)
 
 VLIB_PLUGIN_REGISTER ()
 

Variables

ping_main_t ping_main
 
static vlib_node_registration_t ip6_icmp_echo_reply_node
 (constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node) More...
 
static vlib_node_registration_t ip4_icmp_echo_reply_node
 (constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node) More...
 
static vlib_node_registration_t ip4_icmp_echo_request_node
 (constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_request_node) More...
 
static vlib_cli_command_t ping_command
 (constructor) VLIB_CLI_COMMAND (ping_command) More...
 

Detailed Description

IPv4 and IPv6 ICMP Ping.

This file contains code to support IPv4 or IPv6 ICMP ECHO_REQUEST to network hosts.

Definition in file ping.c.

Macro Definition Documentation

◆ ERROR_OUT

#define ERROR_OUT (   e)    do { err = e; goto done; } while (0)

Definition at line 947 of file ping.c.

◆ MAX_PING_BURST

#define MAX_PING_BURST   (10*VLIB_FRAME_SIZE)

Function Documentation

◆ at_most_a_frame()

static u16 at_most_a_frame ( u32  count)
static

Definition at line 867 of file ping.c.

+ Here is the caller graph for this function:

◆ 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 at line 148 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_icmp_echo_trace()

u8* format_icmp_echo_trace ( u8 s,
va_list *  va 
)

Definition at line 51 of file ping.c.

◆ format_icmp_input_trace()

static u8* format_icmp_input_trace ( u8 s,
va_list *  va 
)
static

Definition at line 550 of file ping.c.

◆ format_ip46_ping_result()

static u8* format_ip46_ping_result ( u8 s,
va_list *  args 
)
static

Definition at line 74 of file ping.c.

+ Here is the caller graph for this function:

◆ 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 at line 103 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_icmp_echo_payload_byte()

static_always_inline u8 get_icmp_echo_payload_byte ( int  offset)

Definition at line 588 of file ping.c.

+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 595 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 219 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_enqueue_packet()

static int ip46_enqueue_packet ( vlib_main_t vm,
vlib_buffer_t b0,
u32  burst,
int  is_ip6 
)
static

Definition at line 873 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_fib_index_from_table_id()

static u32 ip46_fib_index_from_table_id ( u32  table_id,
int  is_ip6 
)
static

Definition at line 653 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 685 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 662 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 771 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_fill_l3_header()

static int ip46_fill_l3_header ( ip46_address_t *  pa46,
vlib_buffer_t b0,
int  is_ip6 
)
static

Definition at line 696 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 837 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 166 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_get_resolving_interface()

static u32 ip46_get_resolving_interface ( u32  fib_index,
ip46_address_t *  pa46,
int  is_ip6 
)
static

Definition at line 671 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 236 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 313 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 198 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_print_buffer_src_address()

static void ip46_print_buffer_src_address ( vlib_main_t vm,
vlib_buffer_t b0,
int  is_ip6 
)
static

Definition at line 750 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip46_set_src_address()

static bool ip46_set_src_address ( u32  sw_if_index,
vlib_buffer_t b0,
int  is_ip6 
)
static

Definition at line 730 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ip4_icmp_compute_checksum()

u16 ip4_icmp_compute_checksum ( vlib_main_t vm,
vlib_buffer_t p0,
ip4_header_t ip0 
)

Definition at line 792 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 326 of file ping.c.

+ Here is the call graph for this function:

◆ ip4_icmp_echo_request()

static uword ip4_icmp_echo_request ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 370 of file ping.c.

+ Here is the call graph for this function:

◆ 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 
)
static

Definition at line 334 of file ping.c.

+ Here is the call graph for this function:

◆ ping_cli_init()

static clib_error_t* ping_cli_init ( vlib_main_t vm)
static

Definition at line 1449 of file ping.c.

+ Here is the call graph for this function:

◆ ping_ip_address()

static clib_error_t* ping_ip_address ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1202 of file ping.c.

+ Here is the call graph for this function:

◆ print_ip46_icmp_reply()

static void print_ip46_icmp_reply ( vlib_main_t vm,
u32  bi0,
int  is_ip6 
)
static

Definition at line 1043 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 1094 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 950 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 1031 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 
)
static

Definition at line 1019 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 at line 124 of file ping.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VLIB_PLUGIN_REGISTER()

VLIB_PLUGIN_REGISTER ( )

Variable Documentation

◆ ip4_icmp_echo_reply_node

vlib_node_registration_t ip4_icmp_echo_reply_node
static
Initial value:
=
{
.name = "ip4-icmp-echo-reply",
.vector_size = sizeof (u32),
.format_trace = format_icmp_echo_trace,
.n_next_nodes = ICMP46_ECHO_REPLY_N_NEXT,
.next_nodes = {
},
}

(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node)

Definition at line 355 of file ping.c.

◆ ip4_icmp_echo_request_node

vlib_node_registration_t ip4_icmp_echo_request_node
static
Initial value:
= {
.function = ip4_icmp_echo_request,
.name = "ip4-icmp-echo-request",
.vector_size = sizeof (u32),
.format_trace = format_icmp_input_trace,
.n_next_nodes = 1,
.next_nodes = {
[0] = "ip4-load-balance",
},
}

(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_request_node)

Definition at line 563 of file ping.c.

◆ ip6_icmp_echo_reply_node

vlib_node_registration_t ip6_icmp_echo_reply_node
static
Initial value:
=
{
.name = "ip6-icmp-echo-reply",
.vector_size = sizeof (u32),
.format_trace = format_icmp_echo_trace,
.n_next_nodes = ICMP46_ECHO_REPLY_N_NEXT,
.next_nodes = {
},
}

(constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node)

Definition at line 342 of file ping.c.

◆ ping_command

vlib_cli_command_t ping_command
static
Initial value:
=
{
.path = "ping",
.function = ping_ip_address,
.short_help = "ping {<ip-addr> | ipv4 <ip4-addr> | ipv6 <ip6-addr>}"
" [ipv4 <ip4-addr> | ipv6 <ip6-addr>] [source <interface>]"
" [size <pktsize:60>] [interval <sec:1>] [repeat <cnt:5>] [table-id <id:0>]"
" [burst <count:1>] [verbose]",
.is_mp_safe = 1,
}

(constructor) VLIB_CLI_COMMAND (ping_command)

Definition at line 1436 of file ping.c.

◆ ping_main

ping_main_t ping_main

Definition at line 30 of file ping.c.

ICMP46_ECHO_REPLY_NEXT_DROP
@ ICMP46_ECHO_REPLY_NEXT_DROP
Definition: ping.h:86
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
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
ICMP46_ECHO_REPLY_NEXT_PUNT
@ ICMP46_ECHO_REPLY_NEXT_PUNT
Definition: ping.h:87
format_icmp_echo_trace
u8 * format_icmp_echo_trace(u8 *s, va_list *va)
Definition: ping.c:51
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
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
ICMP46_ECHO_REPLY_N_NEXT
@ ICMP46_ECHO_REPLY_N_NEXT
Definition: ping.h:88
u32
unsigned int u32
Definition: types.h:88
format_icmp_input_trace
static u8 * format_icmp_input_trace(u8 *s, va_list *va)
Definition: ping.c:550