From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0086.outbound.protection.outlook.com [104.47.2.86]) by dpdk.org (Postfix) with ESMTP id B3A8FE6D for ; Mon, 18 Jul 2016 14:41:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uRdx8LEGjURYgUW1QR4HS8/Y43+kzqclUj4fifWlUuM=; b=HSILX8goo4cDw8C5dq167rI/qe4C8zj/FnLK5ObWLzQEoPUFlNEl0fKrH584WCyCRYXRrC0wTGKRCOn5EG8euGwJ4vKBKcYZ2azK4lWR+qA6ju+HzUu/4oI3YZDiEBKTc9oth1EfuHwyBPsHGqT7xOMbYDzptOnedpKNxCxyank= Received: from DB3PR04MB107.eurprd04.prod.outlook.com (10.242.129.20) by DB3PR04MB108.eurprd04.prod.outlook.com (10.242.129.25) with Microsoft SMTP Server (TLS) id 15.1.539.6; Mon, 18 Jul 2016 12:41:05 +0000 Received: from DB3PR04MB107.eurprd04.prod.outlook.com ([169.254.12.17]) by DB3PR04MB107.eurprd04.prod.outlook.com ([169.254.12.17]) with mapi id 15.01.0539.019; Mon, 18 Jul 2016 12:41:06 +0000 From: Akhil Goyal To: "dev@dpdk.org" Thread-Topic: ip_chksum not updated in ipsec-secgw application Thread-Index: AdHg7lCKLMtEfGA5QMe00lC33OFqiw== Date: Mon, 18 Jul 2016 12:41:05 +0000 Message-ID: Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=akhil.goyal@nxp.com; x-originating-ip: [192.88.169.1] x-ms-office365-filtering-correlation-id: 223d54f6-487b-43a8-1308-08d3af08c94a x-microsoft-exchange-diagnostics: 1; DB3PR04MB108; 6:e29/hrXKPZFFd4WimBQGUJw+m9I9NetVsGnx7NcC1F+CJaANotwgzv6LIYl9+DpQ++ajlF0uzojY2xjz1I0+Tq6DQKCTTiSPuYVIpj3a94koVo6VtC51Pl5JVKkCz/PDHDlgRCwhl7U24VcYnmA/OjsKHhvtjb7gdEZqC8M+dHkaVx1p0koc9z/C/GbDwECQQrJCqer1gQ8GdAVgcv5gU9VIm89NRILrTCMbP5pjOaAYsuHu6pLKa85Ym0pjbNOqhBpev36ez2nvPHndgcTHKYjEBsKp3LsPAzTGRfj52NJJFBZp7SHpWn/wuaUIcf/H097nfM5oCXrORRhlNUvrlQ==; 5:c+zyBRZ5EFX5roohERvE7gCJuJ0N8qllp8jbbimrOKc58BL1WmE01TxnzLkahBOwZiPLB6QX5gurot+BGW78EzAUTujjC+dbcXgVks1KF2Q/oegMhafxa+B3aCrwaQzrYvznM4Z/BYU9ZI8g8KSiYQ==; 24:xZ4FaII5FqBnC2YqFjugKOQUQt5DBGUcSp9D1yynXWmC6IB2Gb9rM1LSCsewj2j5uW76DWfWRFKIxu6VtgzYVY2BxfiSy1TWFriKJaipG+E=; 7:byr39ZfsG5zOA7tmRFEXW7AD12M/mVLbqV/KfP4+Tkat33JovyETDAu8CyeK5aqeMjlHBry1wGR2o3Nlt1M+7sBPdaBdKVHhHWL3scoc8fSniP5dQ7gvPHI6M1ef+I8mLvucDg62PNnTbb1paj5WUel/yaTv3kV0T49fp9tytzLulmrqtpOx020Pt59cVcOqXKnvFGQ3a1ZCQb0HoBE1tQ7iJIgoFr8Vi4wlI8f1odZUUop21AvfDuDU5nVKFYZv x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR04MB108; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(21748063052155); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DB3PR04MB108; BCL:0; PCL:0; RULEID:; SRVR:DB3PR04MB108; x-forefront-prvs: 00073DB75F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(199003)(189002)(3846002)(3280700002)(15975445007)(101416001)(7846002)(5003600100003)(7696003)(3660700001)(54356999)(7736002)(74316002)(16236675004)(586003)(50986999)(19625215002)(33656002)(86362001)(66066001)(15650500001)(2420400007)(122556002)(87936001)(68736007)(2906002)(9686002)(9326002)(5002640100001)(102836003)(2900100001)(19580395003)(790700001)(6116002)(10710500007)(19300405004)(8936002)(76576001)(450100001)(106356001)(105586002)(5640700001)(5630700001)(2501003)(10400500002)(97736004)(107886002)(110136002)(189998001)(7110500001)(229853001)(92566002)(2351001)(81166006)(81156014)(1730700003)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR04MB108; H:DB3PR04MB107.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jul 2016 12:41:05.9096 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR04MB108 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [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:41:07 -0000 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. T= his 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 bu= t the checksum value is not updated. Is it intentional or it is done somewh= ere 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 #define IPV6_VERSION (6) +static inline uint16_t +ip_sum(const unaligned_uint16_t *hdr, int hdr_len) +{ + uint32_t sum =3D 0; + + while (hdr_len > 1) + { + sum +=3D *hdr++; + if (sum & 0x80000000) + sum =3D (sum & 0xFFFF) + (sum >> 16); + hdr_len -=3D 2; + } + + while (sum >> 16) + sum =3D (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, uint3= 2_t src, uint32_t dst) outip->ip_src.s_addr =3D src; outip->ip_dst.s_addr =3D dst; - + outip->ip_sum =3D 0; + outip->ip_sum =3D ip_sum((const unaligned_uint16_t *)outip, sizeof(= struct ip)); return outip; } Regards, Akhil