FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
cnat_session.h File Reference
+ Include dependency graph for cnat_session.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cnat_session_t_
 A session represents the memory of a translation. More...
 

Typedefs

typedef struct cnat_session_t_ cnat_session_t
 A session represents the memory of a translation. More...
 
typedef enum cnat_session_flag_t_ cnat_session_flag_t
 
typedef enum cnat_session_location_t_ cnat_session_location_t
 
typedef walk_rc_t(* cnat_session_walk_cb_t) (const cnat_session_t *session, void *ctx)
 Callback function invoked during a walk of all translations. More...
 

Enumerations

enum  cnat_session_flag_t_ {
  CNAT_SESSION_FLAG_HAS_SNAT = (1 << 0), CNAT_SESSION_FLAG_ALLOC_PORT = (1 << 1), CNAT_SESSION_FLAG_NO_CLIENT = (1 << 2), CNAT_SESSION_FLAG_NO_NAT = (1 << 3),
  CNAT_SESSION_IS_RETURN = (1 << 4)
}
 
enum  cnat_session_location_t_ { CNAT_LOCATION_INPUT = 0, CNAT_LOCATION_OUTPUT = 1, CNAT_LOCATION_FIB = 0xff }
 

Functions

u8format_cnat_session (u8 *s, va_list *args)
 
 STATIC_ASSERT (STRUCT_OFFSET_OF(cnat_session_t, key)==STRUCT_OFFSET_OF(cnat_bihash_kv_t, key), "key overlaps")
 Ensure the session object correctly overlays the bihash key/value pair. More...
 
 STATIC_ASSERT (STRUCT_OFFSET_OF(cnat_session_t, value)==STRUCT_OFFSET_OF(cnat_bihash_kv_t, value), "value overlaps")
 
 STATIC_ASSERT (sizeof(cnat_session_t)==sizeof(cnat_bihash_kv_t), "session kvp")
 
void cnat_session_walk (cnat_session_walk_cb_t cb, void *ctx)
 Walk/visit each of the cnat session. More...
 
u64 cnat_session_scan (vlib_main_t *vm, f64 start_time, int i)
 Scan the session DB for expired sessions. More...
 
int cnat_session_purge (void)
 Purge all the sessions. More...
 
void cnat_session_free (cnat_session_t *session)
 Free a session & update refcounts. More...
 

Variables

cnat_bihash_t cnat_session_db
 The DB of sessions. More...
 
void(* cnat_free_port_cb )(u16 port, ip_protocol_t iproto)
 Port cleanup callback. More...
 

Typedef Documentation

◆ cnat_session_flag_t

◆ cnat_session_location_t

◆ cnat_session_t

A session represents the memory of a translation.

In the tx direction (from behind to in front of the NAT), the session is preserved so subsequent packets follow the same path even if the translation has been updated. In the tx direction the session represents the swap from the VIP to the server address In the RX direction the swap is from the server address/port to VIP.

A session exists only as key and value in the bihash, there is no pool for this object. If there were a pool, one would need to be concerned about what worker is using it.

◆ cnat_session_walk_cb_t

typedef walk_rc_t(* cnat_session_walk_cb_t) (const cnat_session_t *session, void *ctx)

Callback function invoked during a walk of all translations.

Definition at line 163 of file cnat_session.h.

Enumeration Type Documentation

◆ cnat_session_flag_t_

Enumerator
CNAT_SESSION_FLAG_HAS_SNAT 

Indicates a return path session that was source NATed on the way in.

CNAT_SESSION_FLAG_ALLOC_PORT 

This session source port was allocated, free it on cleanup.

CNAT_SESSION_FLAG_NO_CLIENT 

This session doesn't have a client, do not attempt to free it.

CNAT_SESSION_FLAG_NO_NAT 
CNAT_SESSION_IS_RETURN 

Definition at line 110 of file cnat_session.h.

◆ cnat_session_location_t_

Enumerator
CNAT_LOCATION_INPUT 
CNAT_LOCATION_OUTPUT 
CNAT_LOCATION_FIB 

Definition at line 134 of file cnat_session.h.

Function Documentation

◆ cnat_session_free()

void cnat_session_free ( cnat_session_t session)

Free a session & update refcounts.

Definition at line 144 of file cnat_session.c.

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

◆ cnat_session_purge()

int cnat_session_purge ( void  )

Purge all the sessions.

Definition at line 159 of file cnat_session.c.

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

◆ cnat_session_scan()

u64 cnat_session_scan ( vlib_main_t vm,
f64  start_time,
int  i 
)

Scan the session DB for expired sessions.

Definition at line 176 of file cnat_session.c.

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

◆ cnat_session_walk()

void cnat_session_walk ( cnat_session_walk_cb_t  cb,
void *  ctx 
)

Walk/visit each of the cnat session.

Definition at line 44 of file cnat_session.c.

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

◆ format_cnat_session()

u8* format_cnat_session ( u8 s,
va_list *  args 
)

Definition at line 92 of file cnat_session.c.

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

◆ STATIC_ASSERT() [1/3]

STATIC_ASSERT ( sizeof(cnat_session_t = =sizeof(cnat_bihash_kv_t),
"session kvp"   
)

◆ STATIC_ASSERT() [2/3]

STATIC_ASSERT ( STRUCT_OFFSET_OF(cnat_session_t, key = =STRUCT_OFFSET_OF(cnat_bihash_kv_tkey),
"key overlaps"   
)

Ensure the session object correctly overlays the bihash key/value pair.

◆ STATIC_ASSERT() [3/3]

STATIC_ASSERT ( STRUCT_OFFSET_OF(cnat_session_t, value = =STRUCT_OFFSET_OF(cnat_bihash_kv_tvalue),
"value overlaps"   
)

Variable Documentation

◆ cnat_free_port_cb

void(* cnat_free_port_cb) (u16 port, ip_protocol_t iproto)

Port cleanup callback.

Definition at line 24 of file cnat_session.c.

◆ cnat_session_db

cnat_bihash_t cnat_session_db

The DB of sessions.

Definition at line 23 of file cnat_session.c.