summaryrefslogtreecommitdiffstats
path: root/src/vnet/vxlan/encap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/vxlan/encap.c')
-rw-r--r--src/vnet/vxlan/encap.c53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c
index 2bc221adaff..787758a94f8 100644
--- a/src/vnet/vxlan/encap.c
+++ b/src/vnet/vxlan/encap.c
@@ -18,6 +18,7 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/interface_output.h>
#include <vnet/vxlan/vxlan.h>
#include <vnet/qos/qos_types.h>
#include <vnet/adj/rewrite.h>
@@ -98,8 +99,18 @@ vxlan_encap_inline (vlib_main_t * vm,
sizeof (ip4_vxlan_header_t) : sizeof (ip6_vxlan_header_t);
u16 const l3_len = is_ip4 ? sizeof (ip4_header_t) : sizeof (ip6_header_t);
u32 const csum_flags = is_ip4 ? VNET_BUFFER_F_OFFLOAD_IP_CKSUM |
- VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM :
- VNET_BUFFER_F_IS_IP6 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
+ VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
+ VNET_BUFFER_F_L3_HDR_OFFSET_VALID | VNET_BUFFER_F_L4_HDR_OFFSET_VALID :
+ VNET_BUFFER_F_IS_IP6 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
+ VNET_BUFFER_F_L3_HDR_OFFSET_VALID | VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
+ u32 const inner_packet_csum_offload_flags =
+ VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
+ VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ u32 const inner_packet_removed_flags =
+ VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_IS_IP6 |
+ VNET_BUFFER_F_L2_HDR_OFFSET_VALID | VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
+ VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
+
vlib_get_buffers (vm, from, bufs, n_left_from);
while (n_left_from > 0)
@@ -132,6 +143,30 @@ vxlan_encap_inline (vlib_main_t * vm,
vlib_buffer_t *b1 = b[1];
b += 2;
+ u32 or_flags = b0->flags | b1->flags;
+ if (csum_offload && (or_flags & inner_packet_csum_offload_flags))
+ {
+ /* Only calculate the non-GSO packet csum offload */
+ if ((b0->flags & VNET_BUFFER_F_GSO) == 0)
+ {
+ vnet_calc_checksums_inline (vm, b0,
+ b0->flags &
+ VNET_BUFFER_F_IS_IP4,
+ b0->flags &
+ VNET_BUFFER_F_IS_IP6);
+ b0->flags &= ~inner_packet_removed_flags;
+ }
+ if ((b1->flags & VNET_BUFFER_F_GSO) == 0)
+ {
+ vnet_calc_checksums_inline (vm, b1,
+ b1->flags &
+ VNET_BUFFER_F_IS_IP4,
+ b1->flags &
+ VNET_BUFFER_F_IS_IP6);
+ b1->flags &= ~inner_packet_removed_flags;
+ }
+ }
+
u32 flow_hash0 = vnet_l2_compute_flow_hash (b0);
u32 flow_hash1 = vnet_l2_compute_flow_hash (b1);
@@ -342,6 +377,20 @@ vxlan_encap_inline (vlib_main_t * vm,
vlib_buffer_t *b0 = b[0];
b += 1;
+ if (csum_offload && (b0->flags & inner_packet_csum_offload_flags))
+ {
+ /* Only calculate the non-GSO packet csum offload */
+ if ((b0->flags & VNET_BUFFER_F_GSO) == 0)
+ {
+ vnet_calc_checksums_inline (vm, b0,
+ b0->flags &
+ VNET_BUFFER_F_IS_IP4,
+ b0->flags &
+ VNET_BUFFER_F_IS_IP6);
+ b0->flags &= ~inner_packet_removed_flags;
+ }
+ }
+
u32 flow_hash0 = vnet_l2_compute_flow_hash (b0);
/* Get next node index and adj index from tunnel next_dpo */