From: Jianfeng Tan Date: Thu, 4 Aug 2016 07:58:49 +0000 (+0000) Subject: examples/tep_term: fix inner L4 checksum X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d3ab8f9737099267cd5de0c6b97d36ac5844a8b2;p=dpdk.git examples/tep_term: fix inner L4 checksum When sending packets from virtual machine which in need of TSO by hardware NIC, the inner L4 checksum is not correct on the other side of the cable. It's because get_psd_sum() depends on PKT_TX_TCP_SEG to calculate pseudo-header checksum, but currently this bit is set after the function get_psd_sum() is called. The fix is straightforward. Move the bit setting before get_psd_sum() is called. Fixes: a50245ede72a ("examples/tep_term: initialize VXLAN sample") Signed-off-by: Jianfeng Tan --- diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c index 4bad33d62d..155415c873 100644 --- a/examples/tep_termination/vxlan.c +++ b/examples/tep_termination/vxlan.c @@ -141,14 +141,17 @@ process_inner_cksums(struct ether_hdr *eth_hdr, union tunnel_offload_info *info) ethertype, ol_flags); } else if (l4_proto == IPPROTO_TCP) { tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); - ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, - ol_flags); + /* Put PKT_TX_TCP_SEG bit setting before get_psd_sum(), because + * it depends on PKT_TX_TCP_SEG to calculate pseudo-header + * checksum. + */ if (tso_segsz != 0) { ol_flags |= PKT_TX_TCP_SEG; info->tso_segsz = tso_segsz; info->l4_len = sizeof(struct tcp_hdr); } + ol_flags |= PKT_TX_TCP_CKSUM; + tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); } else if (l4_proto == IPPROTO_SCTP) { sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len);