FD.io VPP  v19.01.3-6-g70449b9b9
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_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 int 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)
 

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_cli_command_t ping_command
 (constructor) VLIB_CLI_COMMAND (ping_command) More...
 

Detailed Description

IPv4 and IPv6 ICMP Ping.

This file contains code to suppport 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 735 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 657 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 141 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 44 of file ping.c.

+ Here is the call graph for this function:

◆ format_ip46_ping_result()

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

Definition at line 67 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 96 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 373 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 380 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 212 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 663 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 438 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 470 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 447 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 561 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 481 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 627 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 159 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 456 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 229 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 306 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 191 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 540 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 int ip46_set_src_address ( u32  sw_if_index,
vlib_buffer_t b0,
int  is_ip6 
)
static

Definition at line 515 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 582 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 319 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 327 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 1241 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 994 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 835 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 886 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 738 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 823 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 811 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 117 of file ping.c.

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

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 = {
},
}
u8 * format_icmp_echo_trace(u8 *s, va_list *va)
Definition: ping.c:44
static uword ip4_icmp_echo_reply_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:319
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node)

Definition at line 348 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 = {
},
}
u8 * format_icmp_echo_trace(u8 *s, va_list *va)
Definition: ping.c:44
unsigned int u32
Definition: types.h:88
static uword ip6_icmp_echo_reply_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:327

(constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node)

Definition at line 335 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>] [interval <sec>] [repeat <cnt>] [table-id <id>]"
" [verbose]",
.is_mp_safe = 1,
}
static clib_error_t * ping_ip_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ping.c:994

(constructor) VLIB_CLI_COMMAND (ping_command)

Definition at line 1228 of file ping.c.

◆ ping_main

ping_main_t ping_main

Definition at line 23 of file ping.c.