20 #include <vnet/devices/pci/ixge.h> 37 u8 *dst,
u32 sw_if_index)
56 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",
85 if (session->
cookie_flags & L2TP_COOKIE_ROLLOVER_LOCAL) {
86 s =
format (s,
" local rollover cookie %llx\n",
87 clib_net_to_host_u64 (session->lcl_ro_cookie));
90 s =
format (s,
" local session-id %d remote session-id %d\n",
94 s =
format (s,
" l2 specific sublayer %s\n",
103 s =
format (s,
" user-to-net: %llu pkts %llu bytes\n",
109 s =
format (s,
" net-to-user: %llu pkts %llu bytes\n",
127 .path =
"show session",
128 .short_help =
"show session summary",
142 vlib_cli_output (vm,
"%U", format_l2t_session, session);
149 .path =
"show session detail",
150 .short_help =
"show session table detail",
167 session_index = session - lm->sessions;
169 session_index_to_counter_index (session_index,
170 SESSION_COUNTER_USER_TO_NETWORK);
171 vlib_increment_combined_counter (&lm->counter_main,
174 vlib_increment_combined_counter (&lm->counter_main,
186 .path =
"test counters",
187 .short_help =
"increment all active counters",
204 session_index = session - lm->sessions;
206 session_index_to_counter_index (session_index,
207 SESSION_COUNTER_USER_TO_NETWORK);
208 vlib_zero_combined_counter (&lm->counter_main, counter_index);
209 vlib_zero_combined_counter (&lm->counter_main, counter_index+1);
219 .path =
"clear counters",
220 .short_help =
"clear all active counters",
233 u32 sw_if_index = (
u32)~0;
240 uword vlan_and_sw_if_index_key;
242 u64 local_cookie = (
u64)~0, remote_cookie = (
u64)~0;
243 u32 local_session_id = 1, remote_session_id = 1;
244 int our_address_set = 0, client_address_set = 0;
245 int l2_sublayer_present = 0;
252 if (
unformat (line_input,
"client %U",
254 client_address_set = 1;
255 else if (
unformat (line_input,
"our %U",
258 else if (
unformat (line_input,
"vlan %d", &vlan_id))
260 else if (
unformat (line_input,
"l2-interface %U",
264 else if (
unformat (line_input,
"interface %U",
268 else if (
unformat (line_input,
"local-cookie %llx", &local_cookie))
270 else if (
unformat (line_input,
"remote-cookie %llx", &remote_cookie))
272 else if (
unformat (line_input,
"local-session-id %d",
275 else if (
unformat (line_input,
"remote-session-id %d",
278 else if (
unformat (line_input,
"l2-sublayer-present"))
279 l2_sublayer_present = 1;
287 if (sw_if_index == (
u32)~0)
289 if (our_address_set == 0)
291 if (client_address_set == 0)
294 remote_session_id = clib_host_to_net_u32 (remote_session_id);
295 local_session_id = clib_host_to_net_u32 (local_session_id);
302 (0,
"Session w/ client address %U already exists",
310 (0,
"Session w/ our address %U already exists",
319 "Session w/ local session id %d already exists",
320 clib_net_to_host_u32 (local_session_id));
328 memset (s, 0,
sizeof (*s));
332 s->vlan_id = clib_host_to_net_u16 (vlan_id);
334 l2tp_session_set_remote_cookie (s, remote_cookie);
344 s->l2_output_next_index = next_index;
351 clib_memcpy (src_address_copy, &client_address,
sizeof (*src_address_copy));
357 clib_memcpy (dst_address_copy, &our_address,
sizeof (*dst_address_copy));
370 vlan_and_sw_if_index_key = ((
uword)(s->vlan_id)<<32) | sw_if_index;
371 hash_set (lm->session_by_vlan_and_rx_sw_if_index,
372 vlan_and_sw_if_index_key, s - lm->
sessions);
378 vlib_validate_counter (&lm->
counter_main, counter_index);
379 vlib_validate_counter (&lm->
counter_main, counter_index+1);
390 .path =
"l2tp session add",
392 "l2tp session add client <ip6> our <ip6> vlan <id> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec> l2-interface <int>",
406 uword vlan_and_sw_if_index_key;
408 if (!
unformat (input,
"%d", &session_index))
421 key = (
void *)(hp->
key);
433 key = (
void *)(hp->
key);
452 hash_unset (lm->session_by_vlan_and_rx_sw_if_index, vlan_and_sw_if_index_key);
459 .path =
"l2tp session delete",
461 "l2tp session delete <session-id>",
473 u64 lcl_ro_cookie = (
u64)~0, rem_ro_cookie = (
u64)~0;
476 if (!
unformat (input,
"%d", &session_index))
488 "no rollover cookie ready to commit");
490 l2tp_session_cookie_commit (s);
497 if (
unformat (input,
"local %llx", &lcl_ro_cookie)) {
498 cookie_flags |= L2TP_COOKIE_ROLLOVER_LOCAL;
499 l2tp_session_set_local_rollover_cookie (s, lcl_ro_cookie);
501 if (
unformat (input,
"remote %llx", &rem_ro_cookie)) {
502 cookie_flags |= L2TP_COOKIE_ROLLOVER_REMOTE;
503 l2tp_session_set_remote_cookie (s, rem_ro_cookie);
512 .path =
"l2tp session cookie",
514 "l2tp session cookie <session id> commit|rollover [local <hex>] [remote <hex>]",
#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)
vlib_node_registration_t l2t_ip6_node
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
always_inline void clib_mem_free(void *p)
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)
#define hash_set_mem(h, key, value)
#define hash_get_pair_mem(h, key)
unformat_function_t unformat_vnet_sw_interface
static u32 session_index_to_counter_index(u32 session_index, u32 counter_id)
ip6_address_t client_address
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
static clib_error_t * show_session_detail_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
always_inline uword pool_elts(void *v)
#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)
#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)
static void vlib_get_combined_counter(vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
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
always_inline void * clib_mem_alloc(uword size)
u8 * format_l2t_trace(u8 *s, 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)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define pool_is_free_index(P, I)
always_inline vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
uword * session_by_dst_address
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
vlib_combined_counter_main_t counter_main
#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
always_inline u32 counter_index(vlib_main_t *vm, vlib_error_t e)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)