FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
nat64.h File Reference
+ Include dependency graph for nat64.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  nat64_prefix_t
 
struct  nat64_static_bib_to_update_t
 
struct  nat64_address_t
 
struct  nat64_interface_t
 
struct  nat64_main_t
 

Macros

#define foreach_nat64_tcp_ses_state
 
#define NAT64_INTERFACE_FLAG_IS_INSIDE   1
 
#define NAT64_INTERFACE_FLAG_IS_OUTSIDE   2
 
#define nat64_interface_is_inside(i)   i->flags & NAT64_INTERFACE_FLAG_IS_INSIDE
 Check if NAT64 interface is inside. More...
 
#define nat64_interface_is_outside(i)   i->flags & NAT64_INTERFACE_FLAG_IS_OUTSIDE
 Check if NAT64 interface is outside. More...
 
#define nat64_log_err(...)   vlib_log(VLIB_LOG_LEVEL_ERR, nat64_main.log_class, __VA_ARGS__)
 
#define nat64_log_warn(...)   vlib_log(VLIB_LOG_LEVEL_WARNING, nat64_main.log_class, __VA_ARGS__)
 
#define nat64_log_notice(...)   vlib_log(VLIB_LOG_LEVEL_NOTICE, nat64_main.log_class, __VA_ARGS__)
 
#define nat64_log_info(...)   vlib_log(VLIB_LOG_LEVEL_INFO, nat64_main.log_class, __VA_ARGS__)
 
#define nat64_log_debug(...)   vlib_log(VLIB_LOG_LEVEL_DEBUG, nat64_main.log_class, __VA_ARGS__)
 

Typedefs

typedef int(* nat64_pool_addr_walk_fn_t) (nat64_address_t *addr, void *ctx)
 Call back function when walking addresses in NAT64 pool, non-zero return value stop walk. More...
 
typedef int(* nat64_interface_walk_fn_t) (nat64_interface_t *i, void *ctx)
 Call back function when walking interfaces with NAT64 feature, non-zero return value stop walk. More...
 
typedef int(* nat64_prefix_walk_fn_t) (nat64_prefix_t *pref64, void *ctx)
 Call back function when walking addresses in NAT64 prefixes, non-zero return value stop walk. More...
 

Enumerations

enum  nat64_tcp_ses_state_t { foreach_nat64_tcp_ses_state }
 
enum  nat64_cleaner_process_event_e { NAT64_CLEANER_RESCHEDULE = 1 }
 

Functions

int nat64_add_del_pool_addr (u32 thread_index, ip4_address_t *addr, u32 vrf_id, u8 is_add)
 Add/delete address to NAT64 pool. More...
 
void nat64_pool_addr_walk (nat64_pool_addr_walk_fn_t fn, void *ctx)
 Walk NAT64 pool. More...
 
int nat64_add_interface_address (u32 sw_if_index, int is_add)
 NAT64 pool address from specific (DHCP addressed) interface. More...
 
int nat64_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add)
 Enable/disable NAT64 feature on the interface. More...
 
void nat64_interfaces_walk (nat64_interface_walk_fn_t fn, void *ctx)
 Walk NAT64 interfaces. More...
 
clib_error_tnat64_init (vlib_main_t *vm)
 Initialize NAT64. More...
 
int nat64_add_del_static_bib_entry (ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u8 proto, u32 vrf_id, u8 is_add)
 Add/delete static NAT64 BIB entry. More...
 
int nat64_alloc_out_addr_and_port (u32 fib_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u32 thread_index)
 Alloce IPv4 address and port pair from NAT64 pool. More...
 
int nat64_set_udp_timeout (u32 timeout)
 Set UDP session timeout. More...
 
u32 nat64_get_udp_timeout (void)
 Get UDP session timeout. More...
 
int nat64_set_icmp_timeout (u32 timeout)
 Set ICMP session timeout. More...
 
u32 nat64_get_icmp_timeout (void)
 Get ICMP session timeout. More...
 
int nat64_set_tcp_timeouts (u32 trans, u32 est)
 Set TCP session timeouts. More...
 
u32 nat64_get_tcp_trans_timeout (void)
 Get TCP transitory timeout. More...
 
u32 nat64_get_tcp_est_timeout (void)
 Get TCP established timeout. More...
 
void nat64_session_reset_timeout (nat64_db_st_entry_t *ste, vlib_main_t *vm)
 Reset NAT64 session timeout. More...
 
void nat64_tcp_session_set_state (nat64_db_st_entry_t *ste, tcp_header_t *tcp, u8 is_ip6)
 Set NAT64 TCP session state. More...
 
int nat64_add_del_prefix (ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
 Add/delete NAT64 prefix. More...
 
void nat64_prefix_walk (nat64_prefix_walk_fn_t fn, void *ctx)
 Walk NAT64 prefixes. More...
 
void nat64_compose_ip6 (ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
 Compose IPv4-embedded IPv6 addresses. More...
 
void nat64_extract_ip4 (ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
 Extract IPv4 address from the IPv4-embedded IPv6 addresses. More...
 
void nat64_set_hash (u32 bib_buckets, uword bib_memory_size, u32 st_buckets, uword st_memory_size)
 Set NAT64 hash tables configuration. More...
 
u32 nat64_get_worker_in2out (ip6_address_t *addr)
 Get worker thread index for NAT64 in2out. More...
 
u32 nat64_get_worker_out2in (vlib_buffer_t *b, ip4_header_t *ip)
 Get worker thread index for NAT64 out2in. More...
 
static_always_inline u8 plugin_enabled ()
 
void nat64_add_del_addr_to_fib (ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
 
int nat64_plugin_enable (nat64_config_t c)
 
int nat64_plugin_disable ()
 
void nat64_reset_timeouts ()
 
clib_error_tnat64_api_hookup (vlib_main_t *vm)
 

Variables

nat64_main_t nat64_main
 
vlib_node_registration_t nat64_in2out_node
 (constructor) VLIB_REGISTER_NODE (nat64_in2out_node) More...
 
vlib_node_registration_t nat64_out2in_node
 (constructor) VLIB_REGISTER_NODE (nat64_out2in_node) More...
 
format_function_t format_nat_protocol
 
unformat_function_t unformat_nat_protocol
 

Macro Definition Documentation

◆ foreach_nat64_tcp_ses_state

#define foreach_nat64_tcp_ses_state
Value:
_(0, CLOSED, "closed") \
_(1, V4_INIT, "v4-init") \
_(2, V6_INIT, "v6-init") \
_(3, ESTABLISHED, "established") \
_(4, V4_FIN_RCV, "v4-fin-rcv") \
_(5, V6_FIN_RCV, "v6-fin-rcv") \
_(6, V6_FIN_V4_FIN_RCV, "v6-fin-v4-fin-rcv") \
_(7, TRANS, "trans")

Definition at line 49 of file nat64.h.

◆ NAT64_INTERFACE_FLAG_IS_INSIDE

#define NAT64_INTERFACE_FLAG_IS_INSIDE   1

Definition at line 476 of file nat64.h.

◆ NAT64_INTERFACE_FLAG_IS_OUTSIDE

#define NAT64_INTERFACE_FLAG_IS_OUTSIDE   2

Definition at line 477 of file nat64.h.

◆ nat64_interface_is_inside

#define nat64_interface_is_inside (   i)    i->flags & NAT64_INTERFACE_FLAG_IS_INSIDE

Check if NAT64 interface is inside.

Parameters
iNAT64 interface
Returns
1 if inside interface

Definition at line 483 of file nat64.h.

◆ nat64_interface_is_outside

#define nat64_interface_is_outside (   i)    i->flags & NAT64_INTERFACE_FLAG_IS_OUTSIDE

Check if NAT64 interface is outside.

Parameters
iNAT64 interface
Returns
1 if outside interface

Definition at line 489 of file nat64.h.

◆ nat64_log_debug

#define nat64_log_debug (   ...)    vlib_log(VLIB_LOG_LEVEL_DEBUG, nat64_main.log_class, __VA_ARGS__)

Definition at line 518 of file nat64.h.

◆ nat64_log_err

#define nat64_log_err (   ...)    vlib_log(VLIB_LOG_LEVEL_ERR, nat64_main.log_class, __VA_ARGS__)

Definition at line 510 of file nat64.h.

◆ nat64_log_info

#define nat64_log_info (   ...)    vlib_log(VLIB_LOG_LEVEL_INFO, nat64_main.log_class, __VA_ARGS__)

Definition at line 516 of file nat64.h.

◆ nat64_log_notice

#define nat64_log_notice (   ...)    vlib_log(VLIB_LOG_LEVEL_NOTICE, nat64_main.log_class, __VA_ARGS__)

Definition at line 514 of file nat64.h.

◆ nat64_log_warn

#define nat64_log_warn (   ...)    vlib_log(VLIB_LOG_LEVEL_WARNING, nat64_main.log_class, __VA_ARGS__)

Definition at line 512 of file nat64.h.

Typedef Documentation

◆ nat64_interface_walk_fn_t

typedef int(* nat64_interface_walk_fn_t) (nat64_interface_t *i, void *ctx)

Call back function when walking interfaces with NAT64 feature, non-zero return value stop walk.

Definition at line 273 of file nat64.h.

◆ nat64_pool_addr_walk_fn_t

typedef int(* nat64_pool_addr_walk_fn_t) (nat64_address_t *addr, void *ctx)

Call back function when walking addresses in NAT64 pool, non-zero return value stop walk.

Definition at line 238 of file nat64.h.

◆ nat64_prefix_walk_fn_t

typedef int(* nat64_prefix_walk_fn_t) (nat64_prefix_t *pref64, void *ctx)

Call back function when walking addresses in NAT64 prefixes, non-zero return value stop walk.

Definition at line 417 of file nat64.h.

Enumeration Type Documentation

◆ nat64_cleaner_process_event_e

Enumerator
NAT64_CLEANER_RESCHEDULE 

Definition at line 66 of file nat64.h.

◆ nat64_tcp_ses_state_t

Enumerator
foreach_nat64_tcp_ses_state 

Definition at line 59 of file nat64.h.

Function Documentation

◆ nat64_add_del_addr_to_fib()

void nat64_add_del_addr_to_fib ( ip4_address_t addr,
u8  p_len,
u32  sw_if_index,
int  is_add 
)

Definition at line 509 of file nat64.c.

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

◆ nat64_add_del_pool_addr()

int nat64_add_del_pool_addr ( u32  thread_index,
ip4_address_t addr,
u32  vrf_id,
u8  is_add 
)

Add/delete address to NAT64 pool.

Parameters
thread_indexThread index used by ipfix nat logging (not address per thread).
addrIPv4 address.
vrf_idVRF id of tenant, ~0 means independent of VRF.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 364 of file nat64.c.

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

◆ nat64_add_del_prefix()

int nat64_add_del_prefix ( ip6_address_t *  prefix,
u8  plen,
u32  vrf_id,
u8  is_add 
)

Add/delete NAT64 prefix.

Parameters
prefixNAT64 prefix.
plenPrefix length.
vrf_idVRF id of tenant.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 1206 of file nat64.c.

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

◆ nat64_add_del_static_bib_entry()

int nat64_add_del_static_bib_entry ( ip6_address_t *  in_addr,
ip4_address_t out_addr,
u16  in_port,
u16  out_port,
u8  proto,
u32  vrf_id,
u8  is_add 
)

Add/delete static NAT64 BIB entry.

Parameters
in_addrInside IPv6 address.
out_addrOutside IPv4 address.
in_portInside port number.
out_portOutside port number.
protoL4 protocol.
vrf_idVRF id of tenant.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 879 of file nat64.c.

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

◆ nat64_add_interface_address()

int nat64_add_interface_address ( u32  sw_if_index,
int  is_add 
)

NAT64 pool address from specific (DHCP addressed) interface.

Parameters
sw_if_indexIndex of the interface.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 455 of file nat64.c.

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

◆ nat64_alloc_out_addr_and_port()

int nat64_alloc_out_addr_and_port ( u32  fib_index,
nat_protocol_t  proto,
ip4_address_t addr,
u16 port,
u32  thread_index 
)

Alloce IPv4 address and port pair from NAT64 pool.

Parameters
fib_indexFIB index of tenant.
protoL4 protocol.
addrAllocated IPv4 address.
portAllocated port number.
thread_indexThread index.
Returns
0 on success, non-zero value otherwise.

Definition at line 757 of file nat64.c.

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

◆ nat64_api_hookup()

clib_error_t* nat64_api_hookup ( vlib_main_t vm)

Definition at line 445 of file nat64_api.c.

+ Here is the call graph for this function:

◆ nat64_compose_ip6()

void nat64_compose_ip6 ( ip6_address_t *  ip6,
ip4_address_t ip4,
u32  fib_index 
)

Compose IPv4-embedded IPv6 addresses.

Parameters
ip6IPv4-embedded IPv6 addresses.
ip4IPv4 address.
fib_indexTenant FIB index.

Definition at line 1271 of file nat64.c.

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

◆ nat64_extract_ip4()

void nat64_extract_ip4 ( ip6_address_t *  ip6,
ip4_address_t ip4,
u32  fib_index 
)

Extract IPv4 address from the IPv4-embedded IPv6 addresses.

Parameters
ip6IPv4-embedded IPv6 addresses.
ip4IPv4 address.
fib_indexTenant FIB index.

Definition at line 1341 of file nat64.c.

+ Here is the caller graph for this function:

◆ nat64_get_icmp_timeout()

u32 nat64_get_icmp_timeout ( void  )

Get ICMP session timeout.

Returns
ICMP session timeout in seconds.

Definition at line 1058 of file nat64.c.

◆ nat64_get_tcp_est_timeout()

u32 nat64_get_tcp_est_timeout ( void  )

Get TCP established timeout.

Returns
TCP established timeout in seconds.

Definition at line 1092 of file nat64.c.

◆ nat64_get_tcp_trans_timeout()

u32 nat64_get_tcp_trans_timeout ( void  )

Get TCP transitory timeout.

Returns
TCP transitory timeout in seconds.

Definition at line 1084 of file nat64.c.

◆ nat64_get_udp_timeout()

u32 nat64_get_udp_timeout ( void  )

Get UDP session timeout.

Returns
UDP session timeout in seconds.

Definition at line 1026 of file nat64.c.

◆ nat64_get_worker_in2out()

u32 nat64_get_worker_in2out ( ip6_address_t *  addr)

Get worker thread index for NAT64 in2out.

Parameters
addrIPv6 src address.
Returns
worker thread index.

Definition at line 117 of file nat64.c.

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

◆ nat64_get_worker_out2in()

u32 nat64_get_worker_out2in ( vlib_buffer_t b,
ip4_header_t ip 
)

Get worker thread index for NAT64 out2in.

Parameters
ipIPv4 header.
Returns
worker thread index.

Definition at line 139 of file nat64.c.

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

◆ nat64_init()

clib_error_t* nat64_init ( vlib_main_t vm)

Initialize NAT64.

Parameters
vmvlib main.
Returns
error code.

Definition at line 211 of file nat64.c.

+ Here is the call graph for this function:

◆ nat64_interface_add_del()

int nat64_interface_add_del ( u32  sw_if_index,
u8  is_inside,
u8  is_add 
)

Enable/disable NAT64 feature on the interface.

Parameters
sw_if_indexIndex of the interface.
is_inside1 if inside, 0 if outside.
is_add1 if add, 0 if delete.
Returns
0 on success, non-zero value otherwise.

Definition at line 538 of file nat64.c.

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

◆ nat64_interfaces_walk()

void nat64_interfaces_walk ( nat64_interface_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 interfaces.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 639 of file nat64.c.

+ Here is the caller graph for this function:

◆ nat64_plugin_disable()

int nat64_plugin_disable ( )

Definition at line 1553 of file nat64.c.

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

◆ nat64_plugin_enable()

int nat64_plugin_enable ( nat64_config_t  c)

Definition at line 1516 of file nat64.c.

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

◆ nat64_pool_addr_walk()

void nat64_pool_addr_walk ( nat64_pool_addr_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 pool.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 440 of file nat64.c.

+ Here is the caller graph for this function:

◆ nat64_prefix_walk()

void nat64_prefix_walk ( nat64_prefix_walk_fn_t  fn,
void *  ctx 
)

Walk NAT64 prefixes.

Parameters
fnThe function to invoke on each entry visited.
ctxA context passed in the visit function.

Definition at line 1256 of file nat64.c.

+ Here is the caller graph for this function:

◆ nat64_reset_timeouts()

void nat64_reset_timeouts ( )

Definition at line 1047 of file nat64.c.

+ Here is the caller graph for this function:

◆ nat64_session_reset_timeout()

void nat64_session_reset_timeout ( nat64_db_st_entry_t *  ste,
vlib_main_t vm 
)

Reset NAT64 session timeout.

Parameters
steSession table entry.
vmVLIB main.

Definition at line 1100 of file nat64.c.

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

◆ nat64_set_hash()

void nat64_set_hash ( u32  bib_buckets,
uword  bib_memory_size,
u32  st_buckets,
uword  st_memory_size 
)

Set NAT64 hash tables configuration.

Parameters
bib_bucketsNumber of BIB hash buckets.
bib_memory_sizeMemory size of BIB hash.
st_bucketsNumber of session table hash buckets.
st_memory_sizeMemory size of session table hash.

◆ nat64_set_icmp_timeout()

int nat64_set_icmp_timeout ( u32  timeout)

Set ICMP session timeout.

Parameters
timeoutTimeout value in seconds (if 0 reset to default value 60sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 1034 of file nat64.c.

◆ nat64_set_tcp_timeouts()

int nat64_set_tcp_timeouts ( u32  trans,
u32  est 
)

Set TCP session timeouts.

Parameters
transTransitory timeout in seconds (if 0 reset to default value 240sec).
estEstablished timeout in seconds (if 0 reset to default value 7440sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 1066 of file nat64.c.

◆ nat64_set_udp_timeout()

int nat64_set_udp_timeout ( u32  timeout)

Set UDP session timeout.

Parameters
timeoutTimeout value in seconds (if 0 reset to default value 300sec).
Returns
0 on success, non-zero value otherwise.

Definition at line 1013 of file nat64.c.

◆ nat64_tcp_session_set_state()

void nat64_tcp_session_set_state ( nat64_db_st_entry_t *  ste,
tcp_header_t tcp,
u8  is_ip6 
)

Set NAT64 TCP session state.

Parameters
steSession table entry.
tcpTCP header.
is_ip61 if IPv6 packet, 0 if IPv4.

Definition at line 1139 of file nat64.c.

+ Here is the caller graph for this function:

◆ plugin_enabled()

static_always_inline u8 plugin_enabled ( )

Definition at line 492 of file nat64.h.

Variable Documentation

◆ format_nat_protocol

format_function_t format_nat_protocol

Definition at line 506 of file nat64.h.

◆ nat64_in2out_node

vlib_node_registration_t nat64_in2out_node

(constructor) VLIB_REGISTER_NODE (nat64_in2out_node)

Definition at line 1230 of file nat64_in2out.c.

◆ nat64_main

nat64_main_t nat64_main

Definition at line 27 of file nat64.c.

◆ nat64_out2in_node

vlib_node_registration_t nat64_out2in_node

(constructor) VLIB_REGISTER_NODE (nat64_out2in_node)

Definition at line 643 of file nat64_out2in.c.

◆ unformat_nat_protocol

unformat_function_t unformat_nat_protocol

Definition at line 507 of file nat64.h.