56 s =
format (s,
"l2-classify: sw_if_index %d, table %d, offset %x, next %d",
67 #define foreach_l2_output_classify_error \ 68 _(MISS, "Classify misses") \ 69 _(HIT, "Classify hits") \ 70 _(CHAIN_HIT, "Classify hits after chain walk") \ 71 _(DROP, "L2 Classify Drops") 75 #define _(sym,str) L2_OUTPUT_CLASSIFY_ERROR_##sym, 82 #define _(sym,string) string, 141 u32 n_left_from, *from, *to_next;
153 u32 cached_sw_if_index = (
u32) ~ 0;
154 u32 cached_next_index = (
u32) ~ 0;
166 while (n_left_from > 2)
171 u32 sw_if_index0, sw_if_index1;
173 int type_index0, type_index1;
175 u32 table_index0, table_index1;
207 type0 = clib_net_to_host_u16 (h0->
type);
208 type1 = clib_net_to_host_u16 (h1->
type);
210 type_index0 = (type0 == ETHERNET_TYPE_IP4)
212 type_index0 = (type0 == ETHERNET_TYPE_IP6)
215 type_index1 = (type1 == ETHERNET_TYPE_IP4)
217 type_index1 = (type1 == ETHERNET_TYPE_IP6)
222 rt->
l2cm->classify_table_index_by_sw_if_index
223 [type_index0][sw_if_index0];
225 if (table_index0 != ~0)
236 rt->
l2cm->classify_table_index_by_sw_if_index
237 [type_index1][sw_if_index1];
239 if (table_index1 != ~0)
252 while (n_left_from > 0)
271 type0 = clib_net_to_host_u16 (h0->
type);
273 type_index0 = (type0 == ETHERNET_TYPE_IP4)
275 type_index0 = (type0 == ETHERNET_TYPE_IP6)
279 table_index0 = rt->
l2cm->classify_table_index_by_sw_if_index
280 [type_index0][sw_if_index0];
282 if (table_index0 != ~0)
298 while (n_left_from > 0)
305 while (n_left_from > 0 && n_left_to_next > 0)
314 vnet_classify_entry_t *e0;
327 table_index2 =
vnet_buffer (p2)->l2_classify.table_index;
347 table_index0 =
vnet_buffer (b0)->l2_classify.table_index;
351 feature_bitmap0 =
vnet_buffer (b0)->l2.feature_bitmap
352 & ~L2OUTPUT_FEAT_OUTPUT_CLASSIFY;
355 vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap0;
368 next0 = (e0->next_index < n_next_nodes) ?
369 e0->next_index : next0;
395 next0 = (e0->next_index < n_next_nodes) ?
396 e0->next_index : next0;
406 b0->
error = node->
errors[L2_OUTPUT_CLASSIFY_ERROR_DROP];
420 b0, sw_if_index0, feature_bitmap0, &next0);
436 to_next, n_left_to_next,
444 L2_OUTPUT_CLASSIFY_ERROR_MISS, misses);
446 L2_OUTPUT_CLASSIFY_ERROR_HIT, hits);
448 L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT,
456 .name =
"l2-output-classify",
457 .vector_size =
sizeof (
u32),
496 cm->next_nodes.feat_next_node_index);
498 rt->
vcm = cm->vnet_classify_main;
514 (
u32) enable_disable);
532 u32 other_table_index)
539 if (ip4_table_index != ~0 &&
541 return VNET_API_ERROR_NO_SUCH_TABLE;
543 if (ip6_table_index != ~0 &&
545 return VNET_API_ERROR_NO_SUCH_TABLE2;
547 if (other_table_index != ~0 &&
549 return VNET_API_ERROR_NO_SUCH_TABLE3;
564 [sw_if_index] = ip4_table_index;
567 [sw_if_index] = ip6_table_index;
570 [sw_if_index] = other_table_index;
581 u32 sw_if_index = ~0;
582 u32 ip4_table_index = ~0;
583 u32 ip6_table_index = ~0;
584 u32 other_table_index = ~0;
592 else if (
unformat (input,
"ip4-table %d", &ip4_table_index))
594 else if (
unformat (input,
"ip6-table %d", &ip6_table_index))
596 else if (
unformat (input,
"other-table %d", &other_table_index))
602 if (sw_if_index == ~0)
606 if (ip4_table_index == ~0 && ip6_table_index == ~0
607 && other_table_index == ~0)
643 .path =
"set interface l2 output classify",
645 "set interface l2 output classify intfc <<interface-name>> [ip4-table <n>]\n" 646 " [ip6-table <n>] [other-table <n>]",
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
#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)
Release pointer to next frame vector data.
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
l2_output_classify_main_t * l2cm
l2 input classifier main object pointer
char ** l2output_get_feat_names(void)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
VLIB_NODE_FUNCTION_MULTIARCH(l2_output_classify_node, l2_output_classify_node_fn)
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
static f64 vlib_time_now(vlib_main_t *vm)
clib_error_t * l2_output_classify_init(vlib_main_t *vm)
l2 output classsifier feature initialization.
static uword l2_output_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
l2 output classifier node.
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
static char * l2_output_classify_error_strings[]
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
void l2output_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u8 * format_l2_output_classify_trace(u8 *s, va_list *args)
Packet trace format function.
u32 sw_if_index
interface handle for the ith packet
struct _l2_classify_main l2_output_classify_main_t
l2_output_classify_main_t l2_output_classify_main
l2 output classifier main data structure.
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
l2_output_classify_next_t
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
#define CLIB_PREFETCH(addr, size, type)
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
vnet_classify_main_t * vcm
use-case independent main object pointer
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u32 table_index
classifier table which provided the final result
#define foreach_l2_output_classify_error
#define VLIB_CLI_COMMAND(x,...)
struct _vnet_classify_main vnet_classify_main_t
#define VLIB_NODE_FLAG_TRACE
vnet_classify_main_t vnet_classify_main
static clib_error_t * int_l2_output_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
l2_output_classify_error_t
#define VLIB_BUFFER_IS_TRACED
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 session_offset
offset in classifier heap of the corresponding session
vlib_node_registration_t l2_output_classify_node
(constructor) VLIB_REGISTER_NODE (l2_output_classify_node)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
u32 next_index
graph arc index selected for this packet
#define clib_error_return(e, args...)
static void l2_output_dispatch(vlib_main_t *vlib_main, vnet_main_t *vnet_main, vlib_node_runtime_t *node, u32 node_index, u32 *cached_sw_if_index, u32 *cached_next_index, l2_output_next_nodes_st *next_nodes, vlib_buffer_t *b0, u32 sw_if_index, u32 feature_bitmap, u32 *next0)
Determine the next L2 node based on the output feature bitmap.
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static void l2output_init_output_node_vec(u32 **output_node_index_vec)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)