20 #include <vnet/devices/pci/ixge.h> 57 s =
format (s,
"L2T: %U (client) -> %U (our) session %d",
61 s =
format (s,
"L2T: %U (our) -> %U (client) session %d)",
75 s =
format (s,
"[%d] %U (our) %U (client) vlan-id %d rx_sw_if_index %d\n",
79 clib_net_to_host_u16 (session->vlan_id), session->
sw_if_index);
81 s =
format (s,
" local cookie %llx remote cookie %llx\n",
87 s =
format (s,
" local rollover cookie %llx\n",
88 clib_net_to_host_u64 (session->lcl_ro_cookie));
91 s =
format (s,
" local session-id %d remote session-id %d\n",
95 s =
format (s,
" l2 specific sublayer %s\n",
104 s =
format (s,
" user-to-net: %llu pkts %llu bytes\n",
110 s =
format (s,
" net-to-user: %llu pkts %llu bytes\n",
129 .path =
"show session",
130 .short_help =
"show session summary",
146 vlib_cli_output (vm,
"%U", format_l2t_session, session);
155 .path =
"show session detail",
156 .short_help =
"show session table detail",
174 session_index = session - lm->sessions;
176 session_index_to_counter_index (session_index,
177 SESSION_COUNTER_USER_TO_NETWORK);
178 vlib_increment_combined_counter (&lm->counter_main,
181 vlib_increment_combined_counter (&lm->counter_main,
194 .path =
"test counters",
195 .short_help =
"increment all active counters",
213 session_index = session - lm->sessions;
215 session_index_to_counter_index (session_index,
216 SESSION_COUNTER_USER_TO_NETWORK);
217 vlib_zero_combined_counter (&lm->counter_main, counter_index);
218 vlib_zero_combined_counter (&lm->counter_main, counter_index+1);
229 .path =
"clear counters",
230 .short_help =
"clear all active counters",
244 u32 sw_if_index = (
u32) ~ 0;
251 uword vlan_and_sw_if_index_key;
253 u64 local_cookie = (
u64) ~ 0, remote_cookie = (
u64) ~ 0;
254 u32 local_session_id = 1, remote_session_id = 1;
255 int our_address_set = 0, client_address_set = 0;
256 int l2_sublayer_present = 0;
264 if (
unformat (line_input,
"client %U",
266 client_address_set = 1;
267 else if (
unformat (line_input,
"our %U",
270 else if (
unformat (line_input,
"vlan %d", &vlan_id))
272 else if (
unformat (line_input,
"l2-interface %U",
276 else if (
unformat (line_input,
"interface %U",
280 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
282 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
284 else if (
unformat (line_input,
"local-session-id %d",
287 else if (
unformat (line_input,
"remote-session-id %d",
290 else if (
unformat (line_input,
"l2-sublayer-present"))
291 l2_sublayer_present = 1;
299 if (sw_if_index == (
u32) ~ 0)
301 if (our_address_set == 0)
303 if (client_address_set == 0)
306 remote_session_id = clib_host_to_net_u32 (remote_session_id);
307 local_session_id = clib_host_to_net_u32 (local_session_id);
315 (0,
"Session w/ client address %U already exists",
323 (0,
"Session w/ our address %U already exists",
332 "Session w/ local session id %d already exists",
333 clib_net_to_host_u32 (local_session_id));
341 memset (s, 0,
sizeof (*s));
346 s->vlan_id = clib_host_to_net_u16 (vlan_id);
348 l2tp_session_set_remote_cookie (s, remote_cookie);
358 s->l2_output_next_index = next_index;
367 sizeof (*src_address_copy));
374 sizeof (*dst_address_copy));
387 vlan_and_sw_if_index_key = ((
uword) (s->vlan_id) << 32) | sw_if_index;
388 hash_set (lm->session_by_vlan_and_rx_sw_if_index,
389 vlan_and_sw_if_index_key, s - lm->
sessions);
395 vlib_validate_counter (&lm->
counter_main, counter_index);
396 vlib_validate_counter (&lm->
counter_main, counter_index + 1);
408 .path =
"l2tp session add",
410 "l2tp session add client <ip6> our <ip6> vlan <id> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec> l2-interface <int>",
425 uword vlan_and_sw_if_index_key;
427 if (!
unformat (input,
"%d", &session_index))
442 key = (
void *) (hp->
key);
456 key = (
void *) (hp->
key);
475 hash_unset (lm->session_by_vlan_and_rx_sw_if_index,
476 vlan_and_sw_if_index_key);
484 .path =
"l2tp session delete",
486 "l2tp session delete <session-id>",
499 u64 lcl_ro_cookie = (
u64) ~ 0, rem_ro_cookie = (
u64) ~ 0;
502 if (!
unformat (input,
"%d", &session_index))
519 l2tp_session_cookie_commit (s);
526 if (
unformat (input,
"local %llx", &lcl_ro_cookie))
528 cookie_flags |= L2TP_COOKIE_ROLLOVER_LOCAL;
529 l2tp_session_set_local_rollover_cookie (s, lcl_ro_cookie);
531 if (
unformat (input,
"remote %llx", &rem_ro_cookie))
533 cookie_flags |= L2TP_COOKIE_ROLLOVER_REMOTE;
534 l2tp_session_set_remote_cookie (s, rem_ro_cookie);
544 .path =
"l2tp session cookie",
546 "l2tp session cookie <session id> commit|rollover [local <hex>] [remote <hex>]",
u64 packets
packet counter
#define hash_set(h, key, value)
ip6_address_t client_address
static clib_error_t * clear_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_unset(h, key)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vlib_node_registration_t l2t_ip6_node
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
int vnet_hw_interface_rx_redirect_to_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
uword * session_by_session_id
static clib_error_t * l2tp_session_add_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip6_address_t our_address
static clib_error_t * l2tp_session_cookie_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_session_summary_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Combined counter to hold both packets and byte differences.
#define hash_set_mem(h, key, value)
#define hash_get_pair_mem(h, key)
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)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
ip6_address_t client_address
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static u32 counter_index(vlib_main_t *vm, vlib_error_t e)
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * show_session_detail_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_warning(format, args...)
vlib_node_registration_t l2t_l2_node
(constructor) VLIB_REGISTER_NODE (l2t_l2_node)
void get_interface_ethernet_address(l2t_main_t *lm, u8 *dst, u32 sw_if_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define hash_unset_mem(h, key)
static clib_error_t * l2tp_session_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_put(P, E)
Free an object E in pool P.
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...
u8 * format_l2t_session(u8 *s, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
ip6_to_l2_lookup_t lookup_type
ip6_address_t our_address
u8 * format_l2t_trace(u8 *s, va_list *args)
#define clib_memcpy(a, b, c)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void clib_mem_free(void *p)
uword * session_by_dst_address
static void * clib_mem_alloc(uword size)
vlib_combined_counter_main_t counter_main
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#define hash_get_mem(h, key)
#define clib_error_return(e, args...)
uword * session_by_src_address
static clib_error_t * test_counters_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ethernet_interface_t * interfaces
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
static uword pool_elts(void *v)
Number of active elements in a pool.