|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
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";
145 .path =
"show l2tpv3",
146 .short_help =
"show l2tpv3 [verbose]",
165 session_index = session - lm->
sessions;
188 .path =
"test lt2p counters",
189 .short_help =
"increment all active counters",
207 session_index = session - lm->
sessions;
223 .path =
"clear l2tp 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);
284 ip6_address_t * client_address,
285 ip6_address_t * our_address,
286 u32 local_session_id,
287 u32 remote_session_id,
290 int l2_sublayer_present,
298 l2tpv3_header_t l2tp_hdr;
299 ip6_address_t *dst_address_copy, *src_address_copy;
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));
384 hi->hw_instance =
hi->dev_instance;
389 (vnm, l2tpv3_device_class.index, s - lm->
sessions,
390 l2tpv3_hw_class.index, s - lm->
sessions);
416 ip6_address_t client_address, our_address;
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)
467 if (!(p =
hash_get (
im->fib_index_by_table_id, encap_fib_id)))
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,
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))
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);
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"))
705 if (
hi->hw_class_index != l2tpv3_hw_class.index)
708 u32 session_index =
hi->dev_instance;
728 (0,
sizeof (ip6_address_t) ,
731 (0,
sizeof (ip6_address_t) ,
vnet_interface_main_t * im
#define hash_set(h, key, value)
static clib_error_t * set_ip6_l2tpv3(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_HW_INTERFACE_CLASS(l2tpv3_hw_class)
static clib_error_t * l2tp_config(vlib_main_t *vm, unformat_input_t *input)
static vlib_cli_command_t set_interface_ip6_l2tpv3
(constructor) VLIB_CLI_COMMAND (set_interface_ip6_l2tpv3)
#define clib_memcpy(d, s, n)
static int l2tpv3_name_renumber(vnet_hw_interface_t *hi, u32 new_dev_instance)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u8 * format_l2t_trace(u8 *s, va_list *args)
clib_error_t * l2tp_init(vlib_main_t *vm)
vlib_main_t vlib_node_runtime_t * node
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
#define clib_error_return(e, args...)
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)
#define hash_set_mem(h, key, value)
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
uword * session_by_dst_address
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
static vlib_cli_command_t set_l2tp_tunnel_cookie_command
(constructor) VLIB_CLI_COMMAND (set_l2tp_tunnel_cookie_command)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
VLIB_WORKER_INIT_FUNCTION(l2tp_worker_init)
static clib_error_t * clear_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_l2t_session(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)
static u32 session_index_to_counter_index(u32 session_index, u32 counter_id)
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define hash_create_mem(elts, key_bytes, value_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
uword * session_by_session_id
Combined counter to hold both packets and byte differences.
ip6_to_l2_lookup_t lookup_type
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
u32 * free_l2tpv3_tunnel_hw_if_indices
ip6_address_t client_address
clib_error_t * l2tp_worker_init(vlib_main_t *vm)
static vlib_cli_command_t clear_counters_command
(constructor) VLIB_CLI_COMMAND (clear_counters_command)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
clib_error_t * l2tp_sw_interface_up_down(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
ip6_address_t client_address
static clib_error_t * test_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * set_l2tp_tunnel_cookie_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
counter_t packets
packet counter
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vnet_sw_interface_t * sw_interfaces
static u8 * format_l2tpv3_name(u8 *s, va_list *args)
static vlib_cli_command_t create_l2tpv3_tunnel_command
(constructor) VLIB_CLI_COMMAND (create_l2tpv3_tunnel_command)
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...
#define hash_get_mem(h, key)
uword * session_by_src_address
vlib_node_registration_t l2t_encap_node
(constructor) VLIB_REGISTER_NODE (l2t_encap_node)
format_function_t format_vnet_sw_if_index_name
unformat_function_t unformat_vnet_sw_interface
description fragment has unexpected format
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
#define VLIB_INIT_FUNCTION(x)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
ip6_address_t our_address
counter_t bytes
byte counter
static uword pool_elts(void *v)
Number of active elements in a pool.
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(l2tp_sw_interface_up_down)
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)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
VNET_DEVICE_CLASS(l2tpv3_device_class, static)
static u8 * format_l2tp_header_with_length(u8 *s, va_list *args)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
void l2tp_encap_init(vlib_main_t *vm)
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 placeholder) rewrite.
@ VNET_HW_INTERFACE_CLASS_FLAG_P2P
a point 2 point interface
void ip6_register_protocol(u32 protocol, u32 node_index)
vlib_node_registration_t l2t_decap_local_node
(constructor) VLIB_REGISTER_NODE (l2t_decap_local_node)
vlib_combined_counter_main_t counter_main
@ SESSION_COUNTER_USER_TO_NETWORK
uword unformat_pg_l2tp_header(unformat_input_t *input, va_list *args)
vl_api_interface_index_t sw_if_index
#define hash_create(elts, value_bytes)
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
static vlib_cli_command_t test_counters_command
(constructor) VLIB_CLI_COMMAND (test_counters_command)
unformat_function_t * unformat_pg_edit
static vlib_cli_command_t show_session_detail_command
(constructor) VLIB_CLI_COMMAND (show_session_detail_command)
static void * clib_mem_alloc(uword size)
static clib_error_t * create_l2tpv3_tunnel_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)
vnet_interface_main_t interface_main
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
ip6_address_t our_address
format_function_t format_vnet_sw_interface_name
vl_api_wireguard_peer_flags_t flags