81 if (
vec_len (l2_emulations) >= sw_if_index)
84 memset (l23e, 0,
sizeof (*l23e));
94 u32 sw_if_index,
u32 is_add)
111 u32 sw_if_index = ~0;
119 else if (
unformat (input,
"enable"))
121 else if (
unformat (input,
"disable"))
127 if (~0 == sw_if_index)
149 .path =
"set interface l2 l2-emulation",
151 "set interface l2 l2-emulation <interface-name> [disable|enable]\n",
166 l23e = &l2_emulations[sw_if_index];
187 .path =
"show interface l2 l2-emulation",
188 .short_help =
"show interface l2 l2-emulation\n",
193 #define foreach_l2_emulation \ 194 _(IP4, "Extract IPv4") \ 195 _(IP6, "Extract IPv6") 199 #define _(sym,str) L2_EMULATION_ERROR_##sym, 206 #define _(sym,string) string, 213 #define _(sym,str) L2_EMULATION_NEXT_##sym, 233 u32 n_left_from, *from, *to_next;
242 while (n_left_from > 0)
247 while (n_left_from >= 4 && n_left_to_next >= 2)
250 u32 sw_if_index0, sw_if_index1;
251 u16 ether_type0, ether_type1;
252 u32 next0 = ~0, next1 = ~0;
257 bi0 = to_next[0] = from[0];
258 bi1 = to_next[1] = from[1];
273 ether_type0 = clib_net_to_host_u16 (*(
u16 *) (h0 + l2_len0 - 2));
274 ether_type1 = clib_net_to_host_u16 (*(
u16 *) (h1 + l2_len1 - 2));
285 case ETHERNET_TYPE_IP4:
286 ASSERT (l2_emulations[sw_if_index0].enabled);
288 next0 = L2_EMULATION_NEXT_IP4;
291 case ETHERNET_TYPE_IP6:
292 ASSERT (l2_emulations[sw_if_index0].enabled);
294 next0 = L2_EMULATION_NEXT_IP6;
304 case ETHERNET_TYPE_IP4:
305 ASSERT (l2_emulations[sw_if_index1].enabled);
307 next1 = L2_EMULATION_NEXT_IP4;
310 case ETHERNET_TYPE_IP6:
311 ASSERT (l2_emulations[sw_if_index1].enabled);
313 next1 = L2_EMULATION_NEXT_IP6;
320 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
327 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
337 L2INPUT_FEAT_L2_EMULATION);
342 L2INPUT_FEAT_L2_EMULATION);
345 to_next, n_left_to_next,
346 bi0, bi1, next0, next1);
348 while (n_left_from > 0 && n_left_to_next > 0)
369 ether_type0 = clib_net_to_host_u16 (*(
u16 *) (h0 + l2_len0 - 2));
379 case ETHERNET_TYPE_IP4:
380 ASSERT (l2_emulations[sw_if_index0].enabled);
382 next0 = L2_EMULATION_NEXT_IP4;
385 case ETHERNET_TYPE_IP6:
386 ASSERT (l2_emulations[sw_if_index0].enabled);
388 next0 = L2_EMULATION_NEXT_IP6;
396 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
406 L2INPUT_FEAT_L2_EMULATION);
410 to_next, n_left_to_next,
418 L2_EMULATION_ERROR_IP4, ip4_hits);
420 L2_EMULATION_ERROR_IP6, ip6_hits);
441 .name =
"l2-emulation",
442 .vector_size =
sizeof (
u32),
453 [L2_EMULATION_NEXT_IP4] =
"ip4-input",
454 [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...
#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)