37 s =
format (s,
"L2T: %U (client) -> %U (our) session %d",
41 s =
format (s,
"L2T: %U (our) -> %U (client) session %d)",
55 s =
format (s,
"[%d] %U (our) %U (client) %U (sw_if_index %d)\n",
63 s =
format (s,
" local cookies %016llx %016llx remote cookie %016llx\n",
68 s =
format (s,
" local session-id %d remote session-id %d\n",
72 s =
format (s,
" l2 specific sublayer %s\n",
81 s =
format (s,
" user-to-net: %llu pkts %llu bytes\n",
87 s =
format (s,
" net-to-user: %llu pkts %llu bytes\n",
114 keystr =
"src address";
118 keystr =
"dst address";
122 keystr =
"session id";
135 vlib_cli_output (vm,
"%U", format_l2t_session, session);
145 .path =
"show l2tpv3",
146 .short_help =
"show l2tpv3 [verbose]",
165 session_index = session - lm->sessions;
167 session_index_to_counter_index (session_index,
168 SESSION_COUNTER_USER_TO_NETWORK);
169 vlib_increment_combined_counter (&lm->counter_main,
173 vlib_increment_combined_counter (&lm->counter_main,
188 .path =
"test counters",
189 .short_help =
"increment all active counters",
207 session_index = session - lm->sessions;
209 session_index_to_counter_index (session_index,
210 SESSION_COUNTER_USER_TO_NETWORK);
211 vlib_zero_combined_counter (&lm->counter_main, counter_index);
212 vlib_zero_combined_counter (&lm->counter_main, counter_index+1);
223 .path =
"clear counters",
224 .short_help =
"clear all active counters",
234 u32 show_dev_instance = ~0;
239 if (show_dev_instance != ~0)
240 i = show_dev_instance;
242 return format (s,
"l2tpv3_tunnel%d", i);
261 clib_warning (
"you shouldn't be here, leaking buffers...");
278 void *dst_address,
void *rewrite,
uword max_rewrite_bytes)
292 u32 dev_instance = va_arg (*args,
u32);
293 s =
format (s,
"unimplemented dev %u", dev_instance);
309 u32 local_session_id,
310 u32 remote_session_id,
313 int l2_sublayer_present,
314 u32 encap_fib_index,
u32 * sw_if_index)
321 l2tpv3_header_t l2tp_hdr;
325 remote_session_id = clib_host_to_net_u32 (remote_session_id);
326 local_session_id = clib_host_to_net_u32 (local_session_id);
348 return VNET_API_ERROR_INVALID_VALUE;
351 memset (s, 0,
sizeof (*s));
355 s->
local_cookie[0] = clib_host_to_net_u64 (local_cookie);
362 sizeof (l2tpv3_header_t) :
363 sizeof (l2tpv3_header_t) -
sizeof (l2tp_hdr.l2_specific_sublayer);
373 sizeof (*src_address_copy));
379 clib_memcpy (dst_address_copy, our_address,
sizeof (*dst_address_copy));
412 (vnm, l2tpv3_device_class.index, s - lm->
sessions,
413 l2tpv3_hw_class.index, s - lm->
sessions);
436 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
437 u32 local_session_id = 1, remote_session_id = 1;
438 int our_address_set = 0, client_address_set = 0;
439 int l2_sublayer_present = 0;
442 u32 encap_fib_id = ~0;
443 u32 encap_fib_index = ~0;
451 if (
unformat (line_input,
"client %U",
453 client_address_set = 1;
454 else if (
unformat (line_input,
"our %U",
457 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
459 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
461 else if (
unformat (line_input,
"local-session-id %d",
464 else if (
unformat (line_input,
"remote-session-id %d",
467 else if (
unformat (line_input,
"fib-id %d", &encap_fib_id))
469 else if (
unformat (line_input,
"l2-sublayer-present"))
470 l2_sublayer_present = 1;
478 if (encap_fib_id != ~0)
484 encap_fib_index = p[0];
488 encap_fib_index = ~0;
491 if (our_address_set == 0)
493 if (client_address_set == 0)
497 local_session_id, remote_session_id,
498 local_cookie, remote_cookie,
500 encap_fib_index, &sw_if_index);
507 case VNET_API_ERROR_INVALID_VALUE:
510 case VNET_API_ERROR_NO_SUCH_ENTRY:
523 .path =
"create l2tpv3 tunnel",
525 "create l2tpv3 tunnel client <ip6> our <ip6> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec>",
533 u64 new_local_cookie,
u64 new_remote_cookie)
541 return VNET_API_ERROR_INVALID_VALUE;
546 s->
local_cookie[0] = clib_host_to_net_u64 (new_local_cookie);
560 u32 sw_if_index = ~0;
561 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
570 else if (
unformat (input,
"local %llx", &local_cookie))
572 else if (
unformat (input,
"remote %llx", &remote_cookie))
577 if (sw_if_index == ~0)
579 if (local_cookie == ~0)
581 if (remote_cookie == ~0)
585 local_cookie, remote_cookie);
592 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
606 .path =
"set l2tpv3 tunnel cookie",
608 "set l2tpv3 tunnel cookie <intfc> local <hex> remote <hex>",
615 u32 sw_if_index,
int enable_disable)
625 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
634 ci, feature_index, &config,
sizeof (config));
644 u32 sw_if_index = ~0;
660 if (sw_if_index == ~0)
670 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
675 "l2tp_interface_enable_disable returned %d",
684 .path =
"set interface ip6 l2tpv3",
686 .short_help =
"set interface ip6 l2tpv3 <intfc> [del]",
697 if (
unformat (input,
"lookup-v6-src"))
699 else if (
unformat (input,
"lookup-v6-dst"))
701 else if (
unformat (input,
"lookup-session-id"))
u64 packets
packet counter
#define hash_set(h, key, value)
ip6_address_t client_address
sll srl srl sll sra u16x4 i
u32 * config_index_by_sw_if_index
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
static u8 * format_l2tpv3_name(u8 *s, va_list *args)
static vlib_main_t * vlib_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
uword * session_by_session_id
ip6_address_t our_address
vlib_node_registration_t l2t_encap_node
(constructor) VLIB_REGISTER_NODE (l2t_encap_node)
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Combined counter to hold both packets and byte differences.
#define hash_set_mem(h, key, value)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static u32 session_index_to_counter_index(u32 session_index, u32 counter_id)
format_function_t format_vnet_sw_if_index_name
VNET_HW_INTERFACE_CLASS(l2tpv3_hw_class)
ip6_address_t client_address
static int l2tpv3_name_renumber(vnet_hw_interface_t *hi, u32 new_dev_instance)
vnet_main_t * vnet_get_main(void)
unformat_function_t * unformat_pg_edit
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
VNET_DEVICE_CLASS(l2tpv3_device_class, static)
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
#define clib_warning(format, args...)
clib_error_t * l2tp_init(vlib_main_t *vm)
void l2tp_encap_init(vlib_main_t *vm)
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
static clib_error_t * test_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
static clib_error_t * set_l2tp_tunnel_cookie_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_create_mem(elts, key_bytes, value_bytes)
format_function_t format_vnet_sw_interface_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
u8 * format_l2t_trace(u8 *s, va_list *args)
uword os_get_cpu_number(void)
static void vlib_get_combined_counter(vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of mini co...
#define VLIB_CONFIG_FUNCTION(x, n,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static uword dummy_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
ip6_to_l2_lookup_t lookup_type
uword * fib_index_by_table_id
ip6_address_t our_address
static clib_error_t * create_l2tpv3_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 * free_l2tpv3_tunnel_hw_if_indices
clib_error_t * l2tp_sw_interface_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
uword unformat_pg_l2tp_header(unformat_input_t *input, va_list *args)
#define clib_memcpy(a, b, c)
u8 * format_l2t_session(u8 *s, va_list *args)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define hash_create(elts, value_bytes)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
ip_lookup_main_t lookup_main
int create_l2tpv3_ipv6_tunnel(l2t_main_t *lm, ip6_address_t *client_address, ip6_address_t *our_address, u32 local_session_id, u32 remote_session_id, u64 local_cookie, u64 remote_cookie, int l2_sublayer_present, u32 encap_fib_index, u32 *sw_if_index)
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
u32 ip6_unicast_rx_feature_l2tp_decap
uword * session_by_dst_address
static void * clib_mem_alloc(uword size)
vlib_combined_counter_main_t counter_main
void l2tp_decap_init(void)
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
static clib_error_t * l2tp_config(vlib_main_t *vm, unformat_input_t *input)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vnet_sw_interface_t * sw_interfaces
#define hash_get_mem(h, key)
static clib_error_t * clear_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_l2tp_header_with_length(u8 *s, va_list *args)
static clib_error_t * show_l2tp_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(l2tp_sw_interface_up_down)
#define clib_error_return(e, args...)
uword * session_by_src_address
#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)
vnet_config_main_t config_main
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
static clib_error_t * set_ip6_l2tpv3(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword pool_elts(void *v)
Number of active elements in a pool.