FD.io VPP  v21.01.1
Vector Packet Processing
det44.h File Reference

Deterministic NAT (CGN) definitions. More...

+ Include dependency graph for det44.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  icmp_echo_header_t
 
struct  tcp_udp_header_t
 
struct  det44_runtime_t
 
struct  snat_det_out_key_t
 
struct  snat_det_session_t
 
struct  snat_det_map_t
 
struct  det44_interface_t
 
struct  det44_config_t
 
struct  det44_fib_t
 
struct  det44_main_s
 

Macros

#define foreach_det44_session_state
 
#define DET44_SES_PER_USER   1000
 
#define det44_log_err(...)   vlib_log(VLIB_LOG_LEVEL_ERR, det44_main.log_class, __VA_ARGS__)
 
#define det44_log_warn(...)   vlib_log(VLIB_LOG_LEVEL_WARNING, det44_main.log_class, __VA_ARGS__)
 
#define det44_log_notice(...)   vlib_log(VLIB_LOG_LEVEL_NOTICE, det44_main.log_class, __VA_ARGS__)
 
#define det44_log_info(...)   vlib_log(VLIB_LOG_LEVEL_INFO, det44_main.log_class, __VA_ARGS__)
 
#define det44_log_debug(...)   vlib_log(VLIB_LOG_LEVEL_DEBUG, det44_main.log_class, __VA_ARGS__)
 
#define DET44_INTERFACE_FLAG_IS_INSIDE   1
 
#define DET44_INTERFACE_FLAG_IS_OUTSIDE   2
 
#define det44_interface_is_inside(i)   i->flags & DET44_INTERFACE_FLAG_IS_INSIDE
 Check if Deterministic NAT interface is inside. More...
 
#define det44_interface_is_outside(i)   i->flags & DET44_INTERFACE_FLAG_IS_OUTSIDE
 Check if Deterministic NAT interface is outside. More...
 

Typedefs

typedef struct det44_main_s det44_main_t
 

Enumerations

enum  det44_session_state_t { foreach_det44_session_state }
 

Functions

static_always_inline u8 plugin_enabled ()
 
int det44_plugin_enable ()
 
int det44_plugin_disable ()
 
int det44_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del)
 
int det44_set_timeouts (nat_timeouts_t *timeouts)
 
nat_timeouts_t det44_get_timeouts ()
 
void det44_reset_timeouts ()
 
int snat_det_add_map (ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
 Add/delete deterministic NAT mapping. More...
 
u32 icmp_match_out2in_det (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_det (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 det44_icmp_in2out (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)
 
u32 det44_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, void *d, void *e)
 
static_always_inline int is_addr_in_net (ip4_address_t *addr, ip4_address_t *net, u8 plen)
 
static_always_inline snat_det_map_tsnat_det_map_by_user (ip4_address_t *user_addr)
 
static_always_inline snat_det_map_tsnat_det_map_by_out (ip4_address_t *out_addr)
 
static_always_inline void snat_det_forward (snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
 
static_always_inline void snat_det_reverse (snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
 
static_always_inline u32 snat_det_user_ses_offset (ip4_address_t *addr, u8 plen)
 
static_always_inline snat_det_session_tsnat_det_get_ses_by_out (snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
 
static_always_inline snat_det_session_tsnat_det_find_ses_by_in (snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t out_key)
 
static_always_inline snat_det_session_tsnat_det_ses_create (u32 thread_index, snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t *out)
 
static_always_inline void snat_det_ses_close (snat_det_map_t *dm, snat_det_session_t *ses)
 
clib_error_tdet44_api_hookup (vlib_main_t *vm)
 

Variables

det44_main_t det44_main
 
vlib_node_registration_t det44_in2out_node
 (constructor) VLIB_REGISTER_NODE (det44_in2out_node) More...
 
vlib_node_registration_t det44_out2in_node
 (constructor) VLIB_REGISTER_NODE (det44_out2in_node) More...
 
format_function_t format_det_map_ses
 

Detailed Description

Deterministic NAT (CGN) definitions.

Definition in file det44.h.

Macro Definition Documentation

◆ DET44_INTERFACE_FLAG_IS_INSIDE

#define DET44_INTERFACE_FLAG_IS_INSIDE   1

Definition at line 206 of file det44.h.

◆ DET44_INTERFACE_FLAG_IS_OUTSIDE

#define DET44_INTERFACE_FLAG_IS_OUTSIDE   2

Definition at line 207 of file det44.h.

◆ det44_interface_is_inside

#define det44_interface_is_inside (   i)    i->flags & DET44_INTERFACE_FLAG_IS_INSIDE

Check if Deterministic NAT interface is inside.

Parameters
iDeterministic NAT interface
Returns
1 if inside interface

Definition at line 213 of file det44.h.

◆ det44_interface_is_outside

#define det44_interface_is_outside (   i)    i->flags & DET44_INTERFACE_FLAG_IS_OUTSIDE

Check if Deterministic NAT interface is outside.

Parameters
iDeterministic NAT interface
Returns
1 if outside interface

Definition at line 219 of file det44.h.

◆ det44_log_debug

#define det44_log_debug (   ...)    vlib_log(VLIB_LOG_LEVEL_DEBUG, det44_main.log_class, __VA_ARGS__)

Definition at line 202 of file det44.h.

◆ det44_log_err

#define det44_log_err (   ...)    vlib_log(VLIB_LOG_LEVEL_ERR, det44_main.log_class, __VA_ARGS__)

Definition at line 194 of file det44.h.

◆ det44_log_info

#define det44_log_info (   ...)    vlib_log(VLIB_LOG_LEVEL_INFO, det44_main.log_class, __VA_ARGS__)

Definition at line 200 of file det44.h.

◆ det44_log_notice

#define det44_log_notice (   ...)    vlib_log(VLIB_LOG_LEVEL_NOTICE, det44_main.log_class, __VA_ARGS__)

Definition at line 198 of file det44.h.

◆ det44_log_warn

#define det44_log_warn (   ...)    vlib_log(VLIB_LOG_LEVEL_WARNING, det44_main.log_class, __VA_ARGS__)

Definition at line 196 of file det44.h.

◆ DET44_SES_PER_USER

#define DET44_SES_PER_USER   1000

Definition at line 64 of file det44.h.

◆ foreach_det44_session_state

#define foreach_det44_session_state
Value:
_(0, UNKNOWN, "unknown") \
_(1, UDP_ACTIVE, "udp-active") \
_(2, TCP_SYN_SENT, "tcp-syn-sent") \
_(3, TCP_ESTABLISHED, "tcp-established") \
_(4, TCP_FIN_WAIT, "tcp-fin-wait") \
_(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
_(6, TCP_CLOSING, "tcp-closing") \
_(7, TCP_LAST_ACK, "tcp-last-ack") \
_(8, TCP_CLOSED, "tcp-closed") \
_(9, ICMP_ACTIVE, "icmp-active")

Definition at line 45 of file det44.h.

Typedef Documentation

◆ det44_main_t

typedef struct det44_main_s det44_main_t

Enumeration Type Documentation

◆ det44_session_state_t

Enumerator
foreach_det44_session_state 

Definition at line 57 of file det44.h.

Function Documentation

◆ det44_api_hookup()

clib_error_t* det44_api_hookup ( vlib_main_t vm)

Definition at line 620 of file det44_api.c.

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

◆ det44_get_timeouts()

nat_timeouts_t det44_get_timeouts ( )

Definition at line 181 of file det44.c.

+ Here is the caller graph for this function:

◆ det44_icmp_in2out()

u32 det44_icmp_in2out ( 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 255 of file det44_in2out.c.

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

◆ det44_icmp_out2in()

u32 det44_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,
void *  d,
void *  e 
)

Definition at line 233 of file det44_out2in.c.

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

◆ det44_interface_add_del()

int det44_interface_add_del ( u32  sw_if_index,
u8  is_inside,
int  is_del 
)

Definition at line 195 of file det44.c.

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

◆ det44_plugin_disable()

int det44_plugin_disable ( )

Definition at line 385 of file det44.c.

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

◆ det44_plugin_enable()

int det44_plugin_enable ( )
+ Here is the caller graph for this function:

◆ det44_reset_timeouts()

void det44_reset_timeouts ( )

Definition at line 188 of file det44.c.

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

◆ det44_set_timeouts()

int det44_set_timeouts ( nat_timeouts_t timeouts)

Definition at line 166 of file det44.c.

+ Here is the caller graph for this function:

◆ icmp_match_in2out_det()

u32 icmp_match_in2out_det ( 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]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 100 of file det44_in2out.c.

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

◆ icmp_match_out2in_det()

u32 icmp_match_out2in_det ( 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]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 100 of file det44_out2in.c.

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

◆ is_addr_in_net()

static_always_inline int is_addr_in_net ( ip4_address_t addr,
ip4_address_t net,
u8  plen 
)

Definition at line 269 of file det44.h.

+ Here is the caller graph for this function:

◆ plugin_enabled()

static_always_inline u8 plugin_enabled ( )

Definition at line 222 of file det44.h.

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

◆ snat_det_add_map()

int snat_det_add_map ( ip4_address_t in_addr,
u8  in_plen,
ip4_address_t out_addr,
u8  out_plen,
int  is_add 
)

Add/delete deterministic NAT mapping.

Create bijective mapping of inside address to outside address and port range pairs, with the purpose of enabling deterministic NAT to reduce logging in CGN deployments.

Parameters
in_addrInside network address.
in_plenInside network prefix length.
out_addrOutside network address.
out_plenOutside network prefix length.
is_addIf 0 delete, otherwise add.

Definition at line 99 of file det44.c.

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

◆ snat_det_find_ses_by_in()

static_always_inline snat_det_session_t* snat_det_find_ses_by_in ( snat_det_map_t dm,
ip4_address_t in_addr,
u16  in_port,
snat_det_out_key_t  out_key 
)

Definition at line 361 of file det44.h.

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

◆ snat_det_forward()

static_always_inline void snat_det_forward ( snat_det_map_t dm,
ip4_address_t in_addr,
ip4_address_t out_addr,
u16 lo_port 
)

Definition at line 307 of file det44.h.

+ Here is the caller graph for this function:

◆ snat_det_get_ses_by_out()

static_always_inline snat_det_session_t* snat_det_get_ses_by_out ( snat_det_map_t dm,
ip4_address_t in_addr,
u64  out_key 
)

Definition at line 344 of file det44.h.

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

◆ snat_det_map_by_out()

static_always_inline snat_det_map_t* snat_det_map_by_out ( ip4_address_t out_addr)

Definition at line 292 of file det44.h.

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

◆ snat_det_map_by_user()

static_always_inline snat_det_map_t* snat_det_map_by_user ( ip4_address_t user_addr)

Definition at line 277 of file det44.h.

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

◆ snat_det_reverse()

static_always_inline void snat_det_reverse ( snat_det_map_t dm,
ip4_address_t out_addr,
u16  out_port,
ip4_address_t in_addr 
)

Definition at line 322 of file det44.h.

+ Here is the caller graph for this function:

◆ snat_det_ses_close()

static_always_inline void snat_det_ses_close ( snat_det_map_t dm,
snat_det_session_t ses 
)

Definition at line 414 of file det44.h.

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

◆ snat_det_ses_create()

static_always_inline snat_det_session_t* snat_det_ses_create ( u32  thread_index,
snat_det_map_t dm,
ip4_address_t in_addr,
u16  in_port,
snat_det_out_key_t out 
)

Definition at line 382 of file det44.h.

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

◆ snat_det_user_ses_offset()

static_always_inline u32 snat_det_user_ses_offset ( ip4_address_t addr,
u8  plen 
)

Definition at line 337 of file det44.h.

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

Variable Documentation

◆ det44_in2out_node

vlib_node_registration_t det44_in2out_node

(constructor) VLIB_REGISTER_NODE (det44_in2out_node)

Definition at line 1015 of file det44_in2out.c.

◆ det44_main

det44_main_t det44_main

Definition at line 30 of file det44.c.

◆ det44_out2in_node

vlib_node_registration_t det44_out2in_node

(constructor) VLIB_REGISTER_NODE (det44_out2in_node)

Definition at line 819 of file det44_out2in.c.

◆ format_det_map_ses

format_function_t format_det_map_ses

Definition at line 241 of file det44.h.