22 #ifndef CLIB_MARCH_VARIANT
43 return format (s,
"VXLAN decap error - tunnel for vni %d does not exist",
45 return format (s,
"VXLAN decap from vxlan_tunnel%d vni %d next %d error %d",
53 .next_index = VXLAN_INPUT_NEXT_DROP,
54 .error = VXLAN_ERROR_NO_SUCH_TUNNEL
59 .next_index = VXLAN_INPUT_NEXT_DROP,
60 .error = VXLAN_ERROR_BAD_FLAGS
83 (key4.
key[0] == cache->
key[0] && key4.
key[1] == cache->
key[1]))
87 *stats_sw_if_index =
di.sw_if_index;
96 *stats_sw_if_index =
di.sw_if_index;
195 u32 pkts_dropped = 0;
209 u32 stats_if0 = ~0, stats_if1 = ~0;
410 #define vxlan_error(n,s) s,
418 .name =
"vxlan4-input",
419 .vector_size =
sizeof (
u32),
425 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n,
433 .name =
"vxlan6-input",
434 .vector_size =
sizeof (
u32),
439 #define _(s,n) [VXLAN_INPUT_NEXT_##s] = n,
463 vtep4_key_t last_vtep4;
465 vtep6_key_t last_vtep6;
503 u32 bi0, ip_len0, udp_len0, flags0, next0;
504 u32 bi1, ip_len1, udp_len1, flags1, next1;
505 i32 len_diff0, len_diff1;
506 u8 error0, good_udp0, proto0;
507 u8 error1, good_udp1, proto1;
508 u32 stats_if0 = ~0, stats_if1 = ~0;
519 bi0 = to_next[0] =
from[0];
520 bi1 = to_next[1] =
from[1];
558 if (proto0 != IP_PROTOCOL_UDP)
581 #ifdef CLIB_HAVE_VEC512
582 if (!vtep4_check_vector (&vxm->
vtep_table, b0, ip40, &last_vtep4,
596 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
603 ip_len0 = clib_net_to_host_u16 (ip40->
length);
606 udp_len0 = clib_net_to_host_u16 (udp0->
length);
607 len_diff0 = ip_len0 - udp_len0;
616 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
621 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
622 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
626 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
627 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
632 b0->
error = error0 ? error_node->
errors[error0] : 0;
646 if (proto1 != IP_PROTOCOL_UDP)
669 #ifdef CLIB_HAVE_VEC512
670 if (!vtep4_check_vector (&vxm->
vtep_table, b1, ip41, &last_vtep4,
684 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
691 ip_len1 = clib_net_to_host_u16 (ip41->
length);
694 udp_len1 = clib_net_to_host_u16 (udp1->
length);
695 len_diff1 = ip_len1 - udp_len1;
704 good_udp1 = (flags1 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
709 error1 = good_udp1 ? 0 : IP4_ERROR_UDP_CHECKSUM;
710 error1 = (len_diff1 >= 0) ? error1 : IP4_ERROR_UDP_LENGTH;
714 error1 = good_udp1 ? 0 : IP6_ERROR_UDP_CHECKSUM;
715 error1 = (len_diff1 >= 0) ? error1 : IP6_ERROR_UDP_LENGTH;
720 b1->
error = error1 ? error_node->
errors[error1] : 0;
734 to_next, n_left_to_next,
735 bi0, bi1, next0, next1);
745 u32 bi0, ip_len0, udp_len0, flags0, next0;
747 u8 error0, good_udp0, proto0;
750 bi0 = to_next[0] =
from[0];
773 if (proto0 != IP_PROTOCOL_UDP)
796 #ifdef CLIB_HAVE_VEC512
797 if (!vtep4_check_vector (&vxm->
vtep_table, b0, ip40, &last_vtep4,
811 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
818 ip_len0 = clib_net_to_host_u16 (ip40->
length);
821 udp_len0 = clib_net_to_host_u16 (udp0->
length);
822 len_diff0 = ip_len0 - udp_len0;
831 good_udp0 = (flags0 & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
836 error0 = good_udp0 ? 0 : IP4_ERROR_UDP_CHECKSUM;
837 error0 = (len_diff0 >= 0) ? error0 : IP4_ERROR_UDP_LENGTH;
841 error0 = good_udp0 ? 0 : IP6_ERROR_UDP_CHECKSUM;
842 error0 = (len_diff0 >= 0) ? error0 : IP6_ERROR_UDP_LENGTH;
847 b0->
error = error0 ? error_node->
errors[error0] : 0;
861 to_next, n_left_to_next,
868 return frame->n_vectors;
881 .name =
"ip4-vxlan-bypass",
882 .vector_size =
sizeof (
u32),
913 .name =
"ip6-vxlan-bypass",
914 .vector_size =
sizeof (
u32),
935 #define foreach_vxlan_flow_input_next \
936 _(DROP, "error-drop") \
937 _(L2_INPUT, "l2-input")
941 #define _(s,n) VXLAN_FLOW_NEXT_##s,
947 #define foreach_vxlan_flow_error \
948 _(NONE, "no error") \
949 _(IP_CHECKSUM_ERROR, "Rx ip checksum errors") \
950 _(IP_HEADER_ERROR, "Rx ip header errors") \
951 _(UDP_CHECKSUM_ERROR, "Rx udp checksum errors") \
952 _(UDP_LENGTH_ERROR, "Rx udp length errors")
956 #define _(f,s) VXLAN_FLOW_ERROR_##f,
979 if ((
flags & VNET_BUFFER_F_L4_CHECKSUM_COMPUTED) == 0)
986 return (
flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0;
995 u8 good_csum = (
b->
flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) != 0 ||
1005 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
1006 u16 expected = payload_len +
sizeof *hdr;
1007 return ip_len > expected || hdr->ip4.ttl == 0
1008 || hdr->ip4.ip_version_and_header_length != 0x45;
1015 u16 ip_len = clib_net_to_host_u16 (hdr->ip4.length);
1016 u16 udp_len = clib_net_to_host_u16 (hdr->udp.length);
1017 return udp_len > ip_len;
1023 u8 error0 = VXLAN_FLOW_ERROR_NONE;
1025 error0 = VXLAN_FLOW_ERROR_IP_HEADER_ERROR;
1027 error0 = VXLAN_FLOW_ERROR_UDP_LENGTH_ERROR;
1029 error0 = VXLAN_FLOW_ERROR_UDP_CHECKSUM_ERROR;
1038 { payload_offset =
sizeof (ip4_vxlan_header_t) };
1043 [VXLAN_FLOW_NEXT_DROP] =
1045 [VXLAN_FLOW_NEXT_L2_INPUT] =
1056 u32 n_left_to_next, *to_next;
1062 u32 bi0 = to_next[0] =
from[0];
1063 u32 bi1 = to_next[1] =
from[1];
1064 u32 bi2 = to_next[2] =
from[2];
1065 u32 bi3 = to_next[3] =
from[3];
1069 n_left_to_next -= 4;
1086 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT, next1 =
1087 VXLAN_FLOW_NEXT_L2_INPUT, next2 =
1088 VXLAN_FLOW_NEXT_L2_INPUT, next3 = VXLAN_FLOW_NEXT_L2_INPUT;
1094 u8 ip_err = ip_err0 | ip_err1 | ip_err2 | ip_err3;
1100 u8 udp_err = udp_err0 | udp_err1 | udp_err2 | udp_err3;
1106 u8 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1118 csum_err = csum_err0 | csum_err1 | csum_err2 | csum_err3;
1123 if (ip_err0 || udp_err0 || csum_err0)
1125 next0 = VXLAN_FLOW_NEXT_DROP;
1129 if (ip_err1 || udp_err1 || csum_err1)
1131 next1 = VXLAN_FLOW_NEXT_DROP;
1135 if (ip_err2 || udp_err2 || csum_err2)
1137 next2 = VXLAN_FLOW_NEXT_DROP;
1141 if (ip_err3 || udp_err3 || csum_err3)
1143 next3 = VXLAN_FLOW_NEXT_DROP;
1185 sw_if_index0, 1, len0);
1187 sw_if_index1, 1, len1);
1189 sw_if_index2, 1, len2);
1191 sw_if_index3, 1, len3);
1197 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1207 if (b1->
flags & VLIB_BUFFER_IS_TRACED)
1217 if (b2->
flags & VLIB_BUFFER_IS_TRACED)
1227 if (b3->
flags & VLIB_BUFFER_IS_TRACED)
1240 bi0, bi1, bi2, bi3, next0, next1, next2, next3);
1244 u32 bi0 = to_next[0] =
from[0];
1254 u32 next0 = VXLAN_FLOW_NEXT_L2_INPUT;
1262 if (ip_err0 || udp_err0 || csum_err0)
1264 next0 = VXLAN_FLOW_NEXT_DROP;
1279 sw_if_index0, 1, len0);
1292 to_next, n_left_to_next,
1303 #ifndef CLIB_MULTIARCH_VARIANT
1305 .name =
"vxlan-flow-input",
1307 .vector_size =
sizeof (
u32),
1316 #define _(s,n) [VXLAN_FLOW_NEXT_##s] = n,