55 s =
format (s,
"L2_XCRW: next index %d tx_fib_index %d",
65 #define _(sym,string) string, 74 u32 n_left_from, *from, *to_next;
85 while (n_left_from > 0)
91 while (n_left_from >= 4 && n_left_to_next >= 2)
96 u32 sw_if_index0, sw_if_index1;
114 to_next[0] = bi0 = from[0];
115 to_next[1] = bi1 = from[1];
130 next0 = adj0->rewrite_header.next_index;
132 adj0->rewrite_header.sw_if_index;
134 next1 = adj1->rewrite_header.next_index;
136 adj1->rewrite_header.sw_if_index;
138 em->
counters[node_counter_base_index + next1]++;
144 adj0->rewrite_header.data_bytes);
146 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
153 adj1->rewrite_header.data_bytes);
155 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
181 to_next, n_left_to_next,
182 bi0, bi1, next0, next1);
185 while (n_left_from > 0 && n_left_to_next > 0)
207 next0 = adj0->rewrite_header.next_index;
209 adj0->rewrite_header.sw_if_index;
215 adj0->rewrite_header.data_bytes);
217 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
230 to_next, n_left_to_next,
244 .vector_size =
sizeof (
u32),
278 clib_warning (
"you shouldn't be here, leaking buffers...");
285 u32 dev_instance = va_arg (*args,
u32);
286 return format (s,
"xcrw%d", dev_instance);
309 memset (address, 0,
sizeof (address));
314 (vnm, xcrw_device_class.index, instance++, address, &hw_if_index,
330 u32 l2_sw_if_index,
u32 tx_fib_index,
331 u8 * rewrite,
u32 next_node_index,
int is_add)
355 memset (a, 0,
sizeof (*a));
357 a->rewrite_header.sw_if_index = tx_fib_index;
363 a->rewrite_header.next_index =
379 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
385 memset (a, 0,
sizeof (*a));
406 u32 tx_fib_index = ~0;
407 u32 next_node_index = ~0;
428 if (
unformat (line_input,
"next %U",
431 else if (
unformat (line_input,
"tx-fib-id %d", &tx_fib_id))
433 else if (
unformat (line_input,
"del"))
435 else if (
unformat (line_input,
"ipv6"))
442 if (next_node_index == ~0)
468 rw, next_node_index, is_add);
476 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
479 vnm, l2_sw_if_index);
508 .path =
"set interface l2 xcrw",
510 "set interface l2 xcrw <interface> next <node-name>\n" 511 " [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>",
528 s =
format (s,
"%-25s%s",
"L2 interface",
"Tunnel Details");
532 s =
format (s,
"%-25U %U ",
538 s =
format (s,
"next %U ",
540 a->rewrite_header.next_index);
542 if (a->rewrite_header.sw_if_index != ~0)
543 s =
format (s,
"tx fib index %d ", a->rewrite_header.sw_if_index);
545 if (a->rewrite_header.data_bytes)
547 rewrite_string = (
u8 *) (a + 1);
548 rewrite_string -= a->rewrite_header.data_bytes;
549 s =
format (s,
"rewrite data: %U ",
551 a->rewrite_header.data_bytes);
579 vlib_cli_output (vm,
"%U", format_l2xcrw, vnm, t);
595 .path =
"show l2xcrw",
596 .short_help =
"show l2xcrw",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
#define hash_set(h, key, value)
static char * l2_xcrw_error_strings[]
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define hash_unset(h, key)
vnet_main_t * vnet_get_main(void)
static uword l2_xcrw_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define vnet_rewrite_set_data(rw, data, data_bytes)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * show_l2xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_l2xcrw(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u8 * format_xcrw_name(u8 *s, va_list *args)
clib_error_t * l2_xcrw_init(vlib_main_t *vm)
#define clib_error_return(e, args...)
format_function_t format_vlib_next_node_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
l2_xcrw_tunnel_t * tunnels
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
vlib_error_main_t error_main
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
#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.
#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).
int vnet_configure_l2_xcrw(vlib_main_t *vm, vnet_main_t *vnm, u32 l2_sw_if_index, u32 tx_fib_index, u8 *rewrite, u32 next_node_index, int is_add)
uword * fib_index_by_table_id
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
#define foreach_l2_xcrw_error
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
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,...)
#define hash_create(elts, value_bytes)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static u8 * format_l2_xcrw_trace(u8 *s, va_list *args)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define VLIB_NODE_FLAG_TRACE
static vlib_main_t * vlib_get_main(void)
VNET_DEVICE_CLASS(xcrw_device_class, static)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#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 vlib_node_registration_t l2_xcrw_node
(constructor) VLIB_REGISTER_NODE (l2_xcrw_node)
static u32 create_xcrw_interface(vlib_main_t *vm)
unformat_function_t unformat_vlib_node
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
u16 flags
Copy of main node flags.
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
l2_xcrw_adjacency_t * adj_by_sw_if_index
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.
l2_xcrw_main_t l2_xcrw_main
uword * tunnel_index_by_l2_sw_if_index
static clib_error_t * set_l2_xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword pool_elts(void *v)
Number of active elements in a pool.