43 u8 fdata[3 *
sizeof (u32x4)];
44 u8 rdata[3 *
sizeof (u32x4)];
66 s =
format (s,
"STICKY_HASH_MISS: sw_if_index %d",
74 }) classify_data_or_mask_t;
80 #define foreach_sticky_hash_miss_error \ 81 _(MISSES, "forward flow classify misses") 84 #define _(sym,str) STICKY_HASH_MISS_ERROR_##sym, 87 STICKY_HASH_MISS_N_ERROR,
90 static char * sticky_hash_miss_error_strings[] = {
91 #define _(sym,string) string, 121 u32 n_left_from, * from, * to_next;
122 sticky_hash_miss_next_t next_index;
134 while (n_left_from > 0)
139 to_next, n_left_to_next);
141 while (n_left_from > 0 && n_left_to_next > 0)
147 u32 fib_index0, ft_index0, rt_index0;
148 vnet_classify_table_3_t * ft0, * rt0;
149 vnet_classify_entry_3_t * fe0, * re0;
150 classify_data_or_mask_t * h0;
175 h0 = (classify_data_or_mask_t *)(mp->
rdata);
178 tmp = h0->ip.src_address.as_u32;
179 h0->ip.src_address.as_u32 = h0->ip.dst_address.as_u32;
180 h0->ip.dst_address.as_u32 = tmp;
189 ft0 = (vnet_classify_table_3_t *)
191 rt0 = (vnet_classify_table_3_t *)
194 fe0 = vnet_classify_find_or_add_entry_3 (ft0, mp->
fdata, &was_found0);
198 re0 = vnet_classify_find_or_add_entry_3 (rt0, mp->
rdata, 0);
207 fe0->opaque_index = s - mp->
sessions;
208 re0->opaque_index = s - mp->
sessions;
223 em->
counters[node_counter_base_index + STICKY_HASH_MISS_ERROR_MISSES]
230 to_next, n_left_to_next,
242 .name =
"sticky-hash-miss",
243 .vector_size =
sizeof (
u32),
247 .n_errors =
ARRAY_LEN(sticky_hash_miss_error_strings),
274 u32 fwd_sw_if_index,
u8 * fwd_mask,
275 u32 rev_sw_if_index,
u8 * rev_mask,
276 u32 nbuckets,
int enable_disable)
283 vnet_classify_table_3_t * ft, * rt;
291 ft = (vnet_classify_table_3_t *)
295 = ft - (vnet_classify_table_3_t *) cm->tables;
298 sticky_hash_miss_node.index);
302 rt = (vnet_classify_table_3_t *)
306 = rt - (vnet_classify_table_3_t *) cm->tables;
325 [fwd_sw_if_index] = ~0;
328 [fwd_sw_if_index] = ~0;
348 [rev_sw_if_index] = ~0;
351 [rev_sw_if_index] = ~0;
363 u32 fwd_sw_if_index = ~0, rev_sw_if_index = ~0;
364 int enable_disable = 1;
368 classify_data_or_mask_t fwd_mask, rev_mask;
369 u8 * fm = 0, * rm = 0;
378 else if (
unformat (input,
"nbuckets %d", &nbuckets))
380 else if (
unformat (input,
"disable"))
388 if (fwd_sw_if_index == ~0)
391 if (rev_sw_if_index == ~0)
397 ASSERT(
sizeof(fwd_mask) <= 3 *
sizeof (u32x4));
400 memset(&fwd_mask, 0,
sizeof (fwd_mask));
401 memset (&fwd_mask.ip.src_address, 0xff, 4);
403 memset(&rev_mask, 0,
sizeof (rev_mask));
404 memset (&rev_mask.ip.dst_address, 0xff, 4);
414 nbuckets, enable_disable);
432 .path =
"ip sticky classify",
433 .short_help =
"ip sticky classify fwd <intfc> rev <intfc> " 434 "[nbuckets <nn>][disable]",
443 vnet_classify_table_3_t * t;
444 vnet_classify_entry_3_t * e;
448 classify_data_or_mask_t * match;
452 t = (vnet_classify_table_3_t *)
455 match = (classify_data_or_mask_t *)(e->key);
459 "[%6d] fwd src %U next index %d session %d fib %d\n" 460 " hits %lld last-heard %.6f\n",
463 e->next_index, e->opaque_index, fib->
table_id,
464 e->hits, e->last_heard);
466 if (e->opaque_index != session - mp->
sessions)
467 s =
format (s,
"WARNING: forward session index mismatch!\n");
469 t = (vnet_classify_table_3_t *)
472 match = (classify_data_or_mask_t *)(e->key);
476 "[%6d] rev dst %U next index %d session %d\n" 477 " hits %lld last-heard %.6f\n",
480 e->next_index, e->opaque_index, e->hits, e->last_heard);
482 if (e->opaque_index != session - mp->
sessions)
483 s =
format (s,
"WARNING: reverse session index mismatch!\n");
484 s =
format (s,
"---------\n");
497 int dump_classifier_tables = 0;
505 else if (
unformat (input,
"dump-tables")
506 ||
unformat (input,
"dump-classifier-tables"))
507 dump_classifier_tables = 1;
528 dump_classifier_tables);
536 dump_classifier_tables);
543 vlib_cli_output (vm,
"%U", format_sticky_hash_session, mp, s);
550 .path =
"show sticky classify",
551 .short_help =
"Display sticky classifier tables",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
static u8 * format_sticky_hash_miss_trace(u8 *s, va_list *args)
sticky_hash_session_t * sessions
always_inline vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
vlib_node_registration_t sticky_hash_miss_node
(constructor) VLIB_REGISTER_NODE (sticky_hash_miss_node)
u8 rdata[3 *sizeof(u32x4)]
#define foreach_sticky_hash_miss_error
struct _vlib_node_registration vlib_node_registration_t
static char * sticky_hash_miss_error_strings[]
u8 fdata[3 *sizeof(u32x4)]
always_inline uword max_log2(uword x)
u32 * fib_index_by_sw_if_index
unformat_function_t unformat_vnet_sw_interface
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vnet_classify_main_t * vnet_classify_main
u32 fwd_classify_table_index
u32 * classify_table_index_by_sw_if_index[L2_CLASSIFY_N_TABLES]
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
vnet_classify_table_t * vnet_classify_new_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip_n_vectors, u32 match_n_vectors)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline uword pool_elts(void *v)
u8 * format_sticky_hash_session(u8 *s, va_list *args)
void vnet_l2_classify_enable_disable(u32 sw_if_index, int enable_disable)
u32 rev_classify_table_index
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
l2_classify_main_t l2_classify_main
#define pool_elt_at_index(p, i)
vlib_error_main_t error_main
clib_error_t * sticky_hash_miss_init(vlib_main_t *vm)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define vec_free(V)
Free vector's memory (no header).
u8 * format_classify_table(u8 *s, va_list *args)
#define clib_memcpy(a, b, c)
typedef CLIB_PACKED(struct{ethernet_header_t eh;ip4_header_t ip;})
vlib_node_registration_t l2_classify_node
(constructor) VLIB_REGISTER_NODE (l2_classify_node)
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
always_inline uword is_pow2(uword x)
static clib_error_t * show_ip4_sticky_hash_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
l2_classify_main_t * l2_classify_main
#define VLIB_NODE_FLAG_TRACE
vnet_classify_main_t vnet_classify_main
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define VLIB_BUFFER_IS_TRACED
#define vec_elt(v, i)
Get vector value at index i.
static int ip4_sticky_hash_enable_disable(sticky_hash_main_t *mp, u32 fwd_sw_if_index, u8 *fwd_mask, u32 rev_sw_if_index, u8 *rev_mask, u32 nbuckets, int enable_disable)
static uword sticky_hash_miss_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define VLIB_REGISTER_NODE(x,...)
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return(e, args...)
static clib_error_t * ip4_sticky_hash_init_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.