66 error = VNET_API_ERROR_INVALID_INTERFACE;
86 clib_net_to_host_u16 (push_dot1q ? ETHERNET_TYPE_VLAN :
87 ETHERNET_TYPE_DOT1AD);
88 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
89 vtr_tag1 = clib_net_to_host_u16 (vtr_tag1);
90 vtr_tag2 = clib_net_to_host_u16 (vtr_tag2);
129 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
139 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
153 in_config->
tags[1].
type = push_outer_et;
160 in_config->
tags[0].
type = push_outer_et;
162 in_config->
tags[1].
type = push_inner_et;
168 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
174 in_config->
tags[1].
type = push_outer_et;
180 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
186 in_config->
tags[0].
type = push_outer_et;
188 in_config->
tags[1].
type = push_inner_et;
194 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
200 in_config->
tags[1].
type = push_outer_et;
206 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
212 in_config->
tags[0].
type = push_outer_et;
214 in_config->
tags[1].
type = push_inner_et;
228 clib_net_to_host_u16 (si->
sub.
eth.
flags.dot1ad ? ETHERNET_TYPE_DOT1AD :
230 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
237 out_config->
tags[1].
type = push_outer_et;
242 out_config->
tags[0].
type = push_outer_et;
244 out_config->
tags[1].
type = push_inner_et;
269 if (!vtr_op || !push_dot1q || !vtr_tag1 || !vtr_tag2)
272 error = VNET_API_ERROR_INVALID_ARGUMENT;
318 (ETHERNET_TYPE_VLAN ==
319 clib_host_to_net_u16 (in_config->
tags[1].
type));
328 (ETHERNET_TYPE_VLAN ==
329 clib_host_to_net_u16 (in_config->
tags[0].
type));
334 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
350 (ETHERNET_TYPE_VLAN ==
351 clib_host_to_net_u16 (in_config->
tags[1].
type));
360 (ETHERNET_TYPE_VLAN ==
361 clib_host_to_net_u16 (in_config->
tags[0].
type));
366 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
382 (ETHERNET_TYPE_VLAN ==
383 clib_host_to_net_u16 (in_config->
tags[1].
type));
392 (ETHERNET_TYPE_VLAN ==
393 clib_host_to_net_u16 (in_config->
tags[0].
type));
398 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
405 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
429 u32 tag1 = 0, tag2 = 0;
453 else if (
unformat (input,
"push dot1q %d %d", &tag1, &tag2))
458 else if (
unformat (input,
"push dot1ad %d %d", &tag1, &tag2))
463 else if (
unformat (input,
"push dot1q %d", &tag1))
468 else if (
unformat (input,
"push dot1ad %d", &tag1))
473 else if (
unformat (input,
"translate 1-1 dot1q %d", &tag1))
478 else if (
unformat (input,
"translate 1-1 dot1ad %d", &tag1))
483 else if (
unformat (input,
"translate 2-1 dot1q %d", &tag1))
488 else if (
unformat (input,
"translate 2-1 dot1ad %d", &tag1))
493 else if (
unformat (input,
"translate 2-2 dot1q %d %d", &tag1, &tag2))
498 else if (
unformat (input,
"translate 2-2 dot1ad %d %d", &tag1, &tag2))
503 else if (
unformat (input,
"translate 1-2 dot1q %d %d", &tag1, &tag2))
508 else if (
unformat (input,
"translate 1-2 dot1ad %d %d", &tag1, &tag2))
517 "expecting [disable | pop 1 | pop 2 | push {dot1q|dot1ah} <tag> [<tag>]\n" 518 " | translate {1|2}-{1|2} {dot1q|dot1ah} <tag> [<tag>]] but got `%U'",
523 if (
l2vtr_configure (vm, vnm, sw_if_index, vtr_op, push_dot1q, tag1, tag2))
527 "vlan tag rewrite is not compatible with interface");
537 .path =
"set interface l2 tag-rewrite",
538 .short_help =
"set interface l2 tag-rewrite <interface> [disable | pop {1|2} | push {dot1q|dot1ad} <tag> <tag>]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 l2vtr_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u32 push_dot1q, u32 vtr_tag1, u32 vtr_tag2)
Configure vtag tag rewrite on the given interface.
clib_error_t * l2_vtr_init(vlib_main_t *vm)
Just a placeholder; ensures file is not eliminated by linker.
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct vnet_sub_interface_t::@120::@121::@123 flags
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
Per-interface vlan tag rewrite configuration There will be one instance of this struct for each sw_if...
vnet_main_t * vnet_get_main(void)
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_warning(format, args...)
int vlib_main(vlib_main_t *vm, unformat_input_t *input)
l2output_main_t l2output_main
vnet_hw_interface_class_t ethernet_hw_interface_class
struct vnet_sub_interface_t::@120 eth
static clib_error_t * int_l2_vtr(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface vtr enable/disable.
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
ethernet_vlan_header_tv_t tags[2]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
l2_output_config_t * configs
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
vnet_sw_interface_type_t type
#define clib_error_return(e, args...)