FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
nat_ha.c File Reference
+ Include dependency graph for nat_ha.c:

Go to the source code of this file.

Data Structures

struct  nat_ha_message_header_t
 
struct  nat_ha_event_t
 
struct  nat_ha_resend_entry_t
 
struct  nat_ha_per_thread_data_t
 
struct  nat_ha_main_s
 
struct  nat_ha_trace_t
 
struct  nat_ha_handoff_trace_t
 

Macros

#define NAT_HA_RETRIES   3
 
#define foreach_nat_ha_counter
 
#define NAT_HA_VERSION   0x01
 
#define NAT_HA_FLAG_ACK   0x01
 
#define skip_if_disabled()
 
#define foreach_nat_ha_error
 
#define foreach_nat_ha_handoff_error
 

Typedefs

typedef struct nat_ha_main_s nat_ha_main_t
 

Enumerations

enum  nat_ha_event_type_t { NAT_HA_ADD = 1, NAT_HA_DEL, NAT_HA_REFRESH }
 
enum  nat_ha_counter_t { NAT_HA_N_COUNTERS }
 
enum  nat_ha_next_t { NAT_HA_NEXT_IP4_LOOKUP, NAT_HA_NEXT_DROP, NAT_HA_N_NEXT }
 
enum  nat_ha_error_t { NAT_HA_N_ERROR }
 
enum  nat_ha_handoff_error_t { NAT44_HANDOFF_N_ERROR }
 

Functions

static void nat_ha_resync_fin (void)
 
static int nat_ha_resend_queue_add (u32 seq, u8 *data, u8 data_len, u8 is_resync, u32 thread_index)
 
static_always_inline void nat_ha_ack_recv (u32 seq, u32 thread_index)
 
static void nat_ha_resend_scan (f64 now, u32 thread_index)
 
void nat_ha_init (vlib_main_t *vm, nat_ha_sadd_cb_t sadd_cb, nat_ha_sdel_cb_t sdel_cb, nat_ha_sref_cb_t sref_cb)
 Initialize NAT HA. More...
 
int nat_ha_set_listener (ip4_address_t *addr, u16 port, u32 path_mtu)
 Set HA listener (local settings) More...
 
void nat_ha_get_listener (ip4_address_t *addr, u16 *port, u32 *path_mtu)
 Get HA listener/local configuration. More...
 
int nat_ha_set_failover (ip4_address_t *addr, u16 port, u32 session_refresh_interval)
 Set HA failover (remote settings) More...
 
void nat_ha_get_failover (ip4_address_t *addr, u16 *port, u32 *session_refresh_interval)
 Get HA failover/remote settings. More...
 
static_always_inline void nat_ha_recv_add (nat_ha_event_t *event, f64 now, u32 thread_index)
 
static_always_inline void nat_ha_recv_del (nat_ha_event_t *event, u32 thread_index)
 
static_always_inline void nat_ha_recv_refresh (nat_ha_event_t *event, f64 now, u32 thread_index)
 
static_always_inline void nat_ha_event_process (nat_ha_event_t *event, f64 now, u32 thread_index)
 
static void nat_ha_header_create (vlib_buffer_t *b, u32 *offset, u32 thread_index)
 
static void nat_ha_send (vlib_frame_t *f, vlib_buffer_t *b, u8 is_resync, u32 thread_index)
 
static_always_inline void nat_ha_event_add (nat_ha_event_t *event, u8 do_flush, u32 thread_index, u8 is_resync)
 
void nat_ha_flush (u8 is_resync)
 Flush the current HA data (for testing) More...
 
void nat_ha_sadd (ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index, u8 is_resync)
 Create session add HA event. More...
 
void nat_ha_sdel (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 thread_index)
 Create session delete HA event. More...
 
void nat_ha_sref (ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index, f64 *last_refreshed, f64 now)
 Create session refresh HA event. More...
 
static uword nat_ha_worker_fn (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
static uword nat_ha_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
 
void nat_ha_get_resync_status (u8 *in_resync, u32 *resync_ack_missed)
 Get resync status. More...
 
int nat44_ha_resync (u32 client_index, u32 pid, nat_ha_resync_event_cb_t event_callback)
 
static u8format_nat_ha_trace (u8 *s, va_list *args)
 
static uword nat_ha_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 
static u8format_nat_ha_handoff_trace (u8 *s, va_list *args)
 
static uword nat_ha_handoff_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
 

Variables

nat_ha_main_t nat_ha_main
 
vlib_node_registration_t nat_ha_process_node
 (constructor) VLIB_REGISTER_NODE (nat_ha_process_node) More...
 
vlib_node_registration_t nat_ha_worker_node
 (constructor) VLIB_REGISTER_NODE (nat_ha_worker_node) More...
 
vlib_node_registration_t nat_ha_node
 (constructor) VLIB_REGISTER_NODE (nat_ha_node) More...
 
vlib_node_registration_t nat_ha_handoff_node
 (constructor) VLIB_REGISTER_NODE (nat_ha_handoff_node) More...
 
static char * nat_ha_error_strings []
 
static char * nat_ha_handoff_error_strings []
 

Macro Definition Documentation

◆ foreach_nat_ha_counter

#define foreach_nat_ha_counter
Value:
_(RECV_ADD, "add-event-recv", 0) \
_(RECV_DEL, "del-event-recv", 1) \
_(RECV_REFRESH, "refresh-event-recv", 2) \
_(SEND_ADD, "add-event-send", 3) \
_(SEND_DEL, "del-event-send", 4) \
_(SEND_REFRESH, "refresh-event-send", 5) \
_(RECV_ACK, "ack-recv", 6) \
_(SEND_ACK, "ack-send", 7) \
_(RETRY_COUNT, "retry-count", 8) \
_(MISSED_COUNT, "missed-count", 9)

Definition at line 24 of file nat_ha.c.

◆ foreach_nat_ha_error

#define foreach_nat_ha_error
Value:
_(PROCESSED, "pkts-processed") \
_(BAD_VERSION, "bad-version")

Definition at line 889 of file nat_ha.c.

◆ foreach_nat_ha_handoff_error

#define foreach_nat_ha_handoff_error
Value:
_(CONGESTION_DROP, "congestion drop") \
_(SAME_WORKER, "same worker") \
_(DO_HANDOFF, "do handoff")

Definition at line 1066 of file nat_ha.c.

◆ NAT_HA_FLAG_ACK

#define NAT_HA_FLAG_ACK   0x01

Definition at line 40 of file nat_ha.c.

◆ NAT_HA_RETRIES

#define NAT_HA_RETRIES   3

Definition at line 22 of file nat_ha.c.

◆ NAT_HA_VERSION

#define NAT_HA_VERSION   0x01

Definition at line 37 of file nat_ha.c.

◆ skip_if_disabled

#define skip_if_disabled ( )
Value:
do { \
nat_ha_main_t *ha = &nat_ha_main; \
if (PREDICT_TRUE (!ha->dst_port)) \
return; \
} while (0)
#define PREDICT_TRUE(x)
Definition: clib.h:112
nat_ha_main_t nat_ha_main
Definition: nat_ha.c:163

Definition at line 666 of file nat_ha.c.

Typedef Documentation

◆ nat_ha_main_t

typedef struct nat_ha_main_s nat_ha_main_t

Enumeration Type Documentation

◆ nat_ha_counter_t

Enumerator
NAT_HA_N_COUNTERS 

Definition at line 86 of file nat_ha.c.

◆ nat_ha_error_t

Enumerator
NAT_HA_N_ERROR 

Definition at line 893 of file nat_ha.c.

◆ nat_ha_event_type_t

Enumerator
NAT_HA_ADD 
NAT_HA_DEL 
NAT_HA_REFRESH 

Definition at line 43 of file nat_ha.c.

◆ nat_ha_handoff_error_t

Enumerator
NAT44_HANDOFF_N_ERROR 

Definition at line 1071 of file nat_ha.c.

◆ nat_ha_next_t

Enumerator
NAT_HA_NEXT_IP4_LOOKUP 
NAT_HA_NEXT_DROP 
NAT_HA_N_NEXT 

Definition at line 882 of file nat_ha.c.

Function Documentation

◆ format_nat_ha_handoff_trace()

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

Definition at line 1086 of file nat_ha.c.

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

◆ format_nat_ha_trace()

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

Definition at line 869 of file nat_ha.c.

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

◆ nat44_ha_resync()

int nat44_ha_resync ( u32  client_index,
u32  pid,
nat_ha_resync_event_cb_t  event_callback 
)

Definition at line 825 of file nat_ha.c.

+ Here is the call graph for this function:

◆ nat_ha_ack_recv()

static_always_inline void nat_ha_ack_recv ( u32  seq,
u32  thread_index 
)

Definition at line 206 of file nat_ha.c.

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

◆ nat_ha_event_add()

static_always_inline void nat_ha_event_add ( nat_ha_event_t event,
u8  do_flush,
u32  thread_index,
u8  is_resync 
)

Definition at line 571 of file nat_ha.c.

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

◆ nat_ha_event_process()

static_always_inline void nat_ha_event_process ( nat_ha_event_t event,
f64  now,
u32  thread_index 
)

Definition at line 478 of file nat_ha.c.

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

◆ nat_ha_flush()

void nat_ha_flush ( u8  is_resync)

Flush the current HA data (for testing)

Definition at line 674 of file nat_ha.c.

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

◆ nat_ha_get_failover()

void nat_ha_get_failover ( ip4_address_t addr,
u16 port,
u32 session_refresh_interval 
)

Get HA failover/remote settings.

Definition at line 403 of file nat_ha.c.

+ Here is the caller graph for this function:

◆ nat_ha_get_listener()

void nat_ha_get_listener ( ip4_address_t addr,
u16 port,
u32 path_mtu 
)

Get HA listener/local configuration.

Definition at line 378 of file nat_ha.c.

+ Here is the caller graph for this function:

◆ nat_ha_get_resync_status()

void nat_ha_get_resync_status ( u8 in_resync,
u32 resync_ack_missed 
)

Get resync status.

Parameters
in_resync1 if resync in progress
resync_ack_missednumber of missed (not ACKed) messages

Definition at line 816 of file nat_ha.c.

+ Here is the caller graph for this function:

◆ nat_ha_handoff_node_fn()

static uword nat_ha_handoff_node_fn ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 1100 of file nat_ha.c.

+ Here is the call graph for this function:

◆ nat_ha_header_create()

static void nat_ha_header_create ( vlib_buffer_t b,
u32 offset,
u32  thread_index 
)
inlinestatic

Definition at line 498 of file nat_ha.c.

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

◆ nat_ha_init()

void nat_ha_init ( vlib_main_t vm,
nat_ha_sadd_cb_t  sadd_cb,
nat_ha_sdel_cb_t  sdel_cb,
nat_ha_sref_cb_t  sref_cb 
)

Initialize NAT HA.

Definition at line 306 of file nat_ha.c.

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

◆ nat_ha_node_fn()

static uword nat_ha_node_fn ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t frame 
)
static

Definition at line 909 of file nat_ha.c.

+ Here is the call graph for this function:

◆ nat_ha_process()

static uword nat_ha_process ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 776 of file nat_ha.c.

+ Here is the call graph for this function:

◆ nat_ha_recv_add()

static_always_inline void nat_ha_recv_add ( nat_ha_event_t event,
f64  now,
u32  thread_index 
)

Definition at line 414 of file nat_ha.c.

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

◆ nat_ha_recv_del()

static_always_inline void nat_ha_recv_del ( nat_ha_event_t event,
u32  thread_index 
)

Definition at line 437 of file nat_ha.c.

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

◆ nat_ha_recv_refresh()

static_always_inline void nat_ha_recv_refresh ( nat_ha_event_t event,
f64  now,
u32  thread_index 
)

Definition at line 455 of file nat_ha.c.

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

◆ nat_ha_resend_queue_add()

static int nat_ha_resend_queue_add ( u32  seq,
u8 data,
u8  data_len,
u8  is_resync,
u32  thread_index 
)
static

Definition at line 187 of file nat_ha.c.

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

◆ nat_ha_resend_scan()

static void nat_ha_resend_scan ( f64  now,
u32  thread_index 
)
static

Definition at line 235 of file nat_ha.c.

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

◆ nat_ha_resync_fin()

static void nat_ha_resync_fin ( void  )
static

Definition at line 170 of file nat_ha.c.

+ Here is the caller graph for this function:

◆ nat_ha_sadd()

void nat_ha_sadd ( ip4_address_t in_addr,
u16  in_port,
ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
ip4_address_t ehn_addr,
u16  ehn_port,
u8  proto,
u32  fib_index,
u16  flags,
u32  thread_index,
u8  is_resync 
)

Create session add HA event.

Parameters
in_addrinside IPv4 address
in_portinside L4 port number
out_addroutside IPv4 address
out_portoutside L4 port number
eh_addrexternal host IPv4 address
eh_portexternal host L4 port number
ehn_addrexternal host IPv4 address after translation
ehn_portexternal host L4 port number after translation
protoL4 protocol
fib_indexfib index
flagssession flags
thread_indexthread index
is_resync1 if HA resync

Definition at line 681 of file nat_ha.c.

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

◆ nat_ha_sdel()

void nat_ha_sdel ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  thread_index 
)

Create session delete HA event.

Parameters
out_addroutside IPv4 address
out_portoutside L4 port number
eh_addrexternal host IPv4 address
eh_portexternal host L4 port number
protoL4 protocol
fib_indexfib index
thread_indexthread index

Definition at line 707 of file nat_ha.c.

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

◆ nat_ha_send()

static void nat_ha_send ( vlib_frame_t f,
vlib_buffer_t b,
u8  is_resync,
u32  thread_index 
)
inlinestatic

Definition at line 543 of file nat_ha.c.

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

◆ nat_ha_set_failover()

int nat_ha_set_failover ( ip4_address_t addr,
u16  port,
u32  session_refresh_interval 
)

Set HA failover (remote settings)

Parameters
addrfailover IP4 address
portfailvoer UDP port number
session_refresh_intervalnumber of seconds after which to send session counters refresh
Returns
0 on success, non-zero value otherwise.

Definition at line 388 of file nat_ha.c.

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

◆ nat_ha_set_listener()

int nat_ha_set_listener ( ip4_address_t addr,
u16  port,
u32  path_mtu 
)

Set HA listener (local settings)

Parameters
addrlocal IP4 address
portlocal UDP port number
path_mtupath MTU between local and failover
Returns
0 on success, non-zero value otherwise.

Definition at line 345 of file nat_ha.c.

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

◆ nat_ha_sref()

void nat_ha_sref ( ip4_address_t out_addr,
u16  out_port,
ip4_address_t eh_addr,
u16  eh_port,
u8  proto,
u32  fib_index,
u32  total_pkts,
u64  total_bytes,
u32  thread_index,
f64 last_refreshed,
f64  now 
)

Create session refresh HA event.

Parameters
out_addroutside IPv4 address
out_portoutside L4 port number
eh_addrexternal host IPv4 address
eh_portexternal host L4 port number
protoL4 protocol
fib_indexfib index
total_pktstotal packets processed
total_bytestotal bytes processed
thread_indexthread index
last_refreshedlast session refresh time
nowcurrent time

Definition at line 726 of file nat_ha.c.

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

◆ nat_ha_worker_fn()

static uword nat_ha_worker_fn ( vlib_main_t vm,
vlib_node_runtime_t rt,
vlib_frame_t f 
)
static

Definition at line 754 of file nat_ha.c.

+ Here is the call graph for this function:

Variable Documentation

◆ nat_ha_error_strings

char* nat_ha_error_strings[]
static
Initial value:
= {
#define _(sym, str)
}
#define foreach_nat_ha_error
Definition: nat_ha.c:889

Definition at line 901 of file nat_ha.c.

◆ nat_ha_handoff_error_strings

char* nat_ha_handoff_error_strings[]
static
Initial value:
= {
#define _(sym,string)
}
#define foreach_nat_ha_handoff_error
Definition: nat_ha.c:1066

Definition at line 1079 of file nat_ha.c.

◆ nat_ha_handoff_node

vlib_node_registration_t nat_ha_handoff_node
Initial value:
= {
.name = "nat-ha-handoff",
.vector_size = sizeof (u32),
.format_trace = format_nat_ha_handoff_trace,
.error_strings = nat_ha_handoff_error_strings,
.n_next_nodes = 1,
.next_nodes = {
[0] = "error-drop",
},
}
static char * nat_ha_handoff_error_strings[]
Definition: nat_ha.c:1079
static uword nat_ha_handoff_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat_ha.c:1100
unsigned int u32
Definition: types.h:88
static u8 * format_nat_ha_handoff_trace(u8 *s, va_list *args)
Definition: nat_ha.c:1086
#define ARRAY_LEN(x)
Definition: clib.h:62

(constructor) VLIB_REGISTER_NODE (nat_ha_handoff_node)

Definition at line 167 of file nat_ha.c.

◆ nat_ha_main

nat_ha_main_t nat_ha_main

Definition at line 163 of file nat_ha.c.

◆ nat_ha_node

Initial value:
= {
.function = nat_ha_node_fn,
.name = "nat-ha",
.vector_size = sizeof (u32),
.format_trace = format_nat_ha_trace,
.error_strings = nat_ha_error_strings,
.n_next_nodes = NAT_HA_N_NEXT,
.next_nodes = {
[NAT_HA_NEXT_IP4_LOOKUP] = "ip4-lookup",
[NAT_HA_NEXT_DROP] = "error-drop",
},
}
static u8 * format_nat_ha_trace(u8 *s, va_list *args)
Definition: nat_ha.c:869
static char * nat_ha_error_strings[]
Definition: nat_ha.c:901
unsigned int u32
Definition: types.h:88
#define ARRAY_LEN(x)
Definition: clib.h:62
static uword nat_ha_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat_ha.c:909

(constructor) VLIB_REGISTER_NODE (nat_ha_node)

Definition at line 166 of file nat_ha.c.

◆ nat_ha_process_node

vlib_node_registration_t nat_ha_process_node
Initial value:
= {
.function = nat_ha_process,
.name = "nat-ha-process",
}
static uword nat_ha_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: nat_ha.c:776

(constructor) VLIB_REGISTER_NODE (nat_ha_process_node)

Definition at line 164 of file nat_ha.c.

◆ nat_ha_worker_node

vlib_node_registration_t nat_ha_worker_node
Initial value:
= {
.function = nat_ha_worker_fn,
.state = VLIB_NODE_STATE_INTERRUPT,
.name = "nat-ha-worker",
}
static uword nat_ha_worker_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: nat_ha.c:754

(constructor) VLIB_REGISTER_NODE (nat_ha_worker_node)

Definition at line 165 of file nat_ha.c.