82 if (
vec_len (l2_emulations) >= sw_if_index)
85 memset (l23e, 0,
sizeof (*l23e));
120 else if (
unformat (input,
"enable"))
122 else if (
unformat (input,
"disable"))
128 if (~0 == sw_if_index)
150 .path =
"set interface l2 l2-emulation",
152 "set interface l2 l2-emulation <interface-name> [disable|enable]\n",
188 .path =
"show interface l2 l2-emulation",
189 .short_help =
"show interface l2 l2-emulation\n",
194 #define foreach_l2_emulation \ 195 _(IP4, "Extract IPv4") \ 196 _(IP6, "Extract IPv6") 200 #define _(sym,str) L2_EMULATION_ERROR_##sym, 207 #define _(sym,string) string, 214 #define _(sym,str) L2_EMULATION_NEXT_##sym, 234 u32 n_left_from, *from, *to_next;
243 while (n_left_from > 0)
248 while (n_left_from >= 4 && n_left_to_next >= 2)
251 u32 sw_if_index0, sw_if_index1;
252 u16 ether_type0, ether_type1;
253 u32 next0 = ~0, next1 = ~0;
258 bi0 = to_next[0] = from[0];
259 bi1 = to_next[1] = from[1];
274 ether_type0 = clib_net_to_host_u16 (*(
u16 *) (h0 + l2_len0 - 2));
275 ether_type1 = clib_net_to_host_u16 (*(
u16 *) (h1 + l2_len1 - 2));
286 case ETHERNET_TYPE_IP4:
287 ASSERT (l2_emulations[sw_if_index0].enabled);
289 next0 = L2_EMULATION_NEXT_IP4;
292 case ETHERNET_TYPE_IP6:
293 ASSERT (l2_emulations[sw_if_index0].enabled);
295 next0 = L2_EMULATION_NEXT_IP6;
305 case ETHERNET_TYPE_IP4:
306 ASSERT (l2_emulations[sw_if_index1].enabled);
308 next1 = L2_EMULATION_NEXT_IP4;
311 case ETHERNET_TYPE_IP6:
312 ASSERT (l2_emulations[sw_if_index1].enabled);
314 next1 = L2_EMULATION_NEXT_IP6;
321 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
328 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
338 L2INPUT_FEAT_L2_EMULATION);
343 L2INPUT_FEAT_L2_EMULATION);
346 to_next, n_left_to_next,
347 bi0, bi1, next0, next1);
349 while (n_left_from > 0 && n_left_to_next > 0)
370 ether_type0 = clib_net_to_host_u16 (*(
u16 *) (h0 + l2_len0 - 2));
380 case ETHERNET_TYPE_IP4:
381 ASSERT (l2_emulations[sw_if_index0].enabled);
383 next0 = L2_EMULATION_NEXT_IP4;
386 case ETHERNET_TYPE_IP6:
387 ASSERT (l2_emulations[sw_if_index0].enabled);
389 next0 = L2_EMULATION_NEXT_IP6;
397 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
407 L2INPUT_FEAT_L2_EMULATION);
411 to_next, n_left_to_next,
419 L2_EMULATION_ERROR_IP4, ip4_hits);
421 L2_EMULATION_ERROR_IP6, ip6_hits);
442 .name =
"l2-emulation",
443 .vector_size =
sizeof (
u32),
454 [L2_EMULATION_NEXT_IP4] =
"ip4-input",
455 [L2_EMULATION_NEXT_IP6] =
"ip6-input",
#define vec_foreach_index(var, v)
Iterate over vector indices.
vlib_node_registration_t l2_emulation_node
(constructor) VLIB_REGISTER_NODE (l2_emulation_node)
struct l2_emulation_main_t_ l2_emulation_main_t
Grouping of global data for the L2 emulation feature.
vnet_main_t * vnet_get_main(void)
static clib_error_t * l2_emulation_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
#define foreach_l2_emulation
Grouping of global data for the L2 emulation feature.
u32 l2_input_feat_next[32]
Next nodes for L2 output features.
void l2_emulation_disable(u32 sw_if_index)
static char * l2_emulation_error_strings[]
unformat_function_t unformat_vnet_sw_interface
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(l2_emulation_interface_add_del)
VLIB_NODE_FUNCTION_MULTIARCH(l2_emulation_node, l2_emulation_node_fn)
format_function_t format_vnet_sw_if_index_name
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define VLIB_INIT_FUNCTION(x)
#define clib_error_return(e, args...)
struct l2_emulation_trace_t_ l2_emulation_trace_t
per-packet trace data
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
static u8 * format_l2_emulation_trace(u8 *s, va_list *args)
static l2_emulation_main_t l2_emulation_main
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 node_index
Node index.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#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.
struct l2_emulation_t_ l2_emulation_t
Per-interface L2 configuration.
#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).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
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.
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.
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * l2_emulation_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 enabled
Enabled or Disabled.
l2_emulation_t * l2_emulations
Per-interface vector of emulation configs.
void l2_emulation_enable(u32 sw_if_index)
L2 Emulation is a feautre that is applied to L2 ports to 'extract' IP packets from the L2 path and in...
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword l2_emulation_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Per-interface L2 configuration.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static clib_error_t * l2_emulation_init(vlib_main_t *vm)
u16 flags
Copy of main node flags.
#define VLIB_NODE_FLAG_TRACE
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
static clib_error_t * l2_emulation_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)