From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 90BCAA046B for ; Tue, 25 Jun 2019 15:04:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C12341B9ED; Tue, 25 Jun 2019 15:04:51 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130084.outbound.protection.outlook.com [40.107.13.84]) by dpdk.org (Postfix) with ESMTP id 1CED71B99F; Tue, 25 Jun 2019 15:04:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQAI9TkGybKAyVBPV5RJ18KhotiW0z4WagseLjWHejE=; b=XXBWY4VW6ClYrGbzqwW+lXbQeW3v6csKqaDKiFnWPIOJb9SnpMJM3JDMWpgdPDffhcPquxbKTyQd15fQZlkAtY+PgrUj3o7F+IxJebJR/2RMn0ToSpmIR7a+aee+Bn1A2FDo0I4sffJ5usJULNKmQlDDjfGt8QeP7XiQjTzOB/0= Received: from VE1PR04MB6639.eurprd04.prod.outlook.com (20.179.235.82) by VE1PR04MB6510.eurprd04.prod.outlook.com (20.179.233.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.13; Tue, 25 Jun 2019 13:04:49 +0000 Received: from VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::a929:3d03:7bb7:d5e0]) by VE1PR04MB6639.eurprd04.prod.outlook.com ([fe80::a929:3d03:7bb7:d5e0%7]) with mapi id 15.20.2008.014; Tue, 25 Jun 2019 13:04:49 +0000 From: Akhil Goyal To: Konstantin Ananyev , "dev@dpdk.org" CC: "stable@dpdk.org" Thread-Topic: [PATCH v2 1/5] examples/ipsec-secgw: fix invalid packet length Thread-Index: AQHVHF5MZH8vWBdQiEm6KpNogtx9Aaascxew Date: Tue, 25 Jun 2019 13:04:49 +0000 Message-ID: References: <20190527184448.21264-1-konstantin.ananyev@intel.com> <20190606115151.27805-1-konstantin.ananyev@intel.com> <20190606115151.27805-2-konstantin.ananyev@intel.com> In-Reply-To: <20190606115151.27805-2-konstantin.ananyev@intel.com> 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: [92.120.1.65] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9cb62932-7d3a-4277-d002-08d6f96db4c3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR04MB6510; x-ms-traffictypediagnostic: VE1PR04MB6510: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0079056367 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(366004)(136003)(396003)(346002)(199004)(189003)(110136005)(7736002)(478600001)(53936002)(486006)(68736007)(66446008)(2501003)(73956011)(52536014)(33656002)(71190400001)(66946007)(6436002)(74316002)(71200400001)(86362001)(8936002)(81166006)(3846002)(44832011)(14454004)(66556008)(8676002)(64756008)(305945005)(76116006)(6116002)(81156014)(26005)(316002)(99286004)(25786009)(66066001)(2906002)(186003)(102836004)(7696005)(66476007)(76176011)(6506007)(446003)(6246003)(229853002)(11346002)(55016002)(9686003)(5660300002)(256004)(476003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6510; H:VE1PR04MB6639.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: JrUr/JYj5jH/9oOqlrp2p/hCcb3I6VPRpEquN2Fgvg6nerDHUsFKpk2pfPH0h1fHwdXTIEqHmXEJx5IPqSeniRyhzFpcJLnpzOEZNscIkv62GM3pHT3lge49qO9n3NFJbmRSx/o2TkTv8R945mbCaZiIGtoArUX5yhEFNAwQx/BgaNf2Fb4qDLCcEu+Ean0K0Uwy1CEIQ3qE3uF0Fm/WBu7e9uFXV3eYcRNUHIfNDfpUONiuGJbSM4NGqZznJWfbpOprnzmqeQX3f6RlVrivyYIFUyJduPkj0HsgbP0IEFVApcnLcixZJKxlJgeWM+OOVdC0u6bnG7KmwlAyUUbjc1cxZPwpp39K6E4zjfAMOojdSM65+bmHyjnmQB42U+nhijZnEAQR8qxiLHZYKyKpOZljAA+2rSlAHKEQPIpMAnQ= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb62932-7d3a-4277-d002-08d6f96db4c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 13:04:49.7497 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: akhil.goyal@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6510 Subject: Re: [dpdk-dev] [PATCH v2 1/5] examples/ipsec-secgw: fix invalid packet length 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Konstantin, Could you please rebase this patchset. There are some conflicting changes b= ecause of Marcin's patches. Also could you please squash your doc patch with " examples/ipsec-secgw: su= pport packet fragmentation and reassembly " As per convention followed, there should not be separate doc patches. Thanks, Akhil >=20 > for packets smaller then 64B some NICs reports pkt_len=3D64B. > As ipsec-secgw (and librte_ipsec) relies on pkt_len value to determine > payload length, that causes problems for small packets. > To fix the issue, check that pkt_len matches values in IPv4/IPv6 header > and re-adjust pkt_len if necessary. >=20 > Fixes: 906257e965b7 ("examples/ipsec-secgw: support IPv6") > Fixes: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application"= ) > Cc: stable@dpdk.org >=20 > Signed-off-by: Konstantin Ananyev > --- > examples/ipsec-secgw/ipsec-secgw.c | 59 +++++++++++++++++++++++------- > 1 file changed, 46 insertions(+), 13 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec- > secgw/ipsec-secgw.c > index 6c626fa5f..4004f2bc2 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -229,35 +229,68 @@ static struct rte_eth_conf port_conf =3D { >=20 > static struct socket_ctx socket_ctx[NB_SOCKETS]; >=20 > +static inline void > +adjust_ipv4_pktlen(struct rte_mbuf *m, const struct rte_ipv4_hdr *iph, > + uint32_t l2_len) > +{ > + uint32_t plen, trim; > + > + plen =3D rte_be_to_cpu_16(iph->total_length) + l2_len; > + if (plen < m->pkt_len) { > + trim =3D m->pkt_len - plen; > + rte_pktmbuf_trim(m, trim); > + } > +} > + > +static inline void > +adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph, > + uint32_t l2_len) > +{ > + uint32_t plen, trim; > + > + plen =3D rte_be_to_cpu_16(iph->payload_len) + sizeof(*iph) + l2_len; > + if (plen < m->pkt_len) { > + trim =3D m->pkt_len - plen; > + rte_pktmbuf_trim(m, trim); > + } > +} > + > static inline void > prepare_one_packet(struct rte_mbuf *pkt, struct ipsec_traffic *t) > { > - uint8_t *nlp; > - struct rte_ether_hdr *eth; > + const struct rte_ether_hdr *eth; > + const struct rte_ipv4_hdr *iph4; > + const struct rte_ipv6_hdr *iph6; >=20 > - eth =3D rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); > + eth =3D rte_pktmbuf_mtod(pkt, const struct rte_ether_hdr *); > if (eth->ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) { > - nlp =3D (uint8_t *)rte_pktmbuf_adj(pkt, RTE_ETHER_HDR_LEN); > - nlp =3D RTE_PTR_ADD(nlp, offsetof(struct ip, ip_p)); > - if (*nlp =3D=3D IPPROTO_ESP) > + > + iph4 =3D (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt, > + RTE_ETHER_HDR_LEN); > + adjust_ipv4_pktlen(pkt, iph4, 0); > + > + if (iph4->next_proto_id =3D=3D IPPROTO_ESP) > t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > else { > - t->ip4.data[t->ip4.num] =3D nlp; > + t->ip4.data[t->ip4.num] =3D &iph4->next_proto_id; > t->ip4.pkts[(t->ip4.num)++] =3D pkt; > } > pkt->l2_len =3D 0; > - pkt->l3_len =3D sizeof(struct ip); > + pkt->l3_len =3D sizeof(*iph4); > } else if (eth->ether_type =3D=3D rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6)= ) > { > - nlp =3D (uint8_t *)rte_pktmbuf_adj(pkt, RTE_ETHER_HDR_LEN); > - nlp =3D RTE_PTR_ADD(nlp, offsetof(struct ip6_hdr, ip6_nxt)); > - if (*nlp =3D=3D IPPROTO_ESP) > + > + iph6 =3D (const struct rte_ipv6_hdr *)rte_pktmbuf_adj(pkt, > + RTE_ETHER_HDR_LEN); > + adjust_ipv6_pktlen(pkt, iph6, 0); > + > + if (iph6->proto =3D=3D IPPROTO_ESP) > t->ipsec.pkts[(t->ipsec.num)++] =3D pkt; > else { > - t->ip6.data[t->ip6.num] =3D nlp; > + t->ip6.data[t->ip6.num] =3D &iph6->proto; > t->ip6.pkts[(t->ip6.num)++] =3D pkt; > } > pkt->l2_len =3D 0; > - pkt->l3_len =3D sizeof(struct ip6_hdr); > + pkt->l3_len =3D sizeof(*iph6); > } else { > /* Unknown/Unsupported type, drop the packet */ > RTE_LOG(ERR, IPSEC, "Unsupported packet type 0x%x\n", > -- > 2.17.1