FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
cnat_translation.c File Reference
+ Include dependency graph for cnat_translation.c:

Go to the source code of this file.

Data Structures

struct  cnat_maglev_entry_t
 

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)
 
u8format_cnat_lb_type (u8 *s, va_list *args)
 
uword unformat_cnat_lb_type (unformat_input_t *input, va_list *args)
 
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 int cnat_maglev_entry_compare (void *_a, void *_b)
 
static void cnat_translation_init_maglev (cnat_translation_t *ct)
 
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, cnat_lb_type_t lb_type)
 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_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)
 
void cnat_translation_register_addr_add_cb (cnat_addr_resol_type_t typ, cnat_if_addr_add_cb_t fn)
 
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...
 

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 148 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 733 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 775 of file cnat_translation.c.

+ 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 700 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 802 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 790 of file cnat_translation.c.

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

◆ cnat_maglev_entry_compare()

static int cnat_maglev_entry_compare ( void *  _a,
void *  _b 
)
static

Definition at line 212 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 180 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 56 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 80 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 89 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 607 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 636 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 342 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 591 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 584 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 822 of file cnat_translation.c.

+ Here is the call graph for this function:

◆ cnat_translation_init_maglev()

static void cnat_translation_init_maglev ( cnat_translation_t ct)
static

Definition at line 231 of file cnat_translation.c.

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

◆ cnat_translation_last_lock_gone()

static void cnat_translation_last_lock_gone ( fib_node_t node)
static

Definition at line 599 of file cnat_translation.c.

◆ cnat_translation_purge()

int cnat_translation_purge ( void  )

Purge all the trahslations.

Definition at line 557 of file cnat_translation.c.

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

◆ cnat_translation_register_addr_add_cb()

void cnat_translation_register_addr_add_cb ( cnat_addr_resol_type_t  typ,
cnat_if_addr_add_cb_t  fn 
)

Definition at line 814 of file cnat_translation.c.

+ 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 523 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 309 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 63 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,
cnat_lb_type_t  lb_type 
)

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 366 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 451 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 39 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 463 of file cnat_translation.c.

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

◆ format_cnat_lb_type()

u8* format_cnat_lb_type ( u8 s,
va_list *  args 
)

Definition at line 114 of file cnat_translation.c.

+ Here is the caller graph for this function:

◆ format_cnat_translation()

u8* format_cnat_translation ( u8 s,
va_list *  args 
)

Definition at line 478 of file cnat_translation.c.

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

◆ unformat_cnat_lb_type()

uword unformat_cnat_lb_type ( unformat_input_t input,
va_list *  args 
)

Definition at line 127 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 29 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]]",
}

(constructor) VLIB_CLI_COMMAND (cnat_translation_cli_add_del_command)

Definition at line 692 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 33 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 31 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,
}

(constructor) VLIB_CLI_COMMAND (cnat_translation_show_cmd_node)

Definition at line 576 of file cnat_translation.c.

◆ cnat_translation_vft

const fib_node_vft_t cnat_translation_vft
static
Initial value:

Definition at line 629 of file cnat_translation.c.

◆ tr_resolutions

addr_resolution_t* tr_resolutions

Definition at line 28 of file cnat_translation.c.

cnat_translation_get_node
static fib_node_t * cnat_translation_get_node(fib_node_index_t index)
Definition: cnat_translation.c:584
cnat_translation_show
static clib_error_t * cnat_translation_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cnat_translation.c:523
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)
Definition: cnat_translation.c:607
cnat_translation_last_lock_gone
static void cnat_translation_last_lock_gone(fib_node_t *node)
Definition: cnat_translation.c:599
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)
Definition: cnat_translation.c:636