FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
nat44_ei_out2in.c File Reference

NAT44 EI outside to inside network translation. More...

+ Include dependency graph for nat44_ei_out2in.c:

Go to the source code of this file.

Data Structures

struct  nat44_ei_out2in_trace_t
 

Macros

#define foreach_nat44_ei_out2in_error
 

Enumerations

enum  nat44_ei_out2in_error_t { NAT44_EI_OUT2IN_N_ERROR }
 
enum  nat44_ei_out2in_next_t { NAT44_EI_OUT2IN_NEXT_DROP, NAT44_EI_OUT2IN_NEXT_LOOKUP, NAT44_EI_OUT2IN_NEXT_ICMP_ERROR, NAT44_EI_OUT2IN_N_NEXT }
 

Functions

static u8format_nat44_ei_out2in_trace (u8 *s, va_list *args)
 
static u8format_nat44_ei_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 nat44_ei_session_t * create_session_for_static_mapping (nat44_ei_main_t *nm, vlib_buffer_t *b0, ip4_address_t i2o_addr, u16 i2o_port, u32 i2o_fib_index, ip4_address_t o2i_addr, u16 o2i_port, u32 o2i_fib_index, nat_protocol_t proto, vlib_node_runtime_t *node, u32 thread_index, f64 now)
 Create session for static mapping. More...
 
static_always_inline nat44_ei_out2in_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 nat44_ei_icmp_match_out2in_slow (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, nat44_ei_session_t **p_s0, u8 *dont_translate)
 Get address and port values to be used for ICMP packet translation and create session if needed. More...
 
u32 nat44_ei_icmp_match_out2in_fast (vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *mapping_addr, u16 *mapping_port, u32 *mapping_fib_index, nat_protocol_t *proto, nat44_ei_session_t **p_s0, u8 *dont_translate)
 
u32 nat44_ei_icmp_out2in (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, nat44_ei_session_t **p_s0)
 
static u32 nat44_ei_icmp_out2in_slow_path (nat44_ei_main_t *nm, 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, nat44_ei_session_t **p_s0)
 
static int nat_out2in_sm_unknown_proto (nat44_ei_main_t *nm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index)
 
 vlib_get_buffers (vm, from, b, n_left_from)
 
 while (n_left_from >=2)
 
 while (n_left_from > 0)
 
 vlib_buffer_enqueue_to_next (vm, node, from,(u16 *) nexts, frame->n_vectors)
 

Variables

static char * nat44_ei_out2in_error_strings []
 
vlib_main_tvm
 
vlib_main_t vlib_node_runtime_tnode
 
vlib_main_t vlib_node_runtime_t vlib_frame_tframe
 
nat44_ei_main_tnm = &nat44_ei_main
 
f64 now = vlib_time_now (vm)
 
u32 thread_index = vm->thread_index
 
nat44_ei_main_per_thread_data_ttnm = &nm->per_thread_data[thread_index]
 
 from = vlib_frame_vector_args (frame)
 
 n_left_from = frame->n_vectors
 
vlib_buffer_tbufs [VLIB_FRAME_SIZE]
 
vlib_buffer_t ** b = bufs
 
u16 nexts [VLIB_FRAME_SIZE]
 
u16next = nexts
 
return frame n_vectors
 
vlib_node_registration_t nat44_ei_out2in_node
 (constructor) VLIB_REGISTER_NODE (nat44_ei_out2in_node) More...
 
vlib_node_registration_t nat44_ei_out2in_fast_node
 (constructor) VLIB_REGISTER_NODE (nat44_ei_out2in_fast_node) More...
 

Detailed Description

NAT44 EI outside to inside network translation.

Definition in file nat44_ei_out2in.c.

Macro Definition Documentation

◆ foreach_nat44_ei_out2in_error

#define foreach_nat44_ei_out2in_error
Value:
_ (UNSUPPORTED_PROTOCOL, "unsupported protocol") \
_ (OUT_OF_PORTS, "out of ports") \
_ (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 71 of file nat44_ei_out2in.c.

Enumeration Type Documentation

◆ nat44_ei_out2in_error_t

Enumerator
NAT44_EI_OUT2IN_N_ERROR 

Definition at line 79 of file nat44_ei_out2in.c.

◆ nat44_ei_out2in_next_t

Enumerator
NAT44_EI_OUT2IN_NEXT_DROP 
NAT44_EI_OUT2IN_NEXT_LOOKUP 
NAT44_EI_OUT2IN_NEXT_ICMP_ERROR 
NAT44_EI_OUT2IN_N_NEXT 

Definition at line 93 of file nat44_ei_out2in.c.

Function Documentation

◆ create_session_for_static_mapping()

static nat44_ei_session_t* create_session_for_static_mapping ( nat44_ei_main_t nm,
vlib_buffer_t b0,
ip4_address_t  i2o_addr,
u16  i2o_port,
u32  i2o_fib_index,
ip4_address_t  o2i_addr,
u16  o2i_port,
u32  o2i_fib_index,
nat_protocol_t  proto,
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
nmNAT main.
b0Vlib buffer.
in2outIn2out NAT44 session key.
out2inOut2in NAT44 session key.
nodeVlib node.
Returns
NAT44_EI session if successfully created otherwise 0.

Definition at line 171 of file nat44_ei_out2in.c.

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

◆ format_nat44_ei_out2in_fast_trace()

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

Definition at line 60 of file nat44_ei_out2in.c.

◆ format_nat44_ei_out2in_trace()

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

Definition at line 46 of file nat44_ei_out2in.c.

◆ icmp_get_key()

static_always_inline nat44_ei_out2in_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 257 of file nat44_ei_out2in.c.

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

◆ nat44_ei_icmp_match_out2in_fast()

u32 nat44_ei_icmp_match_out2in_fast ( vlib_node_runtime_t node,
u32  thread_index,
vlib_buffer_t b0,
ip4_header_t ip0,
ip4_address_t mapping_addr,
u16 mapping_port,
u32 mapping_fib_index,
nat_protocol_t proto,
nat44_ei_session_t **  p_s0,
u8 dont_translate 
)

Definition at line 442 of file nat44_ei_out2in.c.

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

◆ nat44_ei_icmp_match_out2in_slow()

u32 nat44_ei_icmp_match_out2in_slow ( 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,
nat44_ei_session_t **  p_s0,
u8 dont_translate 
)

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

Parameters
[in,out]nmNAT 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 316 of file nat44_ei_out2in.c.

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

◆ nat44_ei_icmp_out2in()

u32 nat44_ei_icmp_out2in ( 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,
nat44_ei_session_t **  p_s0 
)

Definition at line 510 of file nat44_ei_out2in.c.

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

◆ nat44_ei_icmp_out2in_slow_path()

static u32 nat44_ei_icmp_out2in_slow_path ( nat44_ei_main_t nm,
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,
nat44_ei_session_t **  p_s0 
)
inlinestatic

Definition at line 658 of file nat44_ei_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 103 of file nat44_ei_out2in.c.

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

◆ nat_out2in_sm_unknown_proto()

static int nat_out2in_sm_unknown_proto ( nat44_ei_main_t nm,
vlib_buffer_t b,
ip4_header_t ip,
u32  rx_fib_index 
)
static

Definition at line 681 of file nat44_ei_out2in.c.

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

◆ vlib_buffer_enqueue_to_next()

vlib_buffer_enqueue_to_next ( vm  ,
node  ,
from  ,
(u16 *)  nexts,
frame->  n_vectors 
)

◆ vlib_get_buffers()

vlib_get_buffers ( vm  ,
from  ,
b  ,
n_left_from   
)

◆ while() [1/2]

while ( n_left_from  ,
 
)

Definition at line 1130 of file nat44_ei_out2in.c.

+ Here is the call graph for this function:

◆ while() [2/2]

while ( n_left_from >=  2)

Definition at line 721 of file nat44_ei_out2in.c.

+ Here is the call graph for this function:

Variable Documentation

◆ b

Definition at line 717 of file nat44_ei_out2in.c.

◆ bufs

vlib_buffer_t * bufs

Definition at line 717 of file nat44_ei_out2in.c.

◆ frame

Initial value:

Definition at line 707 of file nat44_ei_out2in.c.

◆ from

Definition at line 714 of file nat44_ei_out2in.c.

◆ n_left_from

n_left_from = frame->n_vectors

Definition at line 715 of file nat44_ei_out2in.c.

◆ n_vectors

return frame n_vectors

Definition at line 1341 of file nat44_ei_out2in.c.

◆ nat44_ei_out2in_error_strings

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

Definition at line 87 of file nat44_ei_out2in.c.

◆ nat44_ei_out2in_fast_node

vlib_node_registration_t nat44_ei_out2in_fast_node
Initial value:
= {
.name = "nat44-ei-out2in-fast",
.vector_size = sizeof (u32),
.runtime_data_bytes = sizeof (nat44_ei_runtime_t),
.n_next_nodes = NAT44_EI_OUT2IN_N_NEXT,
.next_nodes = {
[NAT44_EI_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[NAT44_EI_OUT2IN_NEXT_DROP] = "error-drop",
[NAT44_EI_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}

(constructor) VLIB_REGISTER_NODE (nat44_ei_out2in_fast_node)

Definition at line 1528 of file nat44_ei_out2in.c.

◆ nat44_ei_out2in_node

vlib_node_registration_t nat44_ei_out2in_node
Initial value:
= {
.name = "nat44-ei-out2in",
.vector_size = sizeof (u32),
.runtime_data_bytes = sizeof (nat44_ei_runtime_t),
.n_next_nodes = NAT44_EI_OUT2IN_N_NEXT,
.next_nodes = {
[NAT44_EI_OUT2IN_NEXT_DROP] = "error-drop",
[NAT44_EI_OUT2IN_NEXT_LOOKUP] = "ip4-lookup",
[NAT44_EI_OUT2IN_NEXT_ICMP_ERROR] = "ip4-icmp-error",
},
}

(constructor) VLIB_REGISTER_NODE (nat44_ei_out2in_node)

Definition at line 1345 of file nat44_ei_out2in.c.

◆ next

u16 * next = nexts

Definition at line 718 of file nat44_ei_out2in.c.

◆ nexts

u16 nexts

Definition at line 718 of file nat44_ei_out2in.c.

◆ nm

Definition at line 709 of file nat44_ei_out2in.c.

◆ node

Definition at line 706 of file nat44_ei_out2in.c.

◆ now

f64 now = vlib_time_now (vm)

Definition at line 710 of file nat44_ei_out2in.c.

◆ thread_index

u32 thread_index = vm->thread_index

Definition at line 711 of file nat44_ei_out2in.c.

◆ tnm

◆ vm

Definition at line 706 of file nat44_ei_out2in.c.

NAT44_EI_OUT2IN_NEXT_DROP
@ NAT44_EI_OUT2IN_NEXT_DROP
Definition: nat44_ei_out2in.c:95
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
format_nat44_ei_out2in_trace
static u8 * format_nat44_ei_out2in_trace(u8 *s, va_list *args)
Definition: nat44_ei_out2in.c:46
NAT44_EI_OUT2IN_N_NEXT
@ NAT44_EI_OUT2IN_N_NEXT
Definition: nat44_ei_out2in.c:98
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
n_left_from
n_left_from
Definition: nat44_ei_out2in.c:715
nat44_ei_runtime_t
Definition: nat44_ei.h:305
NAT44_EI_OUT2IN_NEXT_LOOKUP
@ NAT44_EI_OUT2IN_NEXT_LOOKUP
Definition: nat44_ei_out2in.c:96
foreach_nat44_ei_out2in_error
#define foreach_nat44_ei_out2in_error
Definition: nat44_ei_out2in.c:71
u32
unsigned int u32
Definition: types.h:88
nat44_ei_out2in_error_strings
static char * nat44_ei_out2in_error_strings[]
Definition: nat44_ei_out2in.c:87
format_nat44_ei_out2in_fast_trace
static u8 * format_nat44_ei_out2in_fast_trace(u8 *s, va_list *args)
Definition: nat44_ei_out2in.c:60
from
from
Definition: nat44_ei_out2in.c:714
NAT44_EI_OUT2IN_NEXT_ICMP_ERROR
@ NAT44_EI_OUT2IN_NEXT_ICMP_ERROR
Definition: nat44_ei_out2in.c:97
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123