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

NAT plugin client-IP based session affinity for load-balancing. More...

+ Include dependency graph for nat44_ed_affinity.c:

Go to the source code of this file.

Macros

#define AFFINITY_HASH_BUCKETS   65536
 
#define AFFINITY_HASH_MEMORY   (2 << 25)
 

Functions

u8format_affinity_kvp (u8 *s, va_list *args)
 
void nat_affinity_enable ()
 NAT affinity enable. More...
 
void nat_affinity_disable ()
 NAT affinity disable. More...
 
clib_error_tnat_affinity_init (vlib_main_t *vm)
 Initialize NAT client-IP based affinity. More...
 
static_always_inline void make_affinity_kv (clib_bihash_kv_16_8_t *kv, ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port)
 
u32 nat_affinity_get_per_service_list_head_index (void)
 Get new affinity per service list head index. More...
 
void nat_affinity_flush_service (u32 affinity_per_service_list_head_index)
 Flush all service affinity data. More...
 
int nat_affinity_find_and_lock (vlib_main_t *vm, ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port, u8 *backend_index)
 Find service backend index for client-IP and take a reference counting lock. More...
 
static int affinity_is_expired_cb (clib_bihash_kv_16_8_t *kv, void *arg)
 
int nat_affinity_create_and_lock (ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port, u8 backend_index, u32 sticky_time, u32 affinity_per_service_list_head_index)
 Create affinity record and take reference counting lock. More...
 
void nat_affinity_unlock (ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port)
 Release a reference counting lock for affinity. More...
 

Variables

nat_affinity_main_t nat_affinity_main
 

Detailed Description

NAT plugin client-IP based session affinity for load-balancing.

Definition in file nat44_ed_affinity.c.

Macro Definition Documentation

◆ AFFINITY_HASH_BUCKETS

#define AFFINITY_HASH_BUCKETS   65536

Definition at line 27 of file nat44_ed_affinity.c.

◆ AFFINITY_HASH_MEMORY

#define AFFINITY_HASH_MEMORY   (2 << 25)

Definition at line 28 of file nat44_ed_affinity.c.

Function Documentation

◆ affinity_is_expired_cb()

static int affinity_is_expired_cb ( clib_bihash_kv_16_8_t kv,
void *  arg 
)
static

Definition at line 185 of file nat44_ed_affinity.c.

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

◆ format_affinity_kvp()

u8* format_affinity_kvp ( u8 s,
va_list *  args 
)

Definition at line 31 of file nat44_ed_affinity.c.

+ Here is the caller graph for this function:

◆ make_affinity_kv()

static_always_inline void make_affinity_kv ( clib_bihash_kv_16_8_t kv,
ip4_address_t  client_addr,
ip4_address_t  service_addr,
u8  proto,
u16  service_port 
)

Definition at line 82 of file nat44_ed_affinity.c.

+ Here is the caller graph for this function:

◆ nat_affinity_create_and_lock()

int nat_affinity_create_and_lock ( ip4_address_t  client_addr,
ip4_address_t  service_addr,
u8  proto,
u16  service_port,
u8  backend_index,
u32  sticky_time,
u32  affinity_per_service_list_head_index 
)

Create affinity record and take reference counting lock.

Parameters
client_addrClient IP address.
service_addrService IP address.
protoIP protocol number.
service_portService L4 port number.
backend_indexService backend index for client-IP.
sticky_timeAffinity sticky time in seconds.
affinity_per_service_list_head_indexPer sevice list head index.
Returns
0 on success, non-zero value otherwise.

Definition at line 209 of file nat44_ed_affinity.c.

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

◆ nat_affinity_disable()

void nat_affinity_disable ( )

NAT affinity disable.

Definition at line 63 of file nat44_ed_affinity.c.

+ Here is the call graph for this function:

◆ nat_affinity_enable()

void nat_affinity_enable ( )

NAT affinity enable.

Definition at line 49 of file nat44_ed_affinity.c.

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

◆ nat_affinity_find_and_lock()

int nat_affinity_find_and_lock ( vlib_main_t vm,
ip4_address_t  client_addr,
ip4_address_t  service_addr,
u8  proto,
u16  service_port,
u8 backend_index 
)

Find service backend index for client-IP and take a reference counting lock.

Parameters
client_addrClient IP address.
service_addrService IP address.
protoIP protocol number.
service_portService L4 port number.
backend_indexService backend index for client-IP if found.
Returns
0 on success, non-zero value otherwise.

Definition at line 143 of file nat44_ed_affinity.c.

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

◆ nat_affinity_flush_service()

void nat_affinity_flush_service ( u32  affinity_per_service_list_head_index)

Flush all service affinity data.

Parameters
affinity_per_service_list_head_indexPer sevice list head index.

Definition at line 112 of file nat44_ed_affinity.c.

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

◆ nat_affinity_get_per_service_list_head_index()

u32 nat_affinity_get_per_service_list_head_index ( void  )

Get new affinity per service list head index.

Returns
new affinity per service list head index.

Definition at line 96 of file nat44_ed_affinity.c.

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

◆ nat_affinity_init()

clib_error_t* nat_affinity_init ( vlib_main_t vm)

Initialize NAT client-IP based affinity.

Parameters
vmvlib main.
Returns
error code.

Definition at line 74 of file nat44_ed_affinity.c.

+ Here is the caller graph for this function:

◆ nat_affinity_unlock()

void nat_affinity_unlock ( ip4_address_t  client_addr,
ip4_address_t  service_addr,
u8  proto,
u16  service_port 
)

Release a reference counting lock for affinity.

Parameters
client_addrClient IP address.
service_addrService IP address.
protoIP protocol number.

Definition at line 261 of file nat44_ed_affinity.c.

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

Variable Documentation

◆ nat_affinity_main

nat_affinity_main_t nat_affinity_main

Definition at line 25 of file nat44_ed_affinity.c.