FD.io VPP  v17.07-30-g839fa73
Vector Packet Processing
in2out.c File Reference
+ Include dependency graph for in2out.c:

Go to the source code of this file.

Data Structures

struct  snat_in2out_trace_t
 
struct  snat_in2out_worker_handoff_trace_t
 

Macros

#define foreach_snat_in2out_error
 

Enumerations

enum  snat_in2out_error_t { SNAT_IN2OUT_N_ERROR }
 
enum  snat_in2out_next_t {
  SNAT_IN2OUT_NEXT_LOOKUP, SNAT_IN2OUT_NEXT_DROP, SNAT_IN2OUT_NEXT_ICMP_ERROR, SNAT_IN2OUT_NEXT_SLOW_PATH,
  SNAT_IN2OUT_N_NEXT
}
 

Functions

static u8format_snat_in2out_trace (u8 *s, va_list *args)
 
static u8format_snat_in2out_fast_trace (u8 *s, va_list *args)
 
static u8format_snat_in2out_worker_handoff_trace (u8 *s, va_list *args)
 
static int snat_not_translate_fast (snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, ip4_header_t *ip0, u32 proto0, u32 rx_fib_index0)
 Check if packet should be translated. More...
 
static int snat_not_translate (snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, ip4_header_t *ip0, u32 proto0, u32 rx_fib_index0)
 
static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, u32 rx_fib_index0, snat_session_key_t *key0, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index)
 
static_always_inline snat_in2out_error_t icmp_get_key (ip4_header_t *ip0, snat_session_key_t *p_key0)
 
u32 icmp_match_in2out_slow (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for packet SNAT translation and create session if needed. More...
 
u32 icmp_match_in2out_fast (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for packet SNAT translation. More...
 
static u32 icmp_in2out (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
 
static void snat_hairpinning (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0)
 Hairpinning. More...
 
static u32 icmp_in2out_slow_path (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, f64 now, u32 thread_index, snat_session_t **p_s0)
 
static void snat_in2out_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index)
 
static uword snat_in2out_node_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_slow_path)
 
static uword snat_in2out_fast_path_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_node, snat_in2out_fast_path_fn)
 
static uword snat_in2out_slow_path_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_slowpath_node, snat_in2out_slow_path_fn)
 
static uword snat_det_in2out_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (snat_det_in2out_node, snat_det_in2out_node_fn)
 
u32 icmp_match_in2out_det (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
 Get address and port values to be used for packet SNAT translation and create session if needed. More...
 
static uword snat_in2out_worker_handoff_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_worker_handoff_node, snat_in2out_worker_handoff_fn)
 
static uword snat_in2out_fast_static_map_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_fast_node, snat_in2out_fast_static_map_fn)
 

Variables

vlib_node_registration_t snat_in2out_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_node) More...
 
vlib_node_registration_t snat_in2out_slowpath_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_slowpath_node) More...
 
vlib_node_registration_t snat_in2out_fast_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node) More...
 
vlib_node_registration_t snat_in2out_worker_handoff_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node) More...
 
vlib_node_registration_t snat_det_in2out_node
 (constructor) VLIB_REGISTER_NODE (snat_det_in2out_node) More...
 
static char * snat_in2out_error_strings []
 

Macro Definition Documentation

#define foreach_snat_in2out_error
Value:
_(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \
_(IN2OUT_PACKETS, "Good in2out packets processed") \
_(OUT_OF_PORTS, "Out of ports") \
_(BAD_OUTSIDE_FIB, "Outside VRF ID not found") \
_(BAD_ICMP_TYPE, "unsupported ICMP type") \
_(NO_TRANSLATION, "No translation")

Definition at line 92 of file in2out.c.

Enumeration Type Documentation

Enumerator
SNAT_IN2OUT_N_ERROR 

Definition at line 100 of file in2out.c.

Enumerator
SNAT_IN2OUT_NEXT_LOOKUP 
SNAT_IN2OUT_NEXT_DROP 
SNAT_IN2OUT_NEXT_ICMP_ERROR 
SNAT_IN2OUT_NEXT_SLOW_PATH 
SNAT_IN2OUT_N_NEXT 

Definition at line 113 of file in2out.c.

Function Documentation

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

Definition at line 60 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 45 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 72 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Definition at line 419 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 icmp_in2out ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
icmp46_header_t *  icmp0,
u32  sw_if_index0,
u32  rx_fib_index0,
vlib_node_runtime_t node,
u32  next0,
u32  thread_index,
void *  d,
void *  e 
)
inlinestatic

Definition at line 636 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 icmp_in2out_slow_path ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
icmp46_header_t *  icmp0,
u32  sw_if_index0,
u32  rx_fib_index0,
vlib_node_runtime_t node,
u32  next0,
f64  now,
u32  thread_index,
snat_session_t **  p_s0 
)
inlinestatic

Definition at line 870 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 icmp_match_in2out_det ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

Get address and port values to be used for packet SNAT translation and create session if needed.

Parameters
[in,out]smSNAT main
[in,out]nodeSNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 2251 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 icmp_match_in2out_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

Get address and port values to be used for packet SNAT translation.

Parameters
[in]smSNAT main
[in,out]nodeSNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 569 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 icmp_match_in2out_slow ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
u8 p_proto,
snat_session_key_t p_value,
u8 p_dont_translate,
void *  d,
void *  e 
)

Get address and port values to be used for packet SNAT translation and create session if needed.

Parameters
[in,out]smSNAT main
[in,out]nodeSNAT node runtime
[in]thread_indexthread index
[in,out]b0buffer containing packet to be translated
[out]p_protoprotocol used for matching
[out]p_valueaddress and port after NAT translation
[out]p_dont_translateif packet should not be translated
doptional parameter
eoptional parameter

Definition at line 477 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 slow_path ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
u32  rx_fib_index0,
snat_session_key_t key0,
snat_session_t **  sessionp,
vlib_node_runtime_t node,
u32  next0,
u32  thread_index 
)
static

Definition at line 207 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1642 of file in2out.c.

+ Here is the call graph for this function:

static void snat_hairpinning ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
udp_header_t udp0,
tcp_header_t tcp0,
u32  proto0 
)
inlinestatic

Hairpinning.

Hairpinning allows two endpoints on the internal side of the NAT to communicate even if they only use each other's external IP addresses and ports.

Parameters
smSNAT main.
b0Vlib buffer.
ip0IP header.
udp0UDP header.
tcp0TCP header.
proto0SNAT protocol.

Definition at line 773 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1573 of file in2out.c.

+ Here is the call graph for this function:

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

Definition at line 2559 of file in2out.c.

+ Here is the call graph for this function:

static uword snat_in2out_node_fn_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  is_slow_path 
)
inlinestatic

Definition at line 1020 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1606 of file in2out.c.

+ Here is the call graph for this function:

static void snat_in2out_unknown_proto ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip,
u32  rx_fib_index 
)
static

Definition at line 971 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2399 of file in2out.c.

+ Here is the call graph for this function:

static int snat_not_translate ( snat_main_t sm,
vlib_node_runtime_t node,
u32  sw_if_index0,
ip4_header_t ip0,
u32  proto0,
u32  rx_fib_index0 
)
inlinestatic

Definition at line 178 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int snat_not_translate_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  sw_if_index0,
ip4_header_t ip0,
u32  proto0,
u32  rx_fib_index0 
)
inlinestatic

Check if packet should be translated.

Packets aimed at outside interface and external addresss with active session should be translated.

Parameters
smSNAT main
rtSNAT runtime data
sw_if_index0index of the inside interface
ip0IPv4 header
proto0SNAT protocol
rx_fib_index0RX FIB index
Returns
0 if packet should be translated otherwise 1

Definition at line 137 of file in2out.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VLIB_NODE_FUNCTION_MULTIARCH ( snat_in2out_node  ,
snat_in2out_fast_path_fn   
)

+ Here is the caller graph for this function:

VLIB_NODE_FUNCTION_MULTIARCH ( snat_in2out_slowpath_node  ,
snat_in2out_slow_path_fn   
)
VLIB_NODE_FUNCTION_MULTIARCH ( snat_det_in2out_node  ,
snat_det_in2out_node_fn   
)
VLIB_NODE_FUNCTION_MULTIARCH ( snat_in2out_worker_handoff_node  ,
snat_in2out_worker_handoff_fn   
)
VLIB_NODE_FUNCTION_MULTIARCH ( snat_in2out_fast_node  ,
snat_in2out_fast_static_map_fn   
)

Variable Documentation

vlib_node_registration_t snat_det_in2out_node
Initial value:
= {
.name = "snat-det-in2out",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
.error_strings = snat_in2out_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = 3,
.next_nodes = {
[SNAT_IN2OUT_NEXT_DROP] = "error-drop",
[SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:45
static char * snat_in2out_error_strings[]
Definition: in2out.c:107
static uword snat_det_in2out_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: in2out.c:1642
#define ARRAY_LEN(x)
Definition: clib.h:59
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)

Definition at line 90 of file in2out.c.

char* snat_in2out_error_strings[]
static
Initial value:
= {
#define _(sym,string)
}
#define foreach_snat_in2out_error
Definition: in2out.c:92

Definition at line 107 of file in2out.c.

vlib_node_registration_t snat_in2out_fast_node
Initial value:
= {
.name = "snat-in2out-fast",
.vector_size = sizeof (u32),
.error_strings = snat_in2out_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_IN2OUT_N_NEXT,
.next_nodes = {
[SNAT_IN2OUT_NEXT_DROP] = "error-drop",
[SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_IN2OUT_NEXT_SLOW_PATH] = "snat-in2out-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_fast_trace(u8 *s, va_list *args)
Definition: in2out.c:60
static char * snat_in2out_error_strings[]
Definition: in2out.c:107
static uword snat_in2out_fast_static_map_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: in2out.c:2559
#define ARRAY_LEN(x)
Definition: clib.h:59
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)

Definition at line 88 of file in2out.c.

vlib_node_registration_t snat_in2out_node
Initial value:
= {
.name = "snat-in2out",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
.error_strings = snat_in2out_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_IN2OUT_N_NEXT,
.next_nodes = {
[SNAT_IN2OUT_NEXT_DROP] = "error-drop",
[SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_IN2OUT_NEXT_SLOW_PATH] = "snat-in2out-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:45
static char * snat_in2out_error_strings[]
Definition: in2out.c:107
#define ARRAY_LEN(x)
Definition: clib.h:59
unsigned int u32
Definition: types.h:88
static uword snat_in2out_fast_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: in2out.c:1573

(constructor) VLIB_REGISTER_NODE (snat_in2out_node)

Definition at line 86 of file in2out.c.

vlib_node_registration_t snat_in2out_slowpath_node
Initial value:
= {
.name = "snat-in2out-slowpath",
.vector_size = sizeof (u32),
.format_trace = format_snat_in2out_trace,
.error_strings = snat_in2out_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_IN2OUT_N_NEXT,
.next_nodes = {
[SNAT_IN2OUT_NEXT_DROP] = "error-drop",
[SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_IN2OUT_NEXT_SLOW_PATH] = "snat-in2out-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:45
static uword snat_in2out_slow_path_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: in2out.c:1606
static char * snat_in2out_error_strings[]
Definition: in2out.c:107
#define ARRAY_LEN(x)
Definition: clib.h:59
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (snat_in2out_slowpath_node)

Definition at line 87 of file in2out.c.

vlib_node_registration_t snat_in2out_worker_handoff_node
Initial value:
= {
.name = "snat-in2out-worker-handoff",
.vector_size = sizeof (u32),
.n_next_nodes = 1,
.next_nodes = {
[0] = "error-drop",
},
}
static uword snat_in2out_worker_handoff_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: in2out.c:2399
static u8 * format_snat_in2out_worker_handoff_trace(u8 *s, va_list *args)
Definition: in2out.c:72
unsigned int u32
Definition: types.h:88

(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)

Definition at line 89 of file in2out.c.