24 #include <vpp/app/version.h> 27 #include <ct6/ct6.api_enum.h> 28 #include <ct6/ct6.api_types.h> 30 #define REPLY_MSG_ID_BASE cmp->msg_id_base 45 clib_bihash_init_48_8 (&cmp->
session_hash,
"ct6 session table",
65 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
70 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
73 sw_if_index, enable_disable, 0, 0);
90 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
95 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
98 sw_if_index, enable_disable, 0, 0);
110 int enable_disable = 1;
132 if (sw_if_index == ~0)
145 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
147 (0,
"Invalid interface, only works on physical ports");
161 "set ct6 [inside|outside] <interface-name> [disable]",
170 vl_api_ct6_enable_disable_reply_t *rmp;
187 #include <ct6/ct6.api.c> 222 .arc_name =
"ip6-unicast",
223 .node_name =
"ct6-out2in",
231 .arc_name =
"interface-output",
232 .node_name =
"ct6-in2out",
240 .version = VPP_BUILD_VER,
241 .description =
"IPv6 Connection Tracker",
249 int i = va_arg (*args,
int);
251 int verbose = va_arg (*args,
int);
256 s =
format (s,
"\n%6s%6s%40s%6s%40s%6s",
257 "Sess",
"Prot",
"Src",
"Sport",
"Dst",
"Dport");
261 s =
format (s,
"\n%6d%6d%40U%6u%40U%6u",
264 clib_net_to_host_u16 (s0->
key.sport),
266 clib_net_to_host_u16 (s0->
key.dport));
270 if (clib_bihash_search_48_8 (&cmp->
session_hash, &kvp0, &kvp0) < 0)
272 s =
format (s,
" LOOKUP FAIL!");
287 s =
format (s,
" BOGUS LOOKUP RESULT!");
307 if (
unformat (input,
"verbose %d", &verbose))
309 else if (
unformat (input,
"verbose"))
314 s =
format (s,
"Thread %d: %d sessions\n", i,
327 s = format (s,
"%U", format_ct6_session, cmp, i, s0, verbose);
339 .path =
"show ip6 connection-tracker",
340 .short_help =
"show ip6 connection-tracker",
350 v0 = clib_net_to_host_u64 (a->
as_u64[0]);
351 v1 = clib_net_to_host_u64 (a->
as_u64[1]);
356 a->
as_u64[0] = clib_net_to_host_u64 (v0);
357 a->
as_u64[1] = clib_net_to_host_u64 (v1);
368 ct6_session_key_t *key0;
371 u32 recycled = 0, created = 0;
372 int i, num_sessions = 5;
380 if (
unformat (input,
"num-sessions %d", &num_sessions))
393 memset (src, 0,
sizeof (src));
394 memset (dst, 0,
sizeof (dst));
406 key0 = (ct6_session_key_t *) & kvp0;
407 memset (&kvp0, 0,
sizeof (kvp0));
409 for (i = 0; i < num_sessions; i++)
415 key0->sport = clib_host_to_net_u16 (1234);
416 key0->dport = clib_host_to_net_u16 (4321);
420 (cmp, &kvp0, 3.0 , 0 ,
421 &recycled, &created);
436 s = format (s,
"%U", format_ct6_session, cmp, 0, s0, 1 );
456 s = format (s,
"%U", format_ct6_session, cmp, 0, s0, 1 );
471 .path =
"test ip6 connection-tracker",
472 .short_help =
"test ip6 connection-tracker",
484 if (
unformat (input,
"session-hash-buckets %u",
487 else if (
unformat (input,
"session-hash-memory %U",
490 else if (
unformat (input,
"session-timeout %f",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
vnet_main_t * vnet_get_main(void)
static clib_error_t * test_ct6_command_fn_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_interface_main_t interface_main
vl_api_interface_index_t sw_if_index
#define clib_memcpy_fast(a, b, c)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
int ct6_in2out_enable_disable(ct6_main_t *cmp, u32 sw_if_index, int enable_disable)
ct6_session_t ** sessions
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
static void vl_api_ct6_enable_disable_t_handler(vl_api_ct6_enable_disable_t *mp)
#define clib_error_return(e, args...)
static clib_error_t * ct6_init(vlib_main_t *vm)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
VNET_FEATURE_INIT(ct6out2in, static)
u8 * format_ct6_session(u8 *s, va_list *args)
uword session_hash_memory
#define VLIB_CONFIG_FUNCTION(x, n,...)
ct6_session_t * ct6_create_or_recycle_session(ct6_main_t *cmp, clib_bihash_kv_48_8_t *kvpp, f64 now, u32 my_thread_index, u32 *recyclep, u32 *createp)
static clib_error_t * set_ct6_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define BAD_SW_IF_INDEX_LABEL
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * ct6_config(vlib_main_t *vm, unformat_input_t *input)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
int ct6_out2in_enable_disable(ct6_main_t *cmp, u32 sw_if_index, int enable_disable)
#define VLIB_CLI_COMMAND(x,...)
static void ct6_update_session_hit(ct6_main_t *cmp, ct6_session_t *s0, f64 now)
static clib_error_t * show_ct6_command_fn_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_registration_t ct6_in2out_node
(constructor) VLIB_REGISTER_NODE (ct6_in2out_node)
#define VNET_FEATURES(...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vnet_sw_interface_t * sw_interfaces
clib_bihash_48_8_t session_hash
static void ct6_feature_init(ct6_main_t *cmp)
vnet_sw_interface_type_t type
static u32 vlib_num_workers()
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
static void increment_v6_address(ip6_address_t *a)
#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)
u32 max_sessions_per_worker
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
f64 session_timeout_interval
static void ethernet_setup_node(vlib_main_t *vm, u32 node_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)
#define VALIDATE_SW_IF_INDEX(mp)
static uword pool_elts(void *v)
Number of active elements in a pool.