25 #include <vpp/app/version.h> 34 .arc_name =
"ip4-unicast",
35 .node_name =
"det44-in2out",
37 "ip4-sv-reassembly-feature"),
40 .arc_name =
"ip4-unicast",
41 .node_name =
"det44-out2in",
43 "ip4-sv-reassembly-feature",
44 "ip4-dhcp-client-detect"),
47 .version = VPP_BUILD_VER,
48 .description =
"Deterministic NAT (CGN)",
61 .ip4.as_u32 = addr->
as_u32,
125 return VNET_API_ERROR_VALUE_EXIST;
128 if (!found && !is_add)
129 return VNET_API_ERROR_NO_SUCH_ENTRY;
139 mp->
sharing_ratio = (1 << (32 - in_plen)) / (1 << (32 - out_plen));
144 1, empty_snat_det_session);
199 const char *feature_name;
217 feature_name = is_inside ?
"det44-in2out" :
"det44-out2in";
224 return VNET_API_ERROR_INVALID_VALUE;
232 sw_if_index, 1, 0, 0);
242 det44_log_err (
"det44 is already enabled on this interface");
243 return VNET_API_ERROR_INVALID_VALUE;
251 sw_if_index, 1, 0, 0);
296 if (!is_del && !found)
307 mp->
out_plen, sw_if_index, !is_del);
464 if (new_fib_index == old_fib_index)
487 if (outside_fib->
fib_index == old_fib_index)
498 if (outside_fib->
fib_index == new_fib_index)
556 #define _(v, N, str) case DET44_SESSION_##N: t = (u8 *) str; break; 560 t =
format (t,
"unknown");
571 u32 in_offset, out_offset;
573 u32 *
i = va_arg (*args,
u32 *);
577 clib_host_to_net_u32 (clib_net_to_host_u32 (det_map->
in_addr.
as_u32) +
580 clib_net_to_host_u32 (in_addr.
as_u32) -
584 clib_host_to_net_u32 (clib_net_to_host_u32 (det_map->
out_addr.
as_u32) +
588 "in %U:%d out %U:%d external host %U:%d state: %U expire: %d\n",
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
ip4_table_bind_function_t * function
int det44_plugin_enable(det44_config_t c)
struct nat_timeouts_t::@86 tcp
int det44_plugin_disable()
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL)
Iterate through pool.
static clib_error_t * det44_init(vlib_main_t *vm)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
#define det44_log_err(...)
add paths without path extensions
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Deterministic NAT (CGN) definitions.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
unformat_function_t unformat_vnet_sw_interface
VNET_FEATURE_INIT(ip4_det44_in2out, static)
#define DET44_INTERFACE_FLAG_IS_INSIDE
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static_always_inline void nat_reset_timeouts(nat_timeouts_t *timeouts)
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
det44_fib_t * outside_fibs
static_always_inline u8 plugin_enabled()
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define VLIB_INIT_FUNCTION(x)
ip4_address_t ext_host_addr
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
static void det44_update_outside_fib(ip4_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
nat_timeouts_t det44_get_timeouts()
description fragment has unexpected format
Aggregate type for a prefix.
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
#define FIB_SOURCE_PRIORITY_HI
Some priority values that plugins might use when they are not to concerned where in the list they'll ...
snat_det_session_t * sessions
u32 vlib_process_create(vlib_main_t *vm, char *name, vlib_node_function_t *f, u32 log2_n_stack_bytes)
Create a vlib process.
u8 * format_det44_session_state(u8 *s, va_list *args)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define DET44_INTERFACE_FLAG_IS_OUTSIDE
#define vec_del1(v, i)
Delete the element at index I.
void det44_reset_timeouts()
snat_det_map_t * det_maps
#define pool_free(p)
Free a pool.
u8 * format_det_map_ses(u8 *s, va_list *args)
void det44_add_del_addr_to_fib(ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
static_always_inline void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
vlib_main_t vlib_node_runtime_t * node
int det44_set_timeouts(nat_timeouts_t *timeouts)
#define DET44_SES_PER_USER
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
#define det44_interface_is_inside(i)
Check if Deterministic NAT interface is inside.
static uword det44_expire_walk_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
The 'det44-expire-walk' process's main loop.
int snat_det_add_map(ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
Add/delete deterministic NAT mapping.
#define FIB_SOURCE_PRIORITY_LOW
#define VNET_FEATURES(...)
static vlib_main_t * vlib_get_main(void)
void det44_create_expire_walk_process()
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
det44_interface_t * interfaces
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define det44_interface_is_outside(i)
Check if Deterministic NAT interface is outside.
clib_error_t * det44_api_hookup(vlib_main_t *vm)
vlib_log_class_t log_class
int det44_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
ip4_main_t ip4_main
Global ip4 main structure.
#define vec_foreach(var, vec)
Vector iterator.
u32 expire_walk_node_index
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
vl_api_interface_index_t sw_if_index
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)