DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <akhil.goyal@nxp.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] ip_chksum not updated in ipsec-secgw application
Date: Mon, 18 Jul 2016 12:41:05 +0000	[thread overview]
Message-ID: <DB3PR04MB1073850452F0411F413F395E6360@DB3PR04MB107.eurprd04.prod.outlook.com> (raw)

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?

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 <rte_mbuf.h>

#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

             reply	other threads:[~2016-07-18 12:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 12:41 Akhil Goyal [this message]
2016-07-18 12:57 ` Sergio Gonzalez Monroy
2016-07-18 13:20   ` Thomas Monjalon
2016-07-18 13:53     ` Akhil Goyal
2016-07-18 13:57       ` Sergio Gonzalez Monroy
2016-07-18 14:09         ` Thomas Monjalon
2016-07-18 14:25           ` Sergio Gonzalez Monroy
2016-07-18 13:49   ` Akhil Goyal
2016-07-18 14:00     ` Sergio Gonzalez Monroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB3PR04MB1073850452F0411F413F395E6360@DB3PR04MB107.eurprd04.prod.outlook.com \
    --to=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).