FD.io VPP  v19.08.1-401-g8e4ed521a
Vector Packet Processing
out2in.c File Reference

NAT44 endpoint-dependent outside to inside network translation. More...

+ Include dependency graph for out2in.c:

Go to the source code of this file.

Data Structures

struct  snat_out2in_trace_t
 

Macros

#define foreach_snat_out2in_error
 

Enumerations

enum  snat_out2in_error_t { SNAT_OUT2IN_N_ERROR }
 
enum  snat_out2in_next_t {
  SNAT_OUT2IN_NEXT_DROP, SNAT_OUT2IN_NEXT_LOOKUP, SNAT_OUT2IN_NEXT_ICMP_ERROR, SNAT_OUT2IN_NEXT_REASS,
  SNAT_OUT2IN_N_NEXT
}
 

Functions

static u8format_snat_out2in_trace (u8 *s, va_list *args)
 
static u8format_snat_out2in_fast_trace (u8 *s, va_list *args)
 
int nat44_o2i_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg)
 
static snat_session_t * create_session_for_static_mapping (snat_main_t *sm, vlib_buffer_t *b0, snat_session_key_t in2out, snat_session_key_t out2in, vlib_node_runtime_t *node, u32 thread_index, f64 now)
 Create session for static mapping. More...
 
static_always_inline snat_out2in_error_t icmp_get_key (ip4_header_t *ip0, snat_session_key_t *p_key0)
 
u32 icmp_match_out2in_slow (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, 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 ICMP packet translation and create session if needed. More...
 
u32 icmp_match_out2in_fast (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, 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 ICMP packet translation. More...
 
u32 icmp_out2in (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 u32 icmp_out2in_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 int nat_out2in_sm_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index)
 
VLIB_NODE_FN() snat_out2in_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() nat44_out2in_reass_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() snat_out2in_fast_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 

Variables

static char * snat_out2in_error_strings []
 
vlib_node_registration_t snat_out2in_node
 (constructor) VLIB_REGISTER_NODE (snat_out2in_node) More...
 
vlib_node_registration_t nat44_out2in_reass_node
 (constructor) VLIB_REGISTER_NODE (nat44_out2in_reass_node) More...
 
vlib_node_registration_t snat_out2in_fast_node
 (constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node) More...
 

Detailed Description

NAT44 endpoint-dependent outside to inside network translation.

Definition in file out2in.c.

Macro Definition Documentation

◆ foreach_snat_out2in_error

#define foreach_snat_out2in_error
Value:
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(OUT2IN_PACKETS, "good out2in packets processed") \
_(OUT_OF_PORTS, "out of ports") \
_(BAD_ICMP_TYPE, "unsupported ICMP type") \
_(NO_TRANSLATION, "no translation") \
_(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
_(DROP_FRAGMENT, "drop fragment") \
_(MAX_REASS, "maximum reassemblies exceeded") \
_(MAX_FRAG, "maximum fragments per reassembly exceeded")\
_(TCP_PACKETS, "TCP packets") \
_(UDP_PACKETS, "UDP packets") \
_(ICMP_PACKETS, "ICMP packets") \
_(OTHER_PACKETS, "other protocol packets") \
_(FRAGMENTS, "fragments") \
_(CACHED_FRAGMENTS, "cached fragments") \
_(PROCESSED_FRAGMENTS, "processed fragments")

Definition at line 73 of file out2in.c.

Enumeration Type Documentation

◆ snat_out2in_error_t

Enumerator
SNAT_OUT2IN_N_ERROR 

Definition at line 91 of file out2in.c.

◆ snat_out2in_next_t

Enumerator
SNAT_OUT2IN_NEXT_DROP 
SNAT_OUT2IN_NEXT_LOOKUP 
SNAT_OUT2IN_NEXT_ICMP_ERROR 
SNAT_OUT2IN_NEXT_REASS 
SNAT_OUT2IN_N_NEXT 

Definition at line 105 of file out2in.c.

Function Documentation

◆ create_session_for_static_mapping()

static snat_session_t* create_session_for_static_mapping ( snat_main_t sm,
vlib_buffer_t b0,
snat_session_key_t  in2out,
snat_session_key_t  out2in,
vlib_node_runtime_t node,
u32  thread_index,
f64  now 
)
inlinestatic

Create session for static mapping.

Create NAT session initiated by host from external network with static mapping.

Parameters
smNAT main.
b0Vlib buffer.
in2outIn2out NAT44 session key.
out2inOut2in NAT44 session key.
nodeVlib node.
Returns
SNAT session if successfully created otherwise 0.

Definition at line 178 of file out2in.c.

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

◆ format_snat_out2in_fast_trace()

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

Definition at line 62 of file out2in.c.

+ Here is the call graph for this function:

◆ format_snat_out2in_trace()

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

Definition at line 48 of file out2in.c.

+ Here is the call graph for this function:

◆ icmp_get_key()

Definition at line 266 of file out2in.c.

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

◆ icmp_match_out2in_fast()

u32 icmp_match_out2in_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
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 ICMP packet translation.

Parameters
[in]smNAT main
[in,out]nodeNAT 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 455 of file out2in.c.

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

◆ icmp_match_out2in_slow()

u32 icmp_match_out2in_slow ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
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 ICMP packet translation and create session if needed.

Parameters
[in,out]smNAT main
[in,out]nodeNAT 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 325 of file out2in.c.

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

◆ icmp_out2in()

u32 icmp_out2in ( 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 
)

Definition at line 518 of file out2in.c.

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

◆ icmp_out2in_slow_path()

static u32 icmp_out2in_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 649 of file out2in.c.

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

◆ nat44_o2i_is_idle_session_cb()

int nat44_o2i_is_idle_session_cb ( clib_bihash_kv_8_8_t kv,
void *  arg 
)

Definition at line 116 of file out2in.c.

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

◆ nat44_out2in_reass_node()

VLIB_NODE_FN() nat44_out2in_reass_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 1385 of file out2in.c.

+ Here is the call graph for this function:

◆ nat_out2in_sm_unknown_proto()

static int nat_out2in_sm_unknown_proto ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip,
u32  rx_fib_index 
)
static

Definition at line 675 of file out2in.c.

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

◆ snat_out2in_fast_node()

VLIB_NODE_FN() snat_out2in_fast_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 1722 of file out2in.c.

+ Here is the call graph for this function:

◆ snat_out2in_node()

VLIB_NODE_FN() snat_out2in_node ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)

Definition at line 705 of file out2in.c.

+ Here is the call graph for this function:

Variable Documentation

◆ nat44_out2in_reass_node

vlib_node_registration_t nat44_out2in_reass_node
Initial value:
= {
.name = "nat44-out2in-reass",
.vector_size = sizeof (u32),
.format_trace = format_nat44_reass_trace,
.error_strings = snat_out2in_error_strings,
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
unsigned int u32
Definition: types.h:88
vl_api_fib_path_type_t type
Definition: fib_types.api:123
#define ARRAY_LEN(x)
Definition: clib.h:62
format_function_t format_nat44_reass_trace
Definition: nat.h:701
static char * snat_out2in_error_strings[]
Definition: out2in.c:99

(constructor) VLIB_REGISTER_NODE (nat44_out2in_reass_node)

Definition at line 1701 of file out2in.c.

◆ snat_out2in_error_strings

char* snat_out2in_error_strings[]
static
Initial value:
= {
#define _(sym,string)
}
#define foreach_snat_out2in_error
Definition: out2in.c:73

Definition at line 99 of file out2in.c.

◆ snat_out2in_fast_node

vlib_node_registration_t snat_out2in_fast_node
Initial value:
= {
.name = "nat44-out2in-fast",
.vector_size = sizeof (u32),
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
static u8 * format_snat_out2in_fast_trace(u8 *s, va_list *args)
Definition: out2in.c:62
unsigned int u32
Definition: types.h:88
vl_api_fib_path_type_t type
Definition: fib_types.api:123
#define ARRAY_LEN(x)
Definition: clib.h:62
static char * snat_out2in_error_strings[]
Definition: out2in.c:99

(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)

Definition at line 1900 of file out2in.c.

◆ snat_out2in_node

vlib_node_registration_t snat_out2in_node
Initial value:
= {
.name = "nat44-out2in",
.vector_size = sizeof (u32),
.format_trace = format_snat_out2in_trace,
.error_strings = snat_out2in_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
.n_next_nodes = SNAT_OUT2IN_N_NEXT,
.next_nodes = {
[SNAT_OUT2IN_NEXT_DROP] = "error-drop",
[SNAT_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[SNAT_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
[SNAT_OUT2IN_NEXT_REASS] = "nat44-out2in-reass",
},
}
unsigned int u32
Definition: types.h:88
vl_api_fib_path_type_t type
Definition: fib_types.api:123
#define ARRAY_LEN(x)
Definition: clib.h:62
static char * snat_out2in_error_strings[]
Definition: out2in.c:99
static u8 * format_snat_out2in_trace(u8 *s, va_list *args)
Definition: out2in.c:48

(constructor) VLIB_REGISTER_NODE (snat_out2in_node)

Definition at line 1362 of file out2in.c.