38 ctx->
cb (session, ctx->
ctx);
40 return (BIHASH_WALK_CONTINUE);
66 return (BIHASH_WALK_CONTINUE);
80 "session:[%U;%d -> %U;%d, %U] => %U;%d -> %U;%d lb:%d age:%f",
111 BV (format_bihash), &cnat_session_db, verbose);
118 .path =
"show cnat session",
120 .short_help =
"show cnat session",
136 clib_bihash_add_del_40_48 (&cnat_session_db, bkey, 0 );
163 if (alloc_arena (
h) == 0)
166 for (i = 0; i <
h->nbuckets; i++)
172 if (i < (
h->nbuckets - 3))
174 BVT (clib_bihash_bucket) * b =
175 BV (clib_bihash_get_bucket) (
h, i + 3);
177 b = BV (clib_bihash_get_bucket) (
h, i + 1);
178 if (!BV (clib_bihash_bucket_is_empty) (b))
186 BVT (clib_bihash_bucket) * b = BV (clib_bihash_get_bucket) (
h,
i);
187 if (BV (clib_bihash_bucket_is_empty) (b))
190 for (j = 0; j < (1 << b->log2_pages); j++)
194 if (v->kvp[k].key[0] == ~0ULL && v->kvp[k].value[0] == ~0ULL)
209 if (BV (clib_bihash_bucket_is_empty) (b))
256 .path =
"show cnat timestamp",
258 .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.
#define BIHASH_KVP_PER_PAGE
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)
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 pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
clib_bihash_kv_40_48_t * keys
#define clib_error_return(e, args...)
static void cnat_free_port(u16 port)
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.
static f64 cnat_timestamp_exp(u32 index)
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 void cnat_timestamp_free(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
Indicates a return path session that was source NATed on the way in.
struct cnat_session_purge_walk_t_ cnat_session_purge_walk_ctx_t
struct cnat_session_t_::@637 value
this value sits in the same memory location a 'value' in the bihash kvp
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.
struct cnat_session_t_::@636 key
this key sits in the same memory location a 'key' in the bihash kvp
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
void cnat_session_walk(cnat_session_walk_cb_t cb, void *ctx)
Walk/visit each of the cnat session.