FD.io VPP  v20.09-64-g4f7b92f0a
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 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)
 
 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 948 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 868 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 147 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 50 of file ping.c.

+ Here is the call graph for this function:

◆ format_icmp_input_trace()

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

Definition at line 549 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 73 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 102 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 587 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 594 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 218 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 874 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 652 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 684 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 661 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 772 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 695 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 838 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 165 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 670 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 235 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 312 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 197 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 751 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 729 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 793 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 325 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 369 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 333 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 1451 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 1204 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 1045 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 1096 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 951 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 1033 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 1021 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 123 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 = {
},
}
u8 * format_icmp_echo_trace(u8 *s, va_list *va)
Definition: ping.c:50
static uword ip4_icmp_echo_reply_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:325
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_reply_node)

Definition at line 354 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",
},
}
unsigned int u32
Definition: types.h:88
static uword ip4_icmp_echo_request(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ping.c:369
static u8 * format_icmp_input_trace(u8 *s, va_list *va)
Definition: ping.c:549

(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_request_node)

Definition at line 562 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:50
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:333

(constructor) VLIB_REGISTER_NODE (ip6_icmp_echo_reply_node)

Definition at line 341 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,
}
static clib_error_t * ping_ip_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ping.c:1204

(constructor) VLIB_CLI_COMMAND (ping_command)

Definition at line 1438 of file ping.c.

◆ ping_main

ping_main_t ping_main

Definition at line 29 of file ping.c.