24 #include <vpp/app/version.h> 40 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 46 #define vl_api_version(n,v) static u32 api_version=(v); 50 #define REPLY_MSG_ID_BASE cmp->msg_id_base 57 #define foreach_ct6_plugin_api_msg \ 58 _(CT6_ENABLE_DISABLE, ct6_enable_disable) 70 clib_bihash_init_48_8 (&cmp->
session_hash,
"ct6 session table",
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);
115 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
120 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
123 sw_if_index, enable_disable, 0, 0);
135 int enable_disable = 1;
157 if (sw_if_index == ~0)
170 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
172 (0,
"Invalid interface, only works on physical ports");
186 "set ct6 [inside|outside] <interface-name> [disable]",
218 vl_msg_api_set_handlers((VL_API_##N + cmp->msg_id_base), \ 220 vl_api_##n##_t_handler, \ 222 vl_api_##n##_t_endian, \ 223 vl_api_##n##_t_print, \ 224 sizeof(vl_api_##n##_t), 1); 231 #define vl_msg_name_crc_list 233 #undef vl_msg_name_crc_list 238 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n #crc, id + cmp->msg_id_base); 239 foreach_vl_msg_name_crc_ct6;
253 name =
format (0,
"ct6_%08x%c", api_version, 0);
288 .arc_name =
"ip6-unicast",
289 .node_name =
"ct6-out2in",
297 .arc_name =
"interface-output",
298 .node_name =
"ct6-in2out",
306 .version = VPP_BUILD_VER,
307 .description =
"IPv6 Connection Tracker",
315 int i = va_arg (*args,
int);
317 int verbose = va_arg (*args,
int);
322 s =
format (s,
"\n%6s%6s%40s%6s%40s%6s",
323 "Sess",
"Prot",
"Src",
"Sport",
"Dst",
"Dport");
327 s =
format (s,
"\n%6d%6d%40U%6u%40U%6u",
330 clib_net_to_host_u16 (s0->
key.sport),
332 clib_net_to_host_u16 (s0->
key.dport));
336 if (clib_bihash_search_48_8 (&cmp->
session_hash, &kvp0, &kvp0) < 0)
338 s =
format (s,
" LOOKUP FAIL!");
353 s =
format (s,
" BOGUS LOOKUP RESULT!");
373 if (
unformat (input,
"verbose %d", &verbose))
375 else if (
unformat (input,
"verbose"))
380 s =
format (s,
"Thread %d: %d sessions\n", i,
393 s = format (s,
"%U", format_ct6_session, cmp, i, s0, verbose);
405 .path =
"show ip6 connection-tracker",
406 .short_help =
"show ip6 connection-tracker",
416 v0 = clib_net_to_host_u64 (a->
as_u64[0]);
417 v1 = clib_net_to_host_u64 (a->
as_u64[1]);
422 a->
as_u64[0] = clib_net_to_host_u64 (v0);
423 a->
as_u64[1] = clib_net_to_host_u64 (v1);
434 ct6_session_key_t *key0;
437 u32 recycled = 0, created = 0;
438 int i, num_sessions = 5;
446 if (
unformat (input,
"num-sessions %d", &num_sessions))
459 memset (src, 0,
sizeof (src));
460 memset (dst, 0,
sizeof (dst));
472 key0 = (ct6_session_key_t *) & kvp0;
473 memset (&kvp0, 0,
sizeof (kvp0));
475 for (i = 0; i < num_sessions; i++)
481 key0->sport = clib_host_to_net_u16 (1234);
482 key0->dport = clib_host_to_net_u16 (4321);
486 (cmp, &kvp0, 3.0 , 0 ,
487 &recycled, &created);
502 s = format (s,
"%U", format_ct6_session, cmp, 0, s0, 1 );
522 s = format (s,
"%U", format_ct6_session, cmp, 0, s0, 1 );
537 .path =
"test ip6 connection-tracker",
538 .short_help =
"test ip6 connection-tracker",
550 if (
unformat (input,
"session-hash-buckets %u",
553 else if (
unformat (input,
"session-hash-memory %U",
556 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
#define clib_memcpy_fast(a, b, c)
static void setup_message_id_table(ct6_main_t *cmp, api_main_t *am)
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.
#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)
static clib_error_t * ct6_plugin_api_hookup(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)
API main structure, used by both vpp and binary API clients.
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)
#define foreach_ct6_plugin_api_msg
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 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)
u16 vl_msg_api_get_msg_ids(const char *name, int n)
static uword pool_elts(void *v)
Number of active elements in a pool.