FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
nat44_ed_in2out.c File Reference

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

+ Include dependency graph for nat44_ed_in2out.c:

Go to the source code of this file.

Data Structures

struct  nat_in2out_ed_trace_t
 

Macros

#define ED_PORT_ALLOC_ATTEMPTS   (10)
 

Functions

static u8format_nat_in2out_ed_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 nat_ed_alloc_addr_and_port_with_snat_address (snat_main_t *sm, u32 nat_proto, u32 thread_index, snat_address_t *a, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
 
static int nat_ed_alloc_addr_and_port (snat_main_t *sm, u32 rx_fib_index, u32 nat_proto, u32 thread_index, ip4_address_t s_addr, u16 port_per_thread, u32 snat_thread_index, snat_session_t *s, ip4_address_t *outside_addr, u16 *outside_port)
 
static_always_inline u32 nat_outside_fib_index_lookup (snat_main_t *sm, ip4_address_t addr)
 
static_always_inline int nat44_ed_external_sm_lookup (snat_main_t *sm, ip4_address_t match_addr, u16 match_port, nat_protocol_t match_protocol, u32 match_fib_index, ip4_address_t *daddr, u16 *dport)
 
static u32 slow_path_ed (vlib_main_t *vm, snat_main_t *sm, vlib_buffer_t *b, ip4_address_t l_addr, ip4_address_t r_addr, u16 l_port, u16 r_port, u8 proto, u32 rx_fib_index, snat_session_t **sessionp, vlib_node_runtime_t *node, u32 next, u32 thread_index, f64 now)
 
static_always_inline int nat44_ed_not_translate (vlib_main_t *vm, snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index, vlib_buffer_t *b, ip4_header_t *ip, u32 proto, u32 rx_fib_index, u32 thread_index)
 
static_always_inline int nat_not_translate_output_feature_fwd (snat_main_t *sm, ip4_header_t *ip, u32 thread_index, f64 now, vlib_main_t *vm, vlib_buffer_t *b)
 
static_always_inline int nat44_ed_not_translate_output_feature (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u16 src_port, u16 dst_port, u32 thread_index, u32 rx_sw_if_index, u32 tx_sw_if_index, f64 now, int is_multi_worker)
 
static u32 icmp_in2out_ed_slow_path (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, icmp46_header_t *icmp, u32 sw_if_index, u32 rx_fib_index, vlib_node_runtime_t *node, u32 next, f64 now, u32 thread_index, nat_protocol_t nat_proto, snat_session_t **s_p, int is_multi_worker)
 
static snat_session_t * nat44_ed_in2out_slowpath_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index, f64 now, vlib_main_t *vm, vlib_node_runtime_t *node)
 
static uword nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature, int is_multi_worker)
 
static uword nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_output_feature, int is_multi_worker)
 
VLIB_NODE_FN() nat44_ed_in2out_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() nat44_ed_in2out_output_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() nat44_ed_in2out_slowpath_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
VLIB_NODE_FN() nat44_ed_in2out_output_slowpath_node (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static u8format_nat_pre_trace (u8 *s, va_list *args)
 

Variables

static char * nat_in2out_ed_error_strings []
 
vlib_node_registration_t nat44_ed_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node) More...
 
vlib_node_registration_t nat44_ed_in2out_output_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node) More...
 
vlib_node_registration_t nat44_ed_in2out_slowpath_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node) More...
 
vlib_node_registration_t nat44_ed_in2out_output_slowpath_node
 (constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node) More...
 
vlib_main_tvm
 
vlib_main_t vlib_node_runtime_tnode
 
vlib_main_t vlib_node_runtime_t vlib_frame_tframe
 
vlib_node_registration_t nat_pre_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node) More...
 
vlib_node_registration_t nat_pre_in2out_output_node
 (constructor) VLIB_REGISTER_NODE (nat_pre_in2out_output_node) More...
 

Detailed Description

NAT44 endpoint-dependent inside to outside network translation.

Definition in file nat44_ed_in2out.c.

Macro Definition Documentation

◆ ED_PORT_ALLOC_ATTEMPTS

#define ED_PORT_ALLOC_ATTEMPTS   (10)

Definition at line 38 of file nat44_ed_in2out.c.

Function Documentation

◆ format_nat_in2out_ed_trace()

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

Definition at line 61 of file nat44_ed_in2out.c.

◆ format_nat_pre_trace()

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

Definition at line 1601 of file nat44_ed_in2out.c.

◆ icmp_in2out_ed_slow_path()

static u32 icmp_in2out_ed_slow_path ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip,
icmp46_header_t *  icmp,
u32  sw_if_index,
u32  rx_fib_index,
vlib_node_runtime_t node,
u32  next,
f64  now,
u32  thread_index,
nat_protocol_t  nat_proto,
snat_session_t **  s_p,
int  is_multi_worker 
)
inlinestatic

Definition at line 737 of file nat44_ed_in2out.c.

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

◆ nat44_ed_external_sm_lookup()

static_always_inline int nat44_ed_external_sm_lookup ( snat_main_t sm,
ip4_address_t  match_addr,
u16  match_port,
nat_protocol_t  match_protocol,
u32  match_fib_index,
ip4_address_t daddr,
u16 dport 
)

Definition at line 307 of file nat44_ed_in2out.c.

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

◆ nat44_ed_in2out_fast_path_node_fn_inline()

static uword nat44_ed_in2out_fast_path_node_fn_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  is_output_feature,
int  is_multi_worker 
)
inlinestatic

Definition at line 969 of file nat44_ed_in2out.c.

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

◆ nat44_ed_in2out_node()

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

Definition at line 1499 of file nat44_ed_in2out.c.

+ Here is the call graph for this function:

◆ nat44_ed_in2out_output_node()

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

Definition at line 1524 of file nat44_ed_in2out.c.

+ Here is the call graph for this function:

◆ nat44_ed_in2out_output_slowpath_node()

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

Definition at line 1574 of file nat44_ed_in2out.c.

+ Here is the call graph for this function:

◆ nat44_ed_in2out_slow_path_node_fn_inline()

static uword nat44_ed_in2out_slow_path_node_fn_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame,
int  is_output_feature,
int  is_multi_worker 
)
inlinestatic

Definition at line 1266 of file nat44_ed_in2out.c.

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

◆ nat44_ed_in2out_slowpath_node()

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

Definition at line 1549 of file nat44_ed_in2out.c.

+ Here is the call graph for this function:

◆ nat44_ed_in2out_slowpath_unknown_proto()

static snat_session_t* nat44_ed_in2out_slowpath_unknown_proto ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip,
u32  rx_fib_index,
u32  thread_index,
f64  now,
vlib_main_t vm,
vlib_node_runtime_t node 
)
static

Definition at line 821 of file nat44_ed_in2out.c.

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

◆ nat44_ed_not_translate()

static_always_inline int nat44_ed_not_translate ( vlib_main_t vm,
snat_main_t sm,
vlib_node_runtime_t node,
u32  sw_if_index,
vlib_buffer_t b,
ip4_header_t ip,
u32  proto,
u32  rx_fib_index,
u32  thread_index 
)

Definition at line 560 of file nat44_ed_in2out.c.

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

◆ nat44_ed_not_translate_output_feature()

static_always_inline int nat44_ed_not_translate_output_feature ( snat_main_t sm,
vlib_buffer_t b,
ip4_header_t ip,
u16  src_port,
u16  dst_port,
u32  thread_index,
u32  rx_sw_if_index,
u32  tx_sw_if_index,
f64  now,
int  is_multi_worker 
)

Definition at line 659 of file nat44_ed_in2out.c.

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

◆ nat_ed_alloc_addr_and_port()

static int nat_ed_alloc_addr_and_port ( snat_main_t sm,
u32  rx_fib_index,
u32  nat_proto,
u32  thread_index,
ip4_address_t  s_addr,
u16  port_per_thread,
u32  snat_thread_index,
snat_session_t *  s,
ip4_address_t outside_addr,
u16 outside_port 
)
static

Definition at line 225 of file nat44_ed_in2out.c.

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

◆ nat_ed_alloc_addr_and_port_with_snat_address()

static int nat_ed_alloc_addr_and_port_with_snat_address ( snat_main_t sm,
u32  nat_proto,
u32  thread_index,
snat_address_t a,
u16  port_per_thread,
u32  snat_thread_index,
snat_session_t *  s,
ip4_address_t outside_addr,
u16 outside_port 
)
static

Definition at line 169 of file nat44_ed_in2out.c.

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

◆ nat_not_translate_output_feature_fwd()

static_always_inline int nat_not_translate_output_feature_fwd ( snat_main_t sm,
ip4_header_t ip,
u32  thread_index,
f64  now,
vlib_main_t vm,
vlib_buffer_t b 
)

Definition at line 595 of file nat44_ed_in2out.c.

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

◆ nat_outside_fib_index_lookup()

static_always_inline u32 nat_outside_fib_index_lookup ( snat_main_t sm,
ip4_address_t  addr 
)

Definition at line 281 of file nat44_ed_in2out.c.

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

◆ slow_path_ed()

static u32 slow_path_ed ( vlib_main_t vm,
snat_main_t sm,
vlib_buffer_t b,
ip4_address_t  l_addr,
ip4_address_t  r_addr,
u16  l_port,
u16  r_port,
u8  proto,
u32  rx_fib_index,
snat_session_t **  sessionp,
vlib_node_runtime_t node,
u32  next,
u32  thread_index,
f64  now 
)
static

Definition at line 335 of file nat44_ed_in2out.c.

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

◆ snat_not_translate_fast()

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 address with active session should be translated.

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

Definition at line 115 of file nat44_ed_in2out.c.

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

Variable Documentation

◆ frame

◆ nat44_ed_in2out_node

vlib_node_registration_t nat44_ed_in2out_node
Initial value:
= {
.name = "nat44-ed-in2out",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_in2out_ed_trace,
.error_strings = nat_in2out_ed_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
}

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)

Definition at line 1513 of file nat44_ed_in2out.c.

◆ nat44_ed_in2out_output_node

vlib_node_registration_t nat44_ed_in2out_output_node
Initial value:
= {
.name = "nat44-ed-in2out-output",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_in2out_ed_trace,
.error_strings = nat_in2out_ed_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
}

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)

Definition at line 1538 of file nat44_ed_in2out.c.

◆ nat44_ed_in2out_output_slowpath_node

vlib_node_registration_t nat44_ed_in2out_output_slowpath_node
Initial value:
= {
.name = "nat44-ed-in2out-output-slowpath",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_in2out_ed_trace,
.error_strings = nat_in2out_ed_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
}

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_slowpath_node)

Definition at line 1589 of file nat44_ed_in2out.c.

◆ nat44_ed_in2out_slowpath_node

vlib_node_registration_t nat44_ed_in2out_slowpath_node
Initial value:
= {
.name = "nat44-ed-in2out-slowpath",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_in2out_ed_trace,
.error_strings = nat_in2out_ed_error_strings,
.runtime_data_bytes = sizeof (snat_runtime_t),
}

(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_slowpath_node)

Definition at line 1563 of file nat44_ed_in2out.c.

◆ nat_in2out_ed_error_strings

char* nat_in2out_ed_error_strings[]
static
Initial value:
= {
#define _(sym,string)
}

Definition at line 40 of file nat44_ed_in2out.c.

◆ nat_pre_in2out_node

vlib_node_registration_t nat_pre_in2out_node
Initial value:
= {
.name = "nat-pre-in2out",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_pre_trace,
.n_errors = 0,
}

(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)

Definition at line 1624 of file nat44_ed_in2out.c.

◆ nat_pre_in2out_output_node

vlib_node_registration_t nat_pre_in2out_output_node
Initial value:
= {
.name = "nat-pre-in2out-output",
.vector_size = sizeof (u32),
.sibling_of = "nat-default",
.format_trace = format_nat_pre_trace,
.n_errors = 0,
}

(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_output_node)

Definition at line 1633 of file nat44_ed_in2out.c.

◆ node

Definition at line 1611 of file nat44_ed_in2out.c.

◆ vm

Definition at line 1611 of file nat44_ed_in2out.c.

VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
format_nat_in2out_ed_trace
static u8 * format_nat_in2out_ed_trace(u8 *s, va_list *args)
Definition: nat44_ed_in2out.c:61
NAT_NEXT_IN2OUT_ED_FAST_PATH
@ NAT_NEXT_IN2OUT_ED_FAST_PATH
Definition: nat44_ed.h:77
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
nat_pre_node_fn_inline
static uword nat_pre_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 def_next)
Definition: nat44_ed_inlines.h:607
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ed_in2out.c:1612
foreach_nat_in2out_ed_error
#define foreach_nat_in2out_ed_error
Definition: nat44_ed.h:127
format_nat_pre_trace
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
Definition: nat44_ed_in2out.c:1601
u32
unsigned int u32
Definition: types.h:88
snat_runtime_t
Definition: nat44_ed.h:683
nat_in2out_ed_error_strings
static char * nat_in2out_ed_error_strings[]
Definition: nat44_ed_in2out.c:40
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ed_in2out.c:1611
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vm
vlib_main_t * vm
Definition: nat44_ed_in2out.c:1611