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...");
277 u32 dev_instance = va_arg (*args,
u32);
278 s =
format (s,
"unimplemented dev %u", dev_instance);
295 u32 local_session_id,
296 u32 remote_session_id,
299 int l2_sublayer_present,
300 u32 encap_fib_index,
u32 * sw_if_index)
307 l2tpv3_header_t l2tp_hdr;
311 remote_session_id = clib_host_to_net_u32 (remote_session_id);
312 local_session_id = clib_host_to_net_u32 (local_session_id);
334 return VNET_API_ERROR_INVALID_VALUE;
337 memset (s, 0,
sizeof (*s));
341 s->
local_cookie[0] = clib_host_to_net_u64 (local_cookie);
348 sizeof (l2tpv3_header_t) :
349 sizeof (l2tpv3_header_t) -
sizeof (l2tp_hdr.l2_specific_sublayer);
359 sizeof (*src_address_copy));
365 clib_memcpy (dst_address_copy, our_address,
sizeof (*dst_address_copy));
398 (vnm, l2tpv3_device_class.index, s - lm->
sessions,
399 l2tpv3_hw_class.index, s - lm->
sessions);
422 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
423 u32 local_session_id = 1, remote_session_id = 1;
424 int our_address_set = 0, client_address_set = 0;
425 int l2_sublayer_present = 0;
428 u32 encap_fib_id = ~0;
429 u32 encap_fib_index = ~0;
438 if (
unformat (line_input,
"client %U",
440 client_address_set = 1;
441 else if (
unformat (line_input,
"our %U",
444 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
446 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
448 else if (
unformat (line_input,
"local-session-id %d",
451 else if (
unformat (line_input,
"remote-session-id %d",
454 else if (
unformat (line_input,
"fib-id %d", &encap_fib_id))
456 else if (
unformat (line_input,
"l2-sublayer-present"))
457 l2_sublayer_present = 1;
466 if (encap_fib_id != ~0)
475 encap_fib_index = p[0];
479 encap_fib_index = ~0;
482 if (our_address_set == 0)
487 if (client_address_set == 0)
494 local_session_id, remote_session_id,
495 local_cookie, remote_cookie,
497 encap_fib_index, &sw_if_index);
504 case VNET_API_ERROR_INVALID_VALUE:
508 case VNET_API_ERROR_NO_SUCH_ENTRY:
526 .path =
"create l2tpv3 tunnel",
528 "create l2tpv3 tunnel client <ip6> our <ip6> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec>",
536 u64 new_local_cookie,
u64 new_remote_cookie)
544 return VNET_API_ERROR_INVALID_VALUE;
549 s->
local_cookie[0] = clib_host_to_net_u64 (new_local_cookie);
563 u32 sw_if_index = ~0;
564 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
573 else if (
unformat (input,
"local %llx", &local_cookie))
575 else if (
unformat (input,
"remote %llx", &remote_cookie))
580 if (sw_if_index == ~0)
582 if (local_cookie == ~0)
584 if (remote_cookie == ~0)
588 local_cookie, remote_cookie);
595 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
609 .path =
"set l2tpv3 tunnel cookie",
611 "set l2tpv3 tunnel cookie <intfc> local <hex> remote <hex>",
618 u32 sw_if_index,
int enable_disable)
622 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
625 enable_disable, 0, 0);
634 u32 sw_if_index = ~0;
650 if (sw_if_index == ~0)
660 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
665 "l2tp_interface_enable_disable returned %d",
674 .path =
"set interface ip6 l2tpv3",
676 .short_help =
"set interface ip6 l2tpv3 <intfc> [del]",
687 if (
unformat (input,
"lookup-v6-src"))
689 else if (
unformat (input,
"lookup-v6-dst"))
691 else if (
unformat (input,
"lookup-session-id"))
#define hash_set(h, key, value)
ip6_address_t client_address
sll srl srl sll sra u16x4 i
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)
vnet_main_t * vnet_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)
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)
unformat_function_t * unformat_pg_edit
VLIB_WORKER_INIT_FUNCTION(l2tp_worker_init)
#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_error_return(e, 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)
counter_t packets
packet counter
u8 * format_l2t_trace(u8 *s, va_list *args)
#define VLIB_CONFIG_FUNCTION(x, n,...)
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)
static_always_inline uword vlib_get_thread_index(void)
static void vlib_get_combined_counter(const 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 per-thr...
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_warning(format, 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.
u8 * default_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Return a complete, zero-length (aka dummy) rewrite.
#define VLIB_CLI_COMMAND(x,...)
clib_error_t * l2tp_worker_init(vlib_main_t *vm)
#define hash_create(elts, value_bytes)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
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)
uword * session_by_dst_address
static void * clib_mem_alloc(uword size)
vlib_combined_counter_main_t counter_main
counter_t bytes
byte counter
void l2tp_decap_init(void)
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
a point 2 point interface
#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)
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)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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)
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.