From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0082.outbound.protection.outlook.com [104.47.41.82]) by dpdk.org (Postfix) with ESMTP id B294DA48B for ; Mon, 15 Jan 2018 13:46:16 +0100 (CET) Received: from CY4PR03CA0097.namprd03.prod.outlook.com (10.171.242.166) by DM5PR03MB2698.namprd03.prod.outlook.com (10.168.197.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Mon, 15 Jan 2018 12:46:15 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::191) by CY4PR03CA0097.outlook.office365.com (2603:10b6:910:4d::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Mon, 15 Jan 2018 12:46:15 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Mon, 15 Jan 2018 12:46:15 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0FCkBUR023055; Mon, 15 Jan 2018 05:46:12 -0700 From: Akhil Goyal To: CC: , , , Akhil Goyal Date: Mon, 15 Jan 2018 18:12:12 +0530 Message-ID: <20180115124212.7011-1-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131604939753395115; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(396003)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(59450400001)(53936002)(8656006)(5660300001)(4326008)(50466002)(15650500001)(48376002)(97736004)(86362001)(6916009)(2351001)(106466001)(47776003)(104016004)(54906003)(85426001)(1076002)(16586007)(316002)(296002)(50226002)(81166006)(356003)(8936002)(305945005)(2906002)(8676002)(77096006)(51416003)(68736007)(81156014)(36756003)(105606002)(498600001)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2698; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:XPALKbUfXGIpTJnEe839elp1cxnFpcS6M9mjWXe2Z58Cao0OeyhGgj9HoAoufPpzhlMbU57Dov9k41tERckM02uVy3Bpt06k9CjTBZnM1DLRr0P0vDsEc0x5RmED2ro2 MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3384ce92-c5bd-46a7-13ab-08d55c15f727 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:DM5PR03MB2698; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2698; 3:Y0mHBN5ia93czchnynfg9x1KcBegFj5gqSBZ4Hjr5rQsJ4z7SmzUkQnXeFqewwhS9dHJVRdEktIfzuljjh0OoG6eGCGyl/EK48UE541fwRzTOFSWiRprVvPs3wpkLNOmwzvXohXdfpTQFNIV+f97N77jMgz9bt22Ku3ezR1Ca/ybgyG9PgdSRD1tALu+/5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ejD00HSGACL0L4Nd57QPNttVFmAtn6T3z6njOHP5dP2WuLamGEDnBwOATkQME3nQ6R2vPHuG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231023)(944501161)(6055026)(6096035)(20161123565025)(20161123559100)(20161123556025)(20161123561025)(201703131430075)(201703131520075)(201703131433075)(201703131448075)(201703151042153)(20161123563025)(201708071742011); SRVR:DM5PR03MB2698; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:DM5PR03MB2698; X-Forefront-PRVS: 0553CBB77A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2698; 23:cn9fBEEoH+PUmNuCyaiMm7puT3kMEFR8cvqecEEi+?= =?us-ascii?Q?5JV0gAeKYmi60uHqyCTmMv10H5V6DvmKZtH9zhuG+JYAnQkgjgN0jr2ASk91?= =?us-ascii?Q?HSYvDWREJI5LsPMDx6kTkc1QPCt8Agql+n/nNZs2naRkrPlBtg7ngLSaGOPF?= =?us-ascii?Q?NcM1N0dZbc4IrZ1ur+RX2FbuUdqsTWLTovBxRxTBQ9gXT+gIMtwDYL19A7Sk?= =?us-ascii?Q?k4ZcSJv2UIhNJ/6zyPgemqT6y5oahPNm7XLeggd46idS1TjW/YEtKz3Yur/e?= =?us-ascii?Q?yTua1QHkgQIKbN9bjWA1XlxbGGqxmqOOwbwF18f1uFLdrbj+9M51ZsBmMLr5?= =?us-ascii?Q?eoH162bBUnKTZtRvHRgIlTTAdBH3EblIQkbNysVj0vhEyxVwsalmZG3uOoem?= =?us-ascii?Q?GxZzK4fCndJjFODg2bdHXc8GUpmWigE6FLL6zdNNOgL6nInp18PG1ega977+?= =?us-ascii?Q?W3Ylds/0IVFLJe4wrj8HLnzA93H1bak9+euqLRHVqHNUEwgJKkFCuV0oUbjb?= =?us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FLqUJuV5G5eRaVY8leSX9E3VJtln0V/10EdxAy4ozd5JWQCUsC2zlrBIbB4LS3mxCXKfXZzR9v1+2Ylb0d4OMJKedO1NJvMzVs=; 5:BGS8AY1agswvqIWXjUQaG5PDv8FzzeeV53m5Ef+llswnESH2A4QbdtJE/hG0J8ln3mdMI9iJg/kJXhT1i3OraNsJjp2zXd/WkzqSxr36RRURjG/F2gcUDAoj+xmNm/WIInh4xsfb/ihvtah1066xsQPVM/DtGIxMFsbrfoDIkWw=; 24:S1VJsRLCFIM693N8W04DNX3L41DYkqTMv/LnBO66L9jpQgmE913d7QPDcik9pQC7VOik37EAvgewNE+jORgCs6ymwgfB44jYgLDFWfEPUDQ=; 7:VEmFL3ozb+ef+OJmPHn/dCAKrhz5rq7BTvLGM8wzJAr3nB8PQyfmUDuvo56IEo0H/+PAnY4ZuqDX7YRd0wNPEQuVaxH8asBpBv2fioBT5j4BmFKIdazVnZsxPAlSuenIunlTDBLeY/5oHL1KrOPWYQBsiojaNF1X7Fyb6Ytl+F0zeRJw67amISxvhP8wFemxIkOb0fHWJIKMX/qr+1XJKPWQKA+JwV6N25MpLJB1N5mJpjsVvFtCHnCOLTEX9n18 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2018 12:46:15.1835 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3384ce92-c5bd-46a7-13ab-08d55c15f727 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2698 Subject: [dpdk-dev] [PATCH] examples/ipsec-secgw: update incremental checksum X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 12:46:17 -0000 When TTL is decremented or ecn is updated in IP header before forwarding the packet, checksum needs to be updated. In this patch an incremental checksum is added for ipv4 case. Signed-off-by: Akhil Goyal --- examples/ipsec-secgw/ipip.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/ipsec-secgw/ipip.h b/examples/ipsec-secgw/ipip.h index fb6a6fa..13b8455 100644 --- a/examples/ipsec-secgw/ipip.h +++ b/examples/ipsec-secgw/ipip.h @@ -27,6 +27,10 @@ ipip_outbound(struct rte_mbuf *m, uint32_t offset, uint32_t is_ipv6, if (inip4->ip_v == IPVERSION) { /* XXX This should be done by the forwarding engine instead */ inip4->ip_ttl -= 1; + if (inip4->ip_sum >= rte_cpu_to_be_16(0xffff - 0x100)) + inip4->ip_sum += rte_cpu_to_be_16(0x100) + 1; + else + inip4->ip_sum += rte_cpu_to_be_16(0x100); ds_ecn = inip4->ip_tos; } else { inip6 = (struct ip6_hdr *)inip4; @@ -95,8 +99,17 @@ ip6ip_outbound(struct rte_mbuf *m, uint32_t offset, static inline void ip4_ecn_setup(struct ip *ip4) { - if (ip4->ip_tos & IPTOS_ECN_MASK) + if (ip4->ip_tos & IPTOS_ECN_MASK) { + unsigned long sum; + uint8_t old; + + old = ip4->ip_tos; ip4->ip_tos |= IPTOS_ECN_CE; + sum = old + (~(*(uint8_t *)&ip4->ip_tos) & 0xff); + sum += rte_be_to_cpu_16(ip4->ip_sum); + sum = (sum & 0xffff) + (sum >> 16); + ip4->ip_sum = rte_cpu_to_be_16(sum + (sum >> 16)); + } } static inline void @@ -140,6 +153,10 @@ ipip_inbound(struct rte_mbuf *m, uint32_t offset) ip4_ecn_setup(inip4); /* XXX This should be done by the forwarding engine instead */ inip4->ip_ttl -= 1; + if (inip4->ip_sum >= rte_cpu_to_be_16(0xffff - 0x100)) + inip4->ip_sum += rte_cpu_to_be_16(0x100) + 1; + else + inip4->ip_sum += rte_cpu_to_be_16(0x100); m->packet_type &= ~RTE_PTYPE_L4_MASK; if (inip4->ip_p == IPPROTO_UDP) m->packet_type |= RTE_PTYPE_L4_UDP; -- 2.9.3