From 6636440abf08f9386d5edc782b59dccf8a4fe7a0 Mon Sep 17 00:00:00 2001 From: "Igor Mikhailov (imichail)" Date: Tue, 24 Apr 2018 21:53:00 -0700 Subject: Carry recorded QOS bits in the outer VXLAN IP header Currently for VXLAN IPv4. Change-Id: Id4b8bc0d9f6ab043810e4d1b9f28e01c27ce0660 Signed-off-by: Igor Mikhailov (imichail) --- src/vnet/vxlan/encap.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c index 107e66e4335..f9871d533ff 100644 --- a/src/vnet/vxlan/encap.c +++ b/src/vnet/vxlan/encap.c @@ -19,6 +19,7 @@ #include #include #include +#include /* Statistics (not all errors) */ #define foreach_vxlan_encap_error \ @@ -181,6 +182,7 @@ vxlan_encap_inline (vlib_main_t * vm, u16 payload_l1 = clib_host_to_net_u16 (len1 - l3_len); ip4_header_t * ip4_0, * ip4_1; + qos_bits_t ip4_0_tos = 0, ip4_1_tos = 0; ip6_header_t * ip6_0, * ip6_1; udp_header_t * udp0, * udp1; u8 * l3_0, * l3_1; @@ -199,6 +201,17 @@ vxlan_encap_inline (vlib_main_t * vm, ip4_0->length = clib_host_to_net_u16 (len0); ip4_1->length = clib_host_to_net_u16 (len1); + if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_QOS_DATA_VALID)) + { + ip4_0_tos = vnet_buffer2 (b0)->qos.bits; + ip4_0->tos = ip4_0_tos; + } + if (PREDICT_FALSE (b1->flags & VNET_BUFFER_F_QOS_DATA_VALID)) + { + ip4_1_tos = vnet_buffer2 (b1)->qos.bits; + ip4_1->tos = ip4_1_tos; + } + l3_0 = (u8 *)ip4_0; l3_1 = (u8 *)ip4_1; udp0 = &hdr0->udp; @@ -246,10 +259,20 @@ vxlan_encap_inline (vlib_main_t * vm, ip_csum_t sum0 = ip4_0->checksum; sum0 = ip_csum_update (sum0, 0, ip4_0->length, ip4_header_t, length /* changed member */); + if (PREDICT_FALSE (ip4_0_tos)) + { + sum0 = ip_csum_update (sum0, 0, ip4_0_tos, ip4_header_t, + tos /* changed member */); + } ip4_0->checksum = ip_csum_fold (sum0); ip_csum_t sum1 = ip4_1->checksum; sum1 = ip_csum_update (sum1, 0, ip4_1->length, ip4_header_t, length /* changed member */); + if (PREDICT_FALSE (ip4_1_tos)) + { + sum1 = ip_csum_update (sum1, 0, ip4_1_tos, ip4_header_t, + tos /* changed member */); + } ip4_1->checksum = ip_csum_fold (sum1); } /* IPv6 UDP checksum is mandatory */ @@ -329,6 +352,7 @@ vxlan_encap_inline (vlib_main_t * vm, udp_header_t * udp0; ip4_header_t * ip4_0; + qos_bits_t ip4_0_tos = 0; ip6_header_t * ip6_0; u8 * l3_0; if (is_ip4) @@ -341,6 +365,12 @@ vxlan_encap_inline (vlib_main_t * vm, ip4_0 = &hdr->ip4; ip4_0->length = clib_host_to_net_u16 (len0); + if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_QOS_DATA_VALID)) + { + ip4_0_tos = vnet_buffer2 (b0)->qos.bits; + ip4_0->tos = ip4_0_tos; + } + l3_0 = (u8*)ip4_0; udp0 = &hdr->udp; } @@ -374,6 +404,11 @@ vxlan_encap_inline (vlib_main_t * vm, ip_csum_t sum0 = ip4_0->checksum; sum0 = ip_csum_update (sum0, 0, ip4_0->length, ip4_header_t, length /* changed member */); + if (PREDICT_FALSE (ip4_0_tos)) + { + sum0 = ip_csum_update (sum0, 0, ip4_0_tos, ip4_header_t, + tos /* changed member */); + } ip4_0->checksum = ip_csum_fold (sum0); } /* IPv6 UDP checksum is mandatory */ -- cgit 1.2.3-korg