32 .
name =
"cnat-translation",
33 .stat_segment_name =
"/net/cnat-translation",
72 key = (proto << 16) | port;
73 key = key << 32 | (
u32) cci;
87 key = (proto << 16) | port;
88 key = key << 32 | (
u32) cci;
123 return (VNET_API_ERROR_NO_SUCH_ENTRY);
134 pool_put (cnat_translation_pool, ct);
211 u32 indent = va_arg (*args,
u32);
238 s =
format (s,
"\n via:");
286 index_t tri, *trp, *trs = NULL;
306 .path =
"show cnat translation",
308 .short_help =
"show cnat translation <VIP>",
374 else if (
unformat (input,
"del %d", &del_index))
404 .path =
"cnat translation",
405 .short_help =
"cnat translation [add|del] proto [TCP|UDP] [vip|real] [ip] [port] [to [ip] [port]->[ip] [port]]",
walk_rc_t(* cnat_translation_walk_cb_t)(index_t index, void *ctx)
Callback function invoked during a walk of all translations.
fib_protocol_t fp_proto
protocol type
dpo_type_t cnat_client_dpo
static fib_node_back_walk_rc_t cnat_translation_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
fib_node_index_t fib_entry_track(u32 fib_index, const fib_prefix_t *prefix, fib_node_type_t child_type, index_t child_index, u32 *sibling)
Trackers are used on FIB entries by objects that which to track the changing state of the entry...
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
vl_api_wireguard_peer_flags_t flags
static_always_inline cnat_translation_t * cnat_translation_get(index_t cti)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
static clib_error_t * cnat_translation_cli_add_del(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
static void cnat_tracker_release(cnat_ep_trk_t *trk)
void cnat_remove_translation_from_db(index_t cci, u16 port, ip_protocol_t proto)
Remove a translation from the bihash.
static void cnat_translation_last_lock_gone(fib_node_t *node)
ip_protocol_t ct_proto
The ip protocol for the translation.
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).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
A Translation represents the translation of a VEP to one of a set of real server addresses.
#define STRUCT_OFFSET_OF(t, f)
index_t parent_cci
Parent cnat_client index if cloned via interpose or own index if vanilla client.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
index_t cnat_client_add(const ip_address_t *ip, u8 flags)
fib_node_type_t fib_node_register_new_type(const fib_node_vft_t *vft)
Create a new FIB node type and Register the function table for it.
cnat_translation_t * cnat_translation_pool
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define clib_memcpy(d, s, n)
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
uword unformat_cnat_ep(unformat_input_t *input, va_list *args)
load_balance_t * load_balance_pool
Pool of all DPOs.
cnat_endpoint_t ct_vip
The Virtual end point.
static_always_inline cnat_translation_t * cnat_find_translation(index_t cti, u16 port, ip_protocol_t proto)
#define VLIB_INIT_FUNCTION(x)
u32 cnat_translation_update(const cnat_endpoint_t *vip, ip_protocol_t proto, const cnat_endpoint_tuple_t *paths, u8 flags)
create or update a translation
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
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
static cnat_translation_t * cnat_translation_get_from_node(fib_node_t *node)
int cnat_translation_purge(void)
Purge all the trahslations.
enum ip_protocol ip_protocol_t
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
index_t ct_cci
The client object this translation belongs on.
int cnat_translation_delete(u32 id)
Delete a translation.
static clib_error_t * cnat_translation_init(vlib_main_t *vm)
load-balancing over a choice of [un]equal cost paths
static void cnat_translation_stack(cnat_translation_t *ct)
#define pool_put(P, E)
Free an object E in pool P.
dpo_id_t ct_dpo
The forwarding contributed by the entry.
u8 * format_cnat_endpoint(u8 *s, va_list *args)
An node in the FIB graph.
static fib_node_type_t cnat_translation_fib_node_type
cnat_ep_trk_t * ct_paths
The vector of tracked back-ends.
static_always_inline cnat_client_t * cnat_client_get(index_t i)
#define pool_free(p)
Free a pool.
fib_node_t ct_node
Linkage into the FIB graph.
void cnat_client_translation_added(index_t cci)
A translation that references this VIP was added.
static void cnat_tracker_track(index_t cti, const cnat_endpoint_tuple_t *path, cnat_ep_trk_t *trk)
#define vec_free(V)
Free vector's memory (no header).
static fib_node_t * cnat_translation_get_node(fib_node_index_t index)
static u8 * format_cnat_ep_trk(u8 *s, va_list *args)
u32 fib_node_index_t
A typedef of a node index.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
cnat_endpoint_t ct_ep[VLIB_N_DIR]
The EP being tracked.
8 octet key, 8 octet key value pair
fib_protocol_t ip_address_family_to_fib_proto(ip_address_family_t af)
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.
vlib_main_t vlib_node_runtime_t * node
Context passed between object during a back walk.
vl_api_fib_path_t paths[n_paths]
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * cnat_translation_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void fib_entry_untrack(fib_node_index_t fei, u32 sibling)
Stop tracking a FIB entry.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
dpo_id_t ct_lb
The LB used to forward to the backends.
void cnat_client_translation_deleted(index_t cci)
A translation that references this VIP was deleted.
u8 * format_cnat_translation(u8 *s, va_list *args)
ip_address_family_t version
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
void load_balance_set_bucket(index_t lbi, u32 bucket, const dpo_id_t *next)
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
u32 translation_hash_buckets
void cnat_translation_walk(cnat_translation_walk_cb_t cb, void *ctx)
Walk/visit each of the translations.
index_t dpoi_index
the index of objects of that type
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
uword unformat_cnat_ep_tuple(unformat_input_t *input, va_list *args)
clib_bihash_8_8_t cnat_translation_db
char * name
The counter collection's name.
fib_node_index_t ct_fei
The FIB entry for the EP.
uword translation_hash_memory
A collection of combined counters.
A FIB graph nodes virtual function table.
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
void cnat_add_translation_to_db(index_t cci, u16 port, ip_protocol_t proto, index_t cti)
Add a translation to the bihash.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
#define pool_foreach_index(i, v, body)
Iterate pool by index.
import vnet interface_types api
Data used to track an EP in the FIB.
index_t index
Own index (if copied for trace)
u8 flags
Translation flags.
fib_forward_chain_type_t fib_forw_chain_type_from_fib_proto(fib_protocol_t proto)
Convert from a fib-protocol to a chain type.
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.
u32 ct_sibling
The sibling on the entry's child list.
static uword pool_elts(void *v)
Number of active elements in a pool.