From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id D695EF72 for ; Mon, 18 Jul 2016 14:57:02 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 18 Jul 2016 05:57:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,384,1464678000"; d="scan'208";a="997432198" Received: from smonroyx-mobl.ger.corp.intel.com (HELO [10.237.221.12]) ([10.237.221.12]) by orsmga001.jf.intel.com with ESMTP; 18 Jul 2016 05:57:01 -0700 To: Akhil Goyal , "dev@dpdk.org" References: From: Sergio Gonzalez Monroy Message-ID: <61dc3eb1-2522-78f5-871d-442d473ab69d@intel.com> Date: Mon, 18 Jul 2016 13:57:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] ip_chksum not updated in ipsec-secgw application X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 12:57:03 -0000 Hi, On 18/07/2016 13:41, Akhil Goyal wrote: > Hi, > > In Ipsec-secgw application, while adding the outer IP header, it seems that the application does not update the checksum value for outbound packets. This result in incorrect ip->checksum in the encrypted packet. > > Please let me know if the checksum value is updated somewhere else or not. > > Also In case of inner ip header also the TTL value is decremented by one but the checksum value is not updated. Is it intentional or it is done somewhere else? It is intentional. The application is using IP checksum offload but just looking now at the code there is a bug for IPv6 packets where the flag does not get setup. Is it only for IPv6 traffic that you are having this issue? For IPv4 traffic the PKT_TX_IP_CKSUM flag is setup in 'prepare_tx_pkt' function in ipsec-secgw.c Sergio > After addition of following code, the checksum looks good and the encrypted packets are good. > > diff --git a/examples/ipsec-secgw/ipip.h b/examples/ipsec-secgw/ipip.h > index 322076c..0f7b60f 100644 > --- a/examples/ipsec-secgw/ipip.h > +++ b/examples/ipsec-secgw/ipip.h > @@ -41,6 +41,24 @@ > #include > > #define IPV6_VERSION (6) > +static inline uint16_t > +ip_sum(const unaligned_uint16_t *hdr, int hdr_len) > +{ > + uint32_t sum = 0; > + > + while (hdr_len > 1) > + { > + sum += *hdr++; > + if (sum & 0x80000000) > + sum = (sum & 0xFFFF) + (sum >> 16); > + hdr_len -= 2; > + } > + > + while (sum >> 16) > + sum = (sum & 0xFFFF) + (sum >> 16); > + > + return ~sum; > +} > > static inline struct ip * > ip4ip_outbound(struct rte_mbuf *m, uint32_t offset, uint32_t src, uint32_t dst) > @@ -71,7 +89,8 @@ ip4ip_outbound(struct rte_mbuf *m, uint32_t offset, uint32_t src, uint32_t dst) > > outip->ip_src.s_addr = src; > outip->ip_dst.s_addr = dst; > - > + outip->ip_sum = 0; > + outip->ip_sum = ip_sum((const unaligned_uint16_t *)outip, sizeof(struct ip)); > return outip; > } > > Regards, > Akhil >