FD.io VPP  v21.01.1
Vector Packet Processing
in2out.c File Reference

NAT44 inside to outside network translation. More...

+ Include dependency graph for in2out.c:

Go to the source code of this file.

Data Structures

struct  snat_in2out_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 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, u32 thread_index)
 
static int nat_not_translate_output_feature (snat_main_t *sm, ip4_header_t *ip0, u32 proto0, u16 src_port, u16 dst_port, u32 thread_index, u32 sw_if_index)
 
int nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t *kv, void *arg)
 
static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t i2o_addr, u16 i2o_port, u32 rx_fib_index0, nat_protocol_t nat_proto, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next0, u32 thread_index, f64 now)
 
static_always_inline snat_in2out_error_t icmp_get_key (vlib_buffer_t *b, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, nat_protocol_t *nat_proto)
 
u32 icmp_match_in2out_slow (snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet 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, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation. More...
 
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 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 int nat_in2out_sm_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, int is_output_feature)
 
VLIB_NODE_FN() snat_in2out_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() snat_in2out_output_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() snat_in2out_slowpath_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() snat_in2out_output_slowpath_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() snat_in2out_fast_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 

Variables

static char * snat_in2out_error_strings []
 
vlib_node_registration_t snat_in2out_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_node) More...
 
vlib_node_registration_t snat_in2out_output_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_output_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_output_slowpath_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_output_slowpath_node) More...
 
vlib_node_registration_t snat_in2out_fast_node
 (constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node) More...
 

Detailed Description

NAT44 inside to outside network translation.

Definition in file in2out.c.

Macro Definition Documentation

◆ foreach_snat_in2out_error

#define foreach_snat_in2out_error
Value:
_(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_(OUT_OF_PORTS, "out of ports") \
_(BAD_OUTSIDE_FIB, "outside VRF ID not found") \
_(BAD_ICMP_TYPE, "unsupported ICMP type") \
_(NO_TRANSLATION, "no translation") \
_(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
_(CANNOT_CREATE_USER, "cannot create NAT user")

Definition at line 82 of file in2out.c.

Enumeration Type Documentation

◆ snat_in2out_error_t

Enumerator
SNAT_IN2OUT_N_ERROR 

Definition at line 91 of file in2out.c.

◆ snat_in2out_next_t

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 105 of file in2out.c.

Function Documentation

◆ format_snat_in2out_fast_trace()

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

Definition at line 70 of file in2out.c.

◆ format_snat_in2out_trace()

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

Definition at line 50 of file in2out.c.

◆ icmp_get_key()

static_always_inline snat_in2out_error_t icmp_get_key ( vlib_buffer_t b,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
nat_protocol_t nat_proto 
)

Definition at line 394 of file in2out.c.

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

◆ icmp_in2out()

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 
)

Definition at line 642 of file in2out.c.

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

◆ icmp_in2out_slow_path()

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 802 of file in2out.c.

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

◆ icmp_match_in2out_fast()

u32 icmp_match_in2out_fast ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

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
[in,out]ip0ip header
[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 572 of file in2out.c.

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

◆ icmp_match_in2out_slow()

u32 icmp_match_in2out_slow ( snat_main_t sm,
vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t addr,
u16 port,
u32 fib_index,
nat_protocol_t proto,
void *  d,
void *  e,
u8 dont_translate 
)

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
[in,out]ip0ip header
[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 453 of file in2out.c.

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

◆ nat44_i2o_is_idle_session_cb()

int nat44_i2o_is_idle_session_cb ( clib_bihash_kv_8_8_t kv,
void *  arg 
)

Definition at line 188 of file in2out.c.

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

◆ nat_in2out_sm_unknown_proto()

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

Definition at line 830 of file in2out.c.

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

◆ nat_not_translate_output_feature()

static int nat_not_translate_output_feature ( snat_main_t sm,
ip4_header_t ip0,
u32  proto0,
u16  src_port,
u16  dst_port,
u32  thread_index,
u32  sw_if_index 
)
inlinestatic

Definition at line 151 of file in2out.c.

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

◆ slow_path()

static u32 slow_path ( snat_main_t sm,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t  i2o_addr,
u16  i2o_port,
u32  rx_fib_index0,
nat_protocol_t  nat_proto,
snat_session_t **  sessionp,
vlib_node_runtime_t node,
u32  next0,
u32  thread_index,
f64  now 
)
static

Definition at line 236 of file in2out.c.

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

◆ snat_in2out_fast_node()

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

Definition at line 1761 of file in2out.c.

+ Here is the call graph for this function:

◆ snat_in2out_node()

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

Definition at line 1633 of file in2out.c.

+ Here is the call graph for this function:

◆ snat_in2out_node_fn_inline()

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

Definition at line 863 of file in2out.c.

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

◆ snat_in2out_output_node()

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

Definition at line 1665 of file in2out.c.

+ Here is the call graph for this function:

◆ snat_in2out_output_slowpath_node()

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

Definition at line 1729 of file in2out.c.

+ Here is the call graph for this function:

◆ snat_in2out_slowpath_node()

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

Definition at line 1697 of file in2out.c.

+ Here is the call graph for this function:

◆ snat_not_translate()

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,
u32  thread_index 
)
inlinestatic

Definition at line 115 of file in2out.c.

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

Variable Documentation

◆ snat_in2out_error_strings

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

Definition at line 99 of file in2out.c.

◆ snat_in2out_fast_node

vlib_node_registration_t snat_in2out_fast_node
Initial value:
= {
.name = "nat44-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] = "nat44-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:70
static char * snat_in2out_error_strings[]
Definition: in2out.c:99
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:67

(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)

Definition at line 1951 of file in2out.c.

◆ snat_in2out_node

vlib_node_registration_t snat_in2out_node
Initial value:
= {
.name = "nat44-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] = "nat44-in2out-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:50
static char * snat_in2out_error_strings[]
Definition: in2out.c:99
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:67

(constructor) VLIB_REGISTER_NODE (snat_in2out_node)

Definition at line 1642 of file in2out.c.

◆ snat_in2out_output_node

vlib_node_registration_t snat_in2out_output_node
Initial value:
= {
.name = "nat44-in2out-output",
.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] = "interface-output",
[SNAT_IN2OUT_NEXT_SLOW_PATH] = "nat44-in2out-output-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:50
static char * snat_in2out_error_strings[]
Definition: in2out.c:99
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:67

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)

Definition at line 1674 of file in2out.c.

◆ snat_in2out_output_slowpath_node

vlib_node_registration_t snat_in2out_output_slowpath_node
Initial value:
= {
.name = "nat44-in2out-output-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] = "interface-output",
[SNAT_IN2OUT_NEXT_SLOW_PATH] = "nat44-in2out-output-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:50
static char * snat_in2out_error_strings[]
Definition: in2out.c:99
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:67

(constructor) VLIB_REGISTER_NODE (snat_in2out_output_slowpath_node)

Definition at line 1738 of file in2out.c.

◆ snat_in2out_slowpath_node

vlib_node_registration_t snat_in2out_slowpath_node
Initial value:
= {
.name = "nat44-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] = "nat44-in2out-slowpath",
[SNAT_IN2OUT_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}
static u8 * format_snat_in2out_trace(u8 *s, va_list *args)
Definition: in2out.c:50
static char * snat_in2out_error_strings[]
Definition: in2out.c:99
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:67

(constructor) VLIB_REGISTER_NODE (snat_in2out_slowpath_node)

Definition at line 1706 of file in2out.c.