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;
424 if (
unformat (line_input,
"next %U",
427 else if (
unformat (line_input,
"tx-fib-id %d", &tx_fib_id))
429 else if (
unformat (line_input,
"del"))
431 else if (
unformat (line_input,
"ipv6"))
438 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>",
500 s =
format (s,
"%-25s%s",
"L2 interface",
"Tunnel Details");
504 s =
format (s,
"%-25U %U ",
510 s =
format (s,
"next %U ",
512 a->rewrite_header.next_index);
514 if (a->rewrite_header.sw_if_index != ~0)
515 s =
format (s,
"tx fib index %d ", a->rewrite_header.sw_if_index);
517 if (a->rewrite_header.data_bytes)
519 rewrite_string = (
u8 *) (a + 1);
520 rewrite_string -= a->rewrite_header.data_bytes;
521 s =
format (s,
"rewrite data: %U ",
523 a->rewrite_header.data_bytes);
551 vlib_cli_output (vm,
"%U", format_l2xcrw, vnm, t);
560 .path =
"show l2xcrw",
561 .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)
Release pointer to next frame vector data.
#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 vlib_main_t * vlib_get_main(void)
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)
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)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#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_warning(format, 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
#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).
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
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#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
#define VLIB_BUFFER_IS_TRACED
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)
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
#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_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#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)
#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
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.