79 u32 *del_vec = NULL, *ai;
82 for (
int i = 0;
i < nthreads;
i++)
167 return (cc - cnat_client_pool);
238 original->
dpoi_proto, cc_clone - cnat_client_pool);
250 for (
int i = 0;
i < nthreads;
i++)
261 u32 indent = va_arg (*args,
u32);
265 s =
format (s,
"[%d] cnat-client:[%U] tr:%d sess:%d", cci,
269 s =
format (s,
" expires");
272 s =
format (s,
" exclusive");
275 s =
format (s,
"\n%Uclone of [%d]\n%U%U",
321 .path =
"show cnat client",
323 .short_help =
"show cnat client",
373 u32 indent = va_arg (*ap,
u32);
397 sizeof (ip6_address_t),
402 for (i = 0; i < nthreads; i++)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
fib_protocol_t fp_proto
protocol type
dpo_type_t cnat_client_dpo
dpo_lock_fn_t dv_lock
A reference counting lock function.
int cnat_client_purge(void)
Check all the clients were purged by translation & session purge.
static void cnat_client_dpo_lock(dpo_id_t *dpo)
#define hash_set(h, key, value)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
#define pool_foreach_index(i, v)
u32 session_refcnt
Session refcount for cleanup.
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
A virtual function table regisitered for a DPO type.
static void cnat_client_db_remove(cnat_client_t *cc)
ip_address_t ** throttle_pool
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
#define pool_foreach(VAR, POOL)
Iterate through pool.
static clib_error_t * cnat_client_init(vlib_main_t *vm)
dpo_proto_t dpoi_proto
the data-path protocol of the type.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
dpo_id_t cc_parent
How to send packets to this client post translation.
u8 * format_cnat_client_dpo(u8 *s, va_list *ap)
u32 tr_refcnt
Translations refcount for cleanup.
index_t parent_cci
Parent cnat_client index if cloned via interpose or own index if vanilla client.
static void cnat_client_dpo_unlock(dpo_id_t *dpo)
#define ip_addr_version(_a)
index_t cnat_client_add(const ip_address_t *ip, u8 flags)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
#define static_always_inline
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
#define VLIB_INIT_FUNCTION(x)
static const char *const cnat_client_dpo_ip6_nodes[]
description fragment has unexpected format
static_always_inline u32 cnat_client_uncnt_session(cnat_client_t *cc)
Del a session refcnt to this client.
Aggregate type for a prefix.
#define clib_error_return(e, args...)
void ip_address_to_fib_prefix(const ip_address_t *addr, fib_prefix_t *prefix)
convert from a IP address to a FIB prefix
static void cnat_client_db_add(cnat_client_t *cc)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
static void clib_spinlock_init(clib_spinlock_t *p)
static_always_inline u32 cnat_client_cnt_session(cnat_client_t *cc)
Add a session refcnt to this client.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
#define hash_create_mem(elts, key_bytes, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
fib_source_t cnat_fib_source
cnat_timestamp_t * cnat_timestamps
void cnat_client_throttle_pool_process()
#define pool_put(P, E)
Free an object E in pool P.
static const char *const *const cnat_client_dpo_nodes[DPO_PROTO_NUM]
u8 * format_cnat_client(u8 *s, va_list *args)
static_always_inline cnat_client_t * cnat_client_ip4_find(const ip4_address_t *ip)
Find a client from an IP4 address.
static const char *const cnat_client_dpo_ip4_nodes[]
static_always_inline cnat_client_t * cnat_client_get(index_t i)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
int fib_entry_is_sourced(fib_node_index_t fib_entry_index, fib_source_t source)
fib_node_index_t cc_fei
the FIB entry this client sources
clib_spinlock_t * throttle_pool_lock
void cnat_client_translation_added(index_t cci)
A translation that references this VIP was added.
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
sll srl srl sll sra u16x4 i
u8 * format_ip_address(u8 *s, va_list *args)
u32 fib_node_index_t
A typedef of a node index.
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
u32 cc_locks
number of DPO locks
static clib_error_t * cnat_client_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
static void cnat_client_destroy(cnat_client_t *cc)
static uword hash_elts(void *v)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
void cnat_client_learn(const cnat_learn_arg_t *l)
Called in the main thread by RPC from the workers to learn a new client.
static void cnat_client_dpo_interpose(const dpo_id_t *original, const dpo_id_t *parent, dpo_id_t *clone)
Interpose a policy DPO.
void cnat_client_translation_deleted(index_t cci)
A translation that references this VIP was deleted.
ip_address_family_t version
void cnat_client_free_by_ip(ip46_address_t *ip, u8 af)
static void hash_unset_mem_free(uword **h, const void *key)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
static_always_inline cnat_client_t * cnat_client_ip6_find(const ip6_address_t *ip)
Find a client from an IP6 address.
static_always_inline u8 cnat_client_is_clone(cnat_client_t *cc)
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
cnat_client_db_t cnat_client_db
ip_address_t cc_ip
the client's IP address
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
static vlib_thread_main_t * vlib_get_thread_main()
cnat_client_t * cnat_client_pool
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
static void hash_set_mem_alloc(uword **h, const void *key, uword v)
#define CLIB_CACHE_LINE_BYTES
A client is a representation of an IP address behind the NAT.
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
static uword pool_elts(void *v)
Number of active elements in a pool.