From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jianfeng Tan Subject: [PATCH 2/2] examples/tep_term: fix inner L4 checksum failure Date: Thu, 4 Aug 2016 07:58:49 +0000 Message-ID: <1470297529-100773-3-git-send-email-jianfeng.tan@intel.com> References: <1470297529-100773-1-git-send-email-jianfeng.tan@intel.com> Cc: konstantin.ananyev@intel.com, jingjing.wu@intel.com, mark.b.kavanagh@intel.com, Jianfeng Tan To: dev@dpdk.org Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3F3212C60 for ; Thu, 4 Aug 2016 09:58:59 +0200 (CEST) In-Reply-To: <1470297529-100773-1-git-send-email-jianfeng.tan@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- examples/tep_termination/vxlan.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/tep_termination/vxlan.c b/examples/tep_termination/vxlan.c index 4bad33d..155415c 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); -- 2.7.4