52 s =
format (s,
"L2_XCRW: next index %d tx_fib_index %d",
62 #define _(sym,string) string, 72 u32 n_left_from, * from, * to_next;
83 while (n_left_from > 0)
88 to_next, n_left_to_next);
90 while (n_left_from >= 4 && n_left_to_next >= 2)
95 u32 sw_if_index0, sw_if_index1;
113 to_next[0] = bi0 = from[0];
114 to_next[1] = bi1 = from[1];
129 next0 = adj0->rewrite_header.next_index;
131 adj0->rewrite_header.sw_if_index;
133 next1 = adj1->rewrite_header.next_index;
135 adj1->rewrite_header.sw_if_index;
137 em->
counters[node_counter_base_index + next1]++;
143 adj0->rewrite_header.data_bytes);
145 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
152 adj1->rewrite_header.data_bytes);
154 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
180 to_next, n_left_to_next,
181 bi0, bi1, next0, next1);
184 while (n_left_from > 0 && n_left_to_next > 0)
206 next0 = adj0->rewrite_header.next_index;
208 adj0->rewrite_header.sw_if_index;
214 adj0->rewrite_header.data_bytes);
216 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
230 to_next, n_left_to_next,
243 .vector_size =
sizeof (
u32),
275 clib_warning (
"you shouldn't be here, leaking buffers...");
281 u32 dev_instance = va_arg (*args,
u32);
282 return format (s,
"xcrw%d", dev_instance);
303 memset (address, 0,
sizeof (address));
309 xcrw_device_class.index,
327 u32 l2_sw_if_index,
u32 tx_fib_index,
328 u8 * rewrite,
u32 next_node_index,
int is_add)
352 memset (a, 0,
sizeof (*a));
354 a->rewrite_header.sw_if_index = tx_fib_index;
360 a->rewrite_header.next_index =
376 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
382 memset (a, 0,
sizeof (*a));
404 u32 tx_fib_index = ~0;
405 u32 next_node_index = ~0;
422 if (
unformat (line_input,
"next %U",
425 else if (
unformat (line_input,
"tx-fib-id %d", &tx_fib_id))
427 else if (
unformat (line_input,
"del"))
429 else if (
unformat (line_input,
"ipv6"))
431 else if (
unformat (line_input,
"rw %U",
437 if (next_node_index == ~0)
457 rw, next_node_index, is_add);
465 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
468 vnm, l2_sw_if_index);
480 .path =
"set interface l2 xcrw",
482 "set int l2 xcrw <interface> next <node-name>\n" 483 " [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>",
498 s =
format (s,
"%-25s%s",
"L2 interface",
"Tunnel Details");
502 s =
format (s,
"%-25U %U ",
508 s =
format (s,
"next %U ",
510 a->rewrite_header.next_index);
512 if (a->rewrite_header.sw_if_index != ~0)
513 s =
format (s,
"tx fib index %d ", a->rewrite_header.sw_if_index);
515 if (a->rewrite_header.data_bytes)
517 rewrite_string = (
u8 *)(a + 1);
518 rewrite_string -= a->rewrite_header.data_bytes;
519 s =
format (s,
"rewrite data: %U ",
521 a->rewrite_header.data_bytes);
549 vlib_cli_output (vm,
"%U", format_l2xcrw, vnm, t);
556 .path =
"show l2xcrw",
557 .short_help =
"Display L2/L3 rewrite cross-connects",
#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)
#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)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
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
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)
struct _vlib_node_registration vlib_node_registration_t
unformat_function_t unformat_vnet_sw_interface
format_function_t format_vnet_sw_if_index_name
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
always_inline vlib_main_t * vlib_get_main(void)
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)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
#define VLIB_INIT_FUNCTION(x)
#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)
always_inline uword pool_elts(void *v)
#define clib_warning(format, args...)
format_function_t format_vlib_next_node_name
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define pool_elt_at_index(p, i)
l2_xcrw_tunnel_t * tunnels
uword * fib_index_by_table_id
vlib_error_main_t error_main
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
#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,...)
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
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
#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)
#define VLIB_NODE_FLAG_TRACE
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
#define VLIB_BUFFER_IS_TRACED
VNET_DEVICE_CLASS(xcrw_device_class, static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
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
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_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define VLIB_REGISTER_NODE(x,...)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
l2_xcrw_adjacency_t * adj_by_sw_if_index
always_inline 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)