65 error = VNET_API_ERROR_INVALID_INTERFACE;
82 push_outer_et = clib_net_to_host_u16 (push_dot1q ? ETHERNET_TYPE_VLAN : ETHERNET_TYPE_DOT1AD);
83 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
84 vtr_tag1 = clib_net_to_host_u16 (vtr_tag1);
85 vtr_tag2 = clib_net_to_host_u16 (vtr_tag2);
113 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
122 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
136 in_config->
tags[1].
type = push_outer_et;
143 in_config->
tags[0].
type = push_outer_et;
145 in_config->
tags[1].
type = push_inner_et;
150 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
156 in_config->
tags[1].
type = push_outer_et;
161 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
167 in_config->
tags[0].
type = push_outer_et;
169 in_config->
tags[1].
type = push_inner_et;
174 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
180 in_config->
tags[1].
type = push_outer_et;
185 error = VNET_API_ERROR_INVALID_VLAN_TAG_COUNT;
191 in_config->
tags[0].
type = push_outer_et;
193 in_config->
tags[1].
type = push_inner_et;
204 push_outer_et = clib_net_to_host_u16 (si->
sub.
eth.
flags.dot1ad ? ETHERNET_TYPE_DOT1AD : ETHERNET_TYPE_VLAN);
205 push_inner_et = clib_net_to_host_u16 (ETHERNET_TYPE_VLAN);
211 out_config->
tags[1].
type = push_outer_et;
214 out_config->
tags[0].
type = push_outer_et;
216 out_config->
tags[1].
type = push_inner_et;
242 if (!vtr_op || !push_dot1q || !vtr_tag1 || !vtr_tag2) {
244 error = VNET_API_ERROR_INVALID_ARGUMENT;
282 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[1].
type));
288 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[0].
type));
292 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
305 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[1].
type));
311 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[0].
type));
315 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
328 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[1].
type));
334 *push_dot1q = (ETHERNET_TYPE_VLAN == clib_host_to_net_u16 (in_config->
tags[0].
type));
338 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
345 error = VNET_API_ERROR_UNEXPECTED_INTF_STATE;
367 u32 tag1 = 0, tag2 = 0;
380 }
else if (
unformat (input,
"pop 1")) {
382 }
else if (
unformat (input,
"pop 2")) {
385 }
else if (
unformat (input,
"push dot1q %d %d", &tag1, &tag2)) {
388 }
else if (
unformat (input,
"push dot1ad %d %d", &tag1, &tag2)) {
391 }
else if (
unformat (input,
"push dot1q %d", &tag1)) {
394 }
else if (
unformat (input,
"push dot1ad %d", &tag1)) {
397 }
else if (
unformat (input,
"translate 1-1 dot1q %d", &tag1)) {
400 }
else if (
unformat (input,
"translate 1-1 dot1ad %d", &tag1)) {
403 }
else if (
unformat (input,
"translate 2-1 dot1q %d", &tag1)) {
406 }
else if (
unformat (input,
"translate 2-1 dot1ad %d", &tag1)) {
409 }
else if (
unformat (input,
"translate 2-2 dot1q %d %d", &tag1, &tag2)) {
412 }
else if (
unformat (input,
"translate 2-2 dot1ad %d %d", &tag1, &tag2)) {
415 }
else if (
unformat (input,
"translate 1-2 dot1q %d %d", &tag1, &tag2)) {
418 }
else if (
unformat (input,
"translate 1-2 dot1ad %d %d", &tag1, &tag2)) {
422 error =
clib_error_return (0,
"expecting [disable | pop 1 | pop 2 | push {dot1q|dot1ah} <tag> [<tag>]\n" 423 " | translate {1|2}-{1|2} {dot1q|dot1ah} <tag> [<tag>]] but got `%U'",
435 error =
clib_error_return (0,
"vlan tag rewrite is not compatible with interface");
444 .path =
"set interface l2 tag-rewrite",
445 .short_help =
"set interface l2 tag-rewrite <interface> [disable | pop {1|2} | push {dot1q|dot1ad} <tag> <tag>]",
struct vnet_sub_interface_t::@91 eth
#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)
clib_error_t * l2_vtr_init(vlib_main_t *vm)
unformat_function_t unformat_vnet_sw_interface
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
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * int_l2_vtr(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ethernet_vlan_header_tv_t tags[2]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct vnet_sub_interface_t::@91::@92::@94 flags
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)
vnet_sw_interface_type_t type
#define clib_error_return(e, args...)