FD.io VPP  v21.01.1
Vector Packet Processing
cnat_translation.c File Reference
+ Include dependency graph for cnat_translation.c:

Go to the source code of this file.

Typedefs

typedef void(* cnat_if_addr_add_cb_t) (addr_resolution_t *ar, ip_address_t *address, u8 is_del)
 

Functions

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. More...
 
static void cnat_resolve_ep_tuple (cnat_endpoint_tuple_t *path)
 
void cnat_translation_unwatch_addr (u32 cti, cnat_addr_resol_type_t type)
 Cleanup matching addr resolution requests. More...
 
static void cnat_tracker_release (cnat_ep_trk_t *trk)
 
static void cnat_tracker_track (index_t cti, cnat_ep_trk_t *trk)
 
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. More...
 
static void cnat_remove_translation_from_db (index_t cci, cnat_endpoint_t *vip, ip_protocol_t proto)
 Remove a translation from the bihash. More...
 
static void cnat_translation_stack (cnat_translation_t *ct)
 
int cnat_translation_delete (u32 id)
 Delete a translation. More...
 
u32 cnat_translation_update (cnat_endpoint_t *vip, ip_protocol_t proto, cnat_endpoint_tuple_t *paths, u8 flags)
 create or update a translation More...
 
void cnat_translation_walk (cnat_translation_walk_cb_t cb, void *ctx)
 Walk/visit each of the translations. More...
 
static u8format_cnat_ep_trk (u8 *s, va_list *args)
 
u8format_cnat_translation (u8 *s, va_list *args)
 
static clib_error_tcnat_translation_show (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
int cnat_translation_purge (void)
 Purge all the trahslations. More...
 
static fib_node_tcnat_translation_get_node (fib_node_index_t index)
 
static cnat_translation_tcnat_translation_get_from_node (fib_node_t *node)
 
static void cnat_translation_last_lock_gone (fib_node_t *node)
 
static fib_node_back_walk_rc_t cnat_translation_back_walk_notify (fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
 
static clib_error_tcnat_translation_cli_add_del (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static void cnat_if_addr_add_del_translation_cb (addr_resolution_t *ar, ip_address_t *address, u8 is_del)
 
static void cnat_if_addr_add_del_backend_cb (addr_resolution_t *ar, ip_address_t *address, u8 is_del)
 
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_callback (u32 sw_if_index, ip_address_t *address, u8 is_del)
 
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)
 
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)
 
static clib_error_tcnat_translation_init (vlib_main_t *vm)
 

Variables

cnat_translation_tcnat_translation_pool
 
clib_bihash_8_8_t cnat_translation_db
 
addr_resolution_ttr_resolutions
 
cnat_if_addr_add_cb_tcnat_if_addr_add_cbs
 
static fib_node_type_t cnat_translation_fib_node_type
 
vlib_combined_counter_main_t cnat_translation_counters
 Counters for each translation. More...
 
static vlib_cli_command_t cnat_translation_show_cmd_node
 (constructor) VLIB_CLI_COMMAND (cnat_translation_show_cmd_node) More...
 
static const fib_node_vft_t cnat_translation_vft
 
static vlib_cli_command_t cnat_translation_cli_add_del_command
 (constructor) VLIB_CLI_COMMAND (cnat_translation_cli_add_del_command) More...
 

Typedef Documentation

◆ cnat_if_addr_add_cb_t

typedef void(* cnat_if_addr_add_cb_t) (addr_resolution_t *ar, ip_address_t *address, u8 is_del)

Definition at line 30 of file cnat_translation.c.

Function Documentation

◆ cnat_add_translation_to_db()

static void cnat_add_translation_to_db ( index_t  cci,
cnat_endpoint_t vip,
ip_protocol_t  proto,
index_t  cti 
)
static

Add a translation to the bihash.

Parameters
ccithe ID of the parent client (invalid if vip not resolved)
vipthe translation endpoint
protothe translation proto
ctithe translation index to be used as value

Definition at line 122 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_if_addr_add_del_backend_cb()

static void cnat_if_addr_add_del_backend_cb ( addr_resolution_t ar,
ip_address_t address,
u8  is_del 
)
static

Definition at line 579 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_if_addr_add_del_callback()

static void cnat_if_addr_add_del_callback ( u32  sw_if_index,
ip_address_t address,
u8  is_del 
)
static

Definition at line 647 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_if_addr_add_del_snat_cb()

static void cnat_if_addr_add_del_snat_cb ( addr_resolution_t ar,
ip_address_t address,
u8  is_del 
)
static

Definition at line 621 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_if_addr_add_del_translation_cb()

static void cnat_if_addr_add_del_translation_cb ( addr_resolution_t ar,
ip_address_t address,
u8  is_del 
)
static

Definition at line 546 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_ip4_if_addr_add_del_callback()

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 
)
static

Definition at line 675 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_ip6_if_addr_add_del_callback()

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 
)
static

Definition at line 663 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_remove_translation_from_db()

static void cnat_remove_translation_from_db ( index_t  cci,
cnat_endpoint_t vip,
ip_protocol_t  proto 
)
static

Remove a translation from the bihash.

Parameters
ccithe ID of the parent client
vipthe translation endpoint
protothe translation proto

Definition at line 154 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_resolve_ep_tuple()

static void cnat_resolve_ep_tuple ( cnat_endpoint_tuple_t path)
static

Definition at line 59 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_tracker_release()

static void cnat_tracker_release ( cnat_ep_trk_t trk)
static

Definition at line 84 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_tracker_track()

static void cnat_tracker_track ( index_t  cti,
cnat_ep_trk_t trk 
)
static

Definition at line 93 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_translation_back_walk_notify()

static fib_node_back_walk_rc_t cnat_translation_back_walk_notify ( fib_node_t node,
fib_node_back_walk_ctx_t ctx 
)
static

Definition at line 454 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_cli_add_del()

static clib_error_t* cnat_translation_cli_add_del ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 483 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_delete()

int cnat_translation_delete ( u32  id)

Delete a translation.

Parameters
idthe ID as returned from the create

Definition at line 205 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_translation_get_from_node()

static cnat_translation_t* cnat_translation_get_from_node ( fib_node_t node)
static

Definition at line 438 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_translation_get_node()

static fib_node_t* cnat_translation_get_node ( fib_node_index_t  index)
static

Definition at line 431 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_init()

static clib_error_t* cnat_translation_init ( vlib_main_t vm)
static

Definition at line 687 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_last_lock_gone()

static void cnat_translation_last_lock_gone ( fib_node_t node)
static

Definition at line 446 of file cnat_translation.c.

◆ cnat_translation_purge()

int cnat_translation_purge ( void  )

Purge all the trahslations.

Definition at line 400 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_translation_show()

static clib_error_t* cnat_translation_show ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 364 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_stack()

static void cnat_translation_stack ( cnat_translation_t ct)
static

Definition at line 178 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_translation_unwatch_addr()

void cnat_translation_unwatch_addr ( u32  cti,
cnat_addr_resol_type_t  type 
)

Cleanup matching addr resolution requests.

Definition at line 66 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_translation_update()

u32 cnat_translation_update ( cnat_endpoint_t vip,
ip_protocol_t  ip_proto,
cnat_endpoint_tuple_t backends,
u8  flags 
)

create or update a translation

Parameters
vipThe Virtual Endpoint
ip_protoThe ip protocol to translate
backendsthe backends to choose from
Returns
the ID of the translation. used to delete and gather stats

Definition at line 228 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cnat_translation_walk()

void cnat_translation_walk ( cnat_translation_walk_cb_t  cb,
void *  ctx 
)

Walk/visit each of the translations.

Definition at line 311 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ cnat_translation_watch_addr()

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.

Definition at line 42 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ format_cnat_ep_trk()

static u8* format_cnat_ep_trk ( u8 s,
va_list *  args 
)
static

Definition at line 325 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_cnat_translation()

u8* format_cnat_translation ( u8 s,
va_list *  args 
)

Definition at line 340 of file cnat_translation.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ cnat_if_addr_add_cbs

cnat_if_addr_add_cb_t* cnat_if_addr_add_cbs

Definition at line 32 of file cnat_translation.c.

◆ cnat_translation_cli_add_del_command

vlib_cli_command_t cnat_translation_cli_add_del_command
static
Initial value:
=
{
.path = "cnat translation",
.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]]",
}
static clib_error_t * cnat_translation_cli_add_del(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)

(constructor) VLIB_CLI_COMMAND (cnat_translation_cli_add_del_command)

Definition at line 537 of file cnat_translation.c.

◆ cnat_translation_counters

vlib_combined_counter_main_t cnat_translation_counters
Initial value:
= {
.name = "cnat-translation",
.stat_segment_name = "/net/cnat-translation",
}

Counters for each translation.

Definition at line 36 of file cnat_translation.c.

◆ cnat_translation_db

clib_bihash_8_8_t cnat_translation_db

Definition at line 27 of file cnat_translation.c.

◆ cnat_translation_fib_node_type

fib_node_type_t cnat_translation_fib_node_type
static

Definition at line 34 of file cnat_translation.c.

◆ cnat_translation_pool

cnat_translation_t* cnat_translation_pool

Definition at line 26 of file cnat_translation.c.

◆ cnat_translation_show_cmd_node

vlib_cli_command_t cnat_translation_show_cmd_node
static
Initial value:
= {
.path = "show cnat translation",
.function = cnat_translation_show,
.short_help = "show cnat translation <VIP>",
.is_mp_safe = 1,
}
static clib_error_t * cnat_translation_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)

(constructor) VLIB_CLI_COMMAND (cnat_translation_show_cmd_node)

Definition at line 422 of file cnat_translation.c.

◆ cnat_translation_vft

const fib_node_vft_t cnat_translation_vft
static
Initial value:
= {
}
static fib_node_back_walk_rc_t cnat_translation_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
static void cnat_translation_last_lock_gone(fib_node_t *node)
static fib_node_t * cnat_translation_get_node(fib_node_index_t index)

Definition at line 476 of file cnat_translation.c.

◆ tr_resolutions

addr_resolution_t* tr_resolutions

Definition at line 28 of file cnat_translation.c.