37 .
name =
"cnat-translation",
38 .stat_segment_name =
"/net/cnat-translation",
75 vec_add1(indexes, ar - tr_resolutions);
130 key = key << 16 | vip->
ce_port;
136 key = key << 16 | vip->
ce_port;
137 key = key << 32 | (
u32) cci;
162 key = key << 16 | vip->
ce_port;
168 key = key << 16 | vip->
ce_port;
169 key = key << 32 | (
u32) cci;
211 return (VNET_API_ERROR_NO_SUCH_ENTRY);
222 pool_put (cnat_translation_pool, ct);
328 u32 indent = va_arg (*args,
u32);
355 s =
format (s,
"\n via:");
403 index_t tri, *trp, *trs = NULL;
423 .path =
"show cnat translation",
425 .short_help =
"show cnat translation <VIP>",
503 else if (
unformat (line_input,
"del %d", &del_index))
539 .path =
"cnat translation",
540 .short_help =
"cnat translation [add|del] proto [TCP|UDP] [vip|real] [ip|sw_if_index [v6]] [port] [to [ip|sw_if_index [v6]] [port]->[ip|sw_if_index [v6]] [port]]",
666 u32 address_length,
u32 if_address_index,
678 u32 address_length,
u32 if_address_index,
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
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...
#define pool_foreach_index(i, v)
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
ip4_add_del_interface_address_callback_t * add_del_interface_address_callbacks
Functions to call when interface address changes.
vl_api_wireguard_peer_flags_t flags
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
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.
#define pool_foreach(VAR, POOL)
Iterate through pool.
static void cnat_if_addr_add_del_backend_cb(addr_resolution_t *ar, ip_address_t *address, u8 is_del)
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)
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).
static void cnat_add_translation_to_db(index_t cci, cnat_endpoint_t *vip, ip_protocol_t proto, index_t cti)
Add a translation to the bihash.
#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.
static void cnat_if_addr_add_del_snat_cb(addr_resolution_t *ar, ip_address_t *address, u8 is_del)
static void cnat_if_addr_add_del_translation_cb(addr_resolution_t *ar, ip_address_t *address, u8 is_del)
#define ip_addr_version(_a)
#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)
cnat_if_addr_add_cb_t * cnat_if_addr_add_cbs
u32 sw_if_index
The interface index to resolve.
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.
static void cnat_resolve_ep_tuple(cnat_endpoint_tuple_t *path)
#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)
void cnat_translation_watch_addr(index_t cti, u64 opaque, cnat_endpoint_t *ep, cnat_addr_resol_type_t type)
Add an address resolution request.
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)
description fragment has unexpected format
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.
void cnat_translation_unwatch_addr(u32 cti, cnat_addr_resol_type_t type)
Cleanup matching addr resolution requests.
static cnat_translation_t * cnat_translation_get_from_node(fib_node_t *node)
int cnat_translation_purge(void)
Purge all the trahslations.
vl_api_fib_path_type_t type
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 INDEX_INVALID if vip is unresolved. ...
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.
cnat_addr_resol_type_t type
The cnat_addr_resolution_t.
u8 * format_cnat_endpoint(u8 *s, va_list *args)
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
An node in the FIB graph.
static fib_node_type_t cnat_translation_fib_node_type
ip6_add_del_interface_address_callback_t * add_del_interface_address_callbacks
cnat_ep_trk_t * ct_paths
The vector of tracked back-ends.
static_always_inline cnat_client_t * cnat_client_get(index_t i)
fib_node_t ct_node
Linkage into the FIB graph.
static void cnat_tracker_track(index_t cti, cnat_ep_trk_t *trk)
void cnat_client_translation_added(index_t cci)
A translation that references this VIP was added.
#define vec_free(V)
Free vector's memory (no header).
ip4_add_del_interface_address_function_t * function
addr_resolution_t * tr_resolutions
Entry used to account for a translation's backend waiting for address resolution. ...
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.
#define VLIB_CLI_COMMAND(x,...)
static void cnat_if_addr_add_del_callback(u32 sw_if_index, ip_address_t *address, u8 is_del)
ip6_add_del_interface_address_function_t * function
static clib_error_t * cnat_translation_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip_address_family_t af
ip4 or ip6 resolution
#define pool_put_index(p, i)
Free pool element with given index.
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,...)
manual_print typedef address
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 is_active
Allows to disable if not resolved yet.
static void cnat_remove_translation_from_db(index_t cci, cnat_endpoint_t *vip, ip_protocol_t proto)
Remove a translation from the bihash.
u8 * format_cnat_translation(u8 *s, va_list *args)
ip_address_family_t version
index_t cti
Translation index.
static void cnat_ip4_if_addr_add_del_callback(struct ip4_main_t *im, uword opaque, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 if_address_index, u32 is_del)
u8 cnat_resolve_addr(u32 sw_if_index, ip_address_family_t af, ip_address_t *addr)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
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 cnat_translation_update(cnat_endpoint_t *vip, ip_protocol_t proto, cnat_endpoint_tuple_t *paths, u8 flags)
create or update a translation
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 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 ip_address_copy(ip_address_t *dst, const ip_address_t *src)
ip4_main_t ip4_main
Global ip4 main structure.
void(* cnat_if_addr_add_cb_t)(addr_resolution_t *ar, ip_address_t *address, u8 is_del)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
import vnet interface_types api
Data used to track an EP in the FIB.
u8 cnat_resolve_ep(cnat_endpoint_t *ep)
Resolve endpoint address.
static void cnat_ip6_if_addr_add_del_callback(struct ip6_main_t *im, uword opaque, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 if_address_index, u32 is_del)
index_t index
Own index (if copied for trace)
void cnat_lazy_init()
Lazy initialization when first adding a translation or using snat.
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.
vl_api_interface_index_t sw_if_index
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.