39 ctx->
cb (session, ctx->
ctx);
41 return (BIHASH_WALK_CONTINUE);
67 return (BIHASH_WALK_CONTINUE);
81 "session:[%U;%d -> %U;%d, %U] => %U;%d -> %U;%d lb:%d age:%f",
112 BV (format_bihash), &cnat_session_db, verbose);
119 .path =
"show cnat session",
121 .short_help =
"show cnat session",
138 clib_bihash_add_del_40_48 (&cnat_session_db, bkey, 0 );
165 if (alloc_arena (
h) == 0)
168 for ( ; i <
h->nbuckets; i++)
174 if (i < (
h->nbuckets - 3))
176 BVT (clib_bihash_bucket) *
b =
177 BV (clib_bihash_get_bucket) (
h, i + 3);
179 b = BV (clib_bihash_get_bucket) (
h, i + 1);
180 if (!BV (clib_bihash_bucket_is_empty) (
b))
188 BVT (clib_bihash_bucket) *
b = BV (clib_bihash_get_bucket) (
h,
i);
189 if (BV (clib_bihash_bucket_is_empty) (
b))
192 for (j = 0; j < (1 <<
b->log2_pages); j++)
196 if (v->kvp[k].key[0] == ~0ULL && v->kvp[k].value[0] == ~0ULL)
211 if (BV (clib_bihash_bucket_is_empty) (
b))
258 .path =
"show cnat timestamp",
260 .short_help =
"show cnat timestamp",
static void clib_rwlock_reader_lock(clib_rwlock_t *p)
u64 cnat_session_scan(vlib_main_t *vm, f64 start_time, int i)
Scan the session DB for expired sessions.
This session source port was allocated, free it on cleanup.
#define BIHASH_KVP_PER_PAGE
void(* cnat_free_port_cb)(u16 port, ip_protocol_t iproto)
Port cleanup callback.
This session doesn't have a client, do not attempt to free it.
#define pool_foreach(VAR, POOL)
Iterate through pool.
static void cnat_timestamp_free(u32 index)
struct cnat_session_t_::@632 key
this key sits in the same memory location a 'key' in the bihash kvp
static f64 vlib_time_now(vlib_main_t *vm)
u16 cs_port[VLIB_N_DIR]
ports in rx/tx
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u8 * format_cnat_session(u8 *s, va_list *args)
void cnat_session_free(cnat_session_t *session)
Free a session & update refcounts.
clib_bihash_40_48_t cnat_session_db
The DB of sessions.
A session represents the memory of a translation.
u8 cs_af
The address family describing the IP addresses.
int cnat_session_purge(void)
Purge all the sessions.
#define VLIB_INIT_FUNCTION(x)
clib_bihash_kv_40_48_t * keys
description fragment has unexpected format
#define clib_error_return(e, args...)
ip46_address_t cs_ip[VLIB_N_DIR]
IP 4/6 address in the rx/tx direction.
u32 cs_ts_index
Timestamp index this session was last used.
enum ip_protocol ip_protocol_t
void clib_bihash_foreach_key_value_pair(clib_bihash *h, clib_bihash_foreach_key_value_pair_cb *callback, void *arg)
Visit active (key,value) pairs in a bi-hash table.
static void clib_rwlock_reader_unlock(clib_rwlock_t *p)
static int cnat_session_purge_walk(BVT(clib_bihash_kv) *key, void *arg)
cnat_timestamp_t * cnat_timestamps
static f64 cnat_timestamp_exp(u32 index)
void clib_bihash_init(clib_bihash *h, char *name, u32 nbuckets, uword memory_size)
initialize a bounded index extensible hash table
index_t cs_lbi
The load balance object to use to forward.
format_function_t format_ip46_address
static clib_error_t * cnat_session_init(vlib_main_t *vm)
#define CLIB_PREFETCH(addr, size, type)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static clib_error_t * cnat_timestamp_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int cnat_session_walk_cb(BVT(clib_bihash_kv) *kv, void *arg)
#define VLIB_CLI_COMMAND(x,...)
u32 flags
session flags if cs_lbi == INDEX_INVALID
struct cnat_session_purge_walk_t_ cnat_session_purge_walk_ctx_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void cnat_client_free_by_ip(ip46_address_t *ip, u8 af)
uword session_hash_memory
struct cnat_session_walk_ctx_t_ cnat_session_walk_ctx_t
template key/value backing page structure
ip_protocol_t cs_proto
The IP protocol TCP or UDP only supported.
walk_rc_t(* cnat_session_walk_cb_t)(const cnat_session_t *session, void *ctx)
Callback function invoked during a walk of all translations.
#define vec_foreach(var, vec)
Vector iterator.
cnat_session_walk_cb_t cb
static void * clib_bihash_get_value(clib_bihash *h, uword offset)
Get pointer to value page given its clib mheap offset.
static clib_error_t * cnat_session_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define CLIB_CACHE_LINE_BYTES
struct cnat_session_t_::@633 value
this value sits in the same memory location a 'value' in the bihash kvp
void cnat_session_walk(cnat_session_walk_cb_t cb, void *ctx)
Walk/visit each of the cnat session.