36 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",
115 keystr =
"src address";
119 keystr =
"dst address";
123 keystr =
"session id";
135 vlib_cli_output (vm,
"%U", format_l2t_session, session);
143 .path =
"show l2tpv3",
144 .short_help =
"show l2tpv3 [verbose]",
162 session_index = session - lm->sessions;
164 session_index_to_counter_index (session_index,
165 SESSION_COUNTER_USER_TO_NETWORK);
166 vlib_increment_combined_counter (&lm->counter_main,
170 vlib_increment_combined_counter (&lm->counter_main,
183 .path =
"test counters",
184 .short_help =
"increment all active counters",
201 session_index = session - lm->sessions;
203 session_index_to_counter_index (session_index,
204 SESSION_COUNTER_USER_TO_NETWORK);
205 vlib_zero_combined_counter (&lm->counter_main, counter_index);
206 vlib_zero_combined_counter (&lm->counter_main, counter_index+1);
216 .path =
"clear counters",
217 .short_help =
"clear all active counters",
225 u32 show_dev_instance = ~0;
230 if (show_dev_instance != ~0)
231 i = show_dev_instance;
233 return format (s,
"l2tpv3_tunnel%d", i);
237 u32 new_dev_instance)
252 clib_warning (
"you shouldn't be here, leaking buffers...");
268 uword max_rewrite_bytes)
281 u32 dev_instance = va_arg (*args,
u32);
282 s =
format (s,
"unimplemented dev %u", dev_instance);
295 u32 local_session_id,
296 u32 remote_session_id,
299 int l2_sublayer_present,
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);
333 return VNET_API_ERROR_INVALID_VALUE;
336 memset (s, 0,
sizeof (*s));
339 s->
local_cookie[0] = clib_host_to_net_u64 (local_cookie);
346 sizeof (l2tpv3_header_t) :
347 sizeof (l2tpv3_header_t) -
sizeof(l2tp_hdr.l2_specific_sublayer);
353 clib_memcpy (src_address_copy, client_address,
sizeof (*src_address_copy));
359 clib_memcpy (dst_address_copy, our_address,
sizeof (*dst_address_copy));
392 (vnm, l2tpv3_device_class.index, s - lm->
sessions,
393 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;
431 if (
unformat (line_input,
"client %U",
433 client_address_set = 1;
434 else if (
unformat (line_input,
"our %U",
437 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
439 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
441 else if (
unformat (line_input,
"local-session-id %d",
444 else if (
unformat (line_input,
"remote-session-id %d",
447 else if (
unformat (line_input,
"l2-sublayer-present"))
448 l2_sublayer_present = 1;
456 if (our_address_set == 0)
458 if (client_address_set == 0)
462 local_session_id, remote_session_id,
463 local_cookie, remote_cookie,
470 case VNET_API_ERROR_INVALID_VALUE:
473 case VNET_API_ERROR_NO_SUCH_ENTRY:
484 .path =
"create l2tpv3 tunnel",
486 "create l2tpv3 tunnel client <ip6> our <ip6> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec>",
492 u64 new_local_cookie,
493 u64 new_remote_cookie)
501 return VNET_API_ERROR_INVALID_VALUE;
506 s->
local_cookie[0] = clib_host_to_net_u64(new_local_cookie);
520 u32 sw_if_index = ~0;
521 u64 local_cookie = (
u64)~0, remote_cookie = (
u64)~0;
530 else if (
unformat (input,
"local %llx", &local_cookie))
532 else if (
unformat (input,
"remote %llx", &remote_cookie))
537 if (sw_if_index == ~0)
539 if (local_cookie == ~0)
541 if (remote_cookie == ~0)
545 local_cookie, remote_cookie);
552 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
564 .path =
"set l2tpv3 tunnel cookie",
566 "set l2tpv3 tunnel cookie <intfc> local <hex> remote <hex>",
582 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
605 u32 sw_if_index = ~0;
621 if (sw_if_index == ~0)
631 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
642 .path =
"set interface ip6 l2tpv3",
644 .short_help =
"set interface ip6 l2tpv3 <intfc> [del]",
653 if (
unformat (input,
"lookup-v6-src"))
655 else if (
unformat (input,
"lookup-v6-dst"))
657 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
u32 * config_index_by_sw_if_index
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
static u8 * format_l2tpv3_name(u8 *s, va_list *args)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
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]
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 *sw_if_index)
#define hash_set_mem(h, key, value)
unformat_function_t unformat_vnet_sw_interface
static u32 session_index_to_counter_index(u32 session_index, u32 counter_id)
always_inline vlib_main_t * vlib_get_main(void)
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)
#define VLIB_INIT_FUNCTION(x)
VNET_DEVICE_CLASS(l2tpv3_device_class, static)
always_inline uword pool_elts(void *v)
#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)
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)
#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
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)
always_inline void * clib_mem_alloc(uword size)
u32 * free_l2tpv3_tunnel_hw_if_indices
uword unformat_pg_l2tp_header(unformat_input_t *input, va_list *args)
#define clib_memcpy(a, b, c)
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format_l2t_session(u8 *s, va_list *args)
#define pool_is_free_index(P, I)
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
ip_lookup_main_t lookup_main
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)
uword * session_by_dst_address
vlib_combined_counter_main_t counter_main
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)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
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)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
#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
always_inline u32 counter_index(vlib_main_t *vm, vlib_error_t e)
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)