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);
268 u32 dev_instance = va_arg (*args,
u32);
269 s =
format (s,
"unimplemented dev %u", dev_instance);
286 u32 local_session_id,
287 u32 remote_session_id,
290 int l2_sublayer_present,
298 l2tpv3_header_t l2tp_hdr;
302 remote_session_id = clib_host_to_net_u32 (remote_session_id);
303 local_session_id = clib_host_to_net_u32 (local_session_id);
325 return VNET_API_ERROR_INVALID_VALUE;
332 s->
local_cookie[0] = clib_host_to_net_u64 (local_cookie);
339 sizeof (l2tpv3_header_t) :
340 sizeof (l2tpv3_header_t) -
sizeof (l2tp_hdr.l2_specific_sublayer);
350 sizeof (*src_address_copy));
356 clib_memcpy (dst_address_copy, our_address,
sizeof (*dst_address_copy));
389 (vnm, l2tpv3_device_class.index, s - lm->
sessions,
390 l2tpv3_hw_class.index, s - lm->
sessions);
419 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
420 u32 local_session_id = 1, remote_session_id = 1;
421 int our_address_set = 0, client_address_set = 0;
422 int l2_sublayer_present = 0;
425 u32 encap_fib_id = ~0;
426 u32 encap_fib_index = ~0;
435 if (
unformat (line_input,
"client %U",
437 client_address_set = 1;
438 else if (
unformat (line_input,
"our %U",
441 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
443 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
445 else if (
unformat (line_input,
"local-session-id %d",
448 else if (
unformat (line_input,
"remote-session-id %d",
451 else if (
unformat (line_input,
"fib-id %d", &encap_fib_id))
453 else if (
unformat (line_input,
"l2-sublayer-present"))
454 l2_sublayer_present = 1;
463 if (encap_fib_id != ~0)
472 encap_fib_index = p[0];
476 encap_fib_index = ~0;
479 if (our_address_set == 0)
484 if (client_address_set == 0)
491 local_session_id, remote_session_id,
492 local_cookie, remote_cookie,
494 encap_fib_index, &sw_if_index);
501 case VNET_API_ERROR_INVALID_VALUE:
505 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);
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>",
619 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
622 enable_disable, 0, 0);
647 if (sw_if_index == ~0)
657 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
662 "l2tp_interface_enable_disable returned %d",
671 .path =
"set interface ip6 l2tpv3",
673 .short_help =
"set interface ip6 l2tpv3 <intfc> [del]",
684 if (
unformat (input,
"lookup-v6-src"))
686 else if (
unformat (input,
"lookup-v6-dst"))
688 else if (
unformat (input,
"lookup-session-id"))
#define hash_set(h, key, value)
ip6_address_t client_address
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)
void ip6_register_protocol(u32 protocol, u32 node_index)
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
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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
#define clib_memcpy(d, s, n)
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.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
VNET_DEVICE_CLASS(l2tpv3_device_class, static)
#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,...)
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
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 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)
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)
vlib_node_registration_t l2t_decap_local_node
(constructor) VLIB_REGISTER_NODE (l2t_decap_local_node)
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)
uword * session_by_dst_address
static void * clib_mem_alloc(uword size)
vlib_combined_counter_main_t counter_main
counter_t bytes
byte counter
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.