From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2DB05A00C4; Thu, 28 Jul 2022 13:02:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C298E40151; Thu, 28 Jul 2022 13:02:08 +0200 (CEST) Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2062.outbound.protection.outlook.com [40.107.117.62]) by mails.dpdk.org (Postfix) with ESMTP id 1EE454014F; Thu, 28 Jul 2022 13:02:07 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QkG33pPw3IuN1sP0aSQpLjNDQ4qg+E7MiADDGwddHzoy7YxCpi3YXM7PR2Cn7RNSJzYe5HybvcKpBQcO95bWUEkl4PQ5XQ6JsghgaQ9Ff1/fhhC669rqwwzOHxalKH1ojl9fTSrl61q0GHk75R46nWfGS5xvleQmr8QmsnRu1DWj5DQb1H0fwiFo+A7zTjrb8qVJK6PDwWWAsL6ypy8uoXe/SJGXWnR1NlKOX5C8CKs8HeecjzDB/14qehOi77bAFmk2CorhS8B1aQvAuy8X5wfn2X50EUbrMzygaIQz39N2j6qN1VQQlnHAEABgdyM76FhlXoGE4zBp0712QqC2tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=63tBvZ8X9B4avvUS/g+aDPUyAqLT/abxEYJ1B8UmaSM=; b=OpHZTLoIVrUcufbwayG3ZjTjY8NQALUOLwN5kIaN9/A+yXlVQZ2OHbkQVIMmTZDv1z665na9WihL/yT5Cqm3CFVquARRxsmRAjaRXAdZPFs5jZ4iVXbvqPuvjc/wK3iNUUgqAnvK+VwZOXjjfDiPVRj271o87736/u+foeP7GKHXh1Ibiq75Q2yw9P+rPGNkUEuBgXxXFfKgg1VfdqZP8goIdlcnGf5vJXv0QxOjaCxcEm8qXWq0RqpYyo5wJUDXTtA34ChwcblrwSlWtpgSoBzC1XFG+HaeyzeqgHXwv6bXn5igunGHt2l+DmvurdHyODpdVagdKNtJPiomdUaOkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=63tBvZ8X9B4avvUS/g+aDPUyAqLT/abxEYJ1B8UmaSM=; b=N3ET1+F49JaQoo94QUM+IF503y9qMb8CvSZ10lHpqAm2DWJbqw1hDGyqRzJPS4bH9tF+K+j2LLFnNrj1urwK0xgIxmpAU3gXsJ/I8NJuE0KWK39KdfY7YxmPzBbImy/xaaVnHTyEk0qKA+CNfkKxhjVh1A9Tor72kUuLXt2G3oDdrAmxTOYaQYxrpgyrl53V/qlekwCRq7OBIuYeLqhWlw79O3PPcuIFRpklcC5Y4i7tIw8U0i3kefF3JEn82X6gBjR+LxtRcSEQMIvoFmZ+jbs/QGlHzMWaxMJUCq3+IK3Y7WHMQQIBMpktJsSKQZAaVRCLLLy64lQL6ogpnRaEvQ== Received: from KL1PR0601MB4530.apcprd06.prod.outlook.com (2603:1096:820:64::10) by SEZPR06MB5714.apcprd06.prod.outlook.com (2603:1096:101:9c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10; Thu, 28 Jul 2022 11:02:02 +0000 Received: from KL1PR0601MB4530.apcprd06.prod.outlook.com ([fe80::59b6:ff9c:d103:9e97]) by KL1PR0601MB4530.apcprd06.prod.outlook.com ([fe80::59b6:ff9c:d103:9e97%9]) with mapi id 15.20.5482.010; Thu, 28 Jul 2022 11:02:01 +0000 From: Jun Qiu To: "Hu, Jiayu" , "dev@dpdk.org" CC: "stable@dpdk.org" Subject: RE: [PATCH] gro: fix gro with ethernet tail padding bytes Thread-Topic: [PATCH] gro: fix gro with ethernet tail padding bytes Thread-Index: AQHYoY8HQI2EJTJAQkuWZDx3BnnlRq2TByWAgACTBpA= Date: Thu, 28 Jul 2022 11:02:01 +0000 Message-ID: References: <20220727080036.27263-1-jun.qiu@jaguarmicro.com> <483ed738105b4547b082d5149687da94@intel.com> In-Reply-To: <483ed738105b4547b082d5149687da94@intel.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 44116cc7-9af7-4043-d690-08da7088994c x-ms-traffictypediagnostic: SEZPR06MB5714:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7e8YbdzQYzJX3JcenSaV5c7l2N9ymH96i/9C4lEL7ib+sfZSDfebSxA5OosK7C3BOODafH+Kk6PY3LeHP0goAnObFfxAiYMBsI2tLjxqygygdl15JKzs1fzKMMN3R0ZT1pVegwd138XF5LJcogLBDy6KdeajbUIsU7OVBDATIrQ9YLcU70zgifXzVRDO4X+mgQe6lAEiXx1wKSiQajjgX3egFqypEM2KGbnpK+mrvFJGlbA6FxMZxIfG8kLBmUxGepedj317hxReE0sSZjhH+sAedOJppjXhA21vSqfw6ZGeJjIkyXSHUJCoRSacM/nZNo7uJnqh9tVlNbaZTSvRKNP7nb4XKtN0dBw8c/k99qS46RcPb6Qx1mg8j8Ffzqfm7oehgtYHx/zKrS0WkVMVu8t9PijyE4WOyWntSIjDL9fedfVsgMKBMaLkRqZsa7C1OAeioc0cr75Mrh1cvt84w2RbG4YNtIGTZasGg78fM+wlQKKkiLHy1wIGlQsWV0uTH+Q2v4jPo222JH0DXkgVkowK7gLO02QUAafAuT6Zl+sg4CbuPz4jLO2fvFNHmHBC7AME8F+tQPWW+q8xqN4g1SscF71W05WBnei1TNq/rTDli3bvHuvdzm920RQdDkzq6YuYYRyQOaIEcyhdk6aXNZpcWwf3KOJYeQug7LlYzWcO6Yw3JCpal7SIH0qn8KfchS1gbRVIKURI4D+wmYepdQxkoOS9bhuuqSUTXu9NdRS4NaC4IpSNF/1U5LcdmEwvjIqwzQDdYbkjr13iTMMUfTnhe2sSgfaAIwVcIPTVxmeDWwiOUoQLKaB8z1oB0yQ4 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:KL1PR0601MB4530.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(39830400003)(376002)(136003)(346002)(366004)(38100700002)(55016003)(110136005)(122000001)(316002)(41300700001)(86362001)(83380400001)(8676002)(5660300002)(66476007)(66446008)(4326008)(66946007)(66556008)(71200400001)(76116006)(64756008)(9686003)(2906002)(6506007)(38070700005)(7696005)(53546011)(33656002)(52536014)(478600001)(186003)(26005)(8936002)(44832011); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?8J8D0Nb+MyKOVY/VN1I6BwsJbdp5VtLjVJXVxq/NMLAcXL/VI3jT/zkvvV9h?= =?us-ascii?Q?q+0upQRJTwuIXhhxwLd9PmytntdCc/Qf3e89UZVjA0QIHkHPY6LJPIAg6+JA?= =?us-ascii?Q?zYt82flccXg+1mf//Yxs5za4ENbWMLlkg5IGt777r/PTAVpZOmXryQNTh1RZ?= =?us-ascii?Q?ipPHIq4AyJcXyxbstDBIcNZ2IIgLIwtBdEZDt0x+CR7ltkieRLXE5G9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X+sq28rCVe2lXFm3IUg2Ke3E4OyZmvyTaLNu9?= =?us-ascii?Q?lJtqtVB+J4QRGOZMG3W6MNGy1DI7vYmjPzvLGKDFhJf1Iwpp6K8h/fClL0pE?= =?us-ascii?Q?NHIvFPxACJMh6VXnajsMgh8C0NzgXdW1g4nMBTXY5C7bzm0pvNMCugVxoeAr?= =?us-ascii?Q?dBK3nfpx8ev0rbnV3SulaV++J6+kAD9jHo1RsS8u2BLZvKD8fv1+7QhPdhGh?= =?us-ascii?Q?aw2OyNMT4dc0xXVz7EqmCYHQIiPEtCqM3GKzrqvXzKTPakytb9jolSPSShp1?= =?us-ascii?Q?5Plt9xFAxFvwXIkEKDq8EZD11UAGi+Oojs3DxPyzIcs7SPqY8GKDUlirFCBx?= =?us-ascii?Q?dbYSMwC40WrFqdmysa5ebLKByB3vUewzuY16IVX9SWTru3/lo9kVG36PUj3D?= =?us-ascii?Q?zjA7Ht6T15gZn4qYKP1WBPgfJ/z0rLd4wTI5tlDlh61Kifz2Ktlq6BYsnusa?= =?us-ascii?Q?EgGow9rxBVEKf7wBci0EO2iUI5KINYsb74gtf/tu?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4530.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44116cc7-9af7-4043-d690-08da7088994c X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2022 11:02:01.5690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JKw+LEGo5PmWnn7WEiVki6xJpDYbNeOYcxIKblwV7/ICDlAe15Dm9owcF42MwNUX9xjYcNcfs8GeSms0jvkDQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5714 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org I don't think the stack(software) cares if the length of a packet is less t= han 60, especially when receiving it. In the linux kernel, if the packet length does not match the IP total-lengt= h, the packet is flushed to the stack instead of GRO. The previous GRO cach= e packets are also flushed into the stack. If you trim padding in merge_two_tcp4_packets(), then both "pkt_head" and "= pkt_tail" need to decide whether to trim or not, which can be a bit tricky = to handle. -----Original Message----- From: Hu, Jiayu =20 Sent: Thursday, July 28, 2022 9:56 AM To: Jun Qiu ; dev@dpdk.org Cc: stable@dpdk.org Subject: RE: [PATCH] gro: fix gro with ethernet tail padding bytes Hi Jun, > -----Original Message----- > From: Jun Qiu > Sent: Wednesday, July 27, 2022 4:01 PM > To: dev@dpdk.org > Cc: Hu, Jiayu ; stable@dpdk.org > Subject: [PATCH] gro: fix gro with ethernet tail padding bytes >=20 > Exclude CRC fields, the minimum Ethernet packet length is 60 bytes.=20 > When the actual packet length is less than 60 bytes, padding is added to = the tail. > When GRO is performed on a packet containing a padding field, mbuf- > >pkt_len is the one that contains the padding field, which leads to=20 > >the error > of thinking of the padding field as the actual content of the packet. > We need to trim away this extra padding field during GRO processing. >=20 > Fixes: 0d2cbe59b719 ("lib/gro: support TCP/IPv4") > Cc: stable@dpdk.org >=20 > Signed-off-by: Jun Qiu > --- > lib/gro/gro_tcp4.c | 7 ++++++- > lib/gro/gro_udp4.c | 4 ++++ > 2 files changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c index > 7849a2bd1d..0110db5748 100644 > --- a/lib/gro/gro_tcp4.c > +++ b/lib/gro/gro_tcp4.c > @@ -198,7 +198,7 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, > struct rte_tcp_hdr *tcp_hdr; > uint32_t sent_seq; > int32_t tcp_dl; > - uint16_t ip_id, hdr_len, frag_off; > + uint16_t ip_id, hdr_len, frag_off, ip_tlen; > uint8_t is_atomic; >=20 > struct tcp4_flow_key key; > @@ -233,6 +233,11 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, > if (tcp_dl <=3D 0) > return -1; >=20 > + /* trim the tail padding bytes */ > + ip_tlen =3D rte_be_to_cpu_16(ipv4_hdr->total_length); > + if (pkt->pkt_len > (uint32_t)(ip_tlen + pkt->l2_len)) > + rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_tlen - pkt->l2_len); Good catch. But there is a case needed to consider: if the packet with padding doesn't merge with any other packets, its paddin= g bytes are trimmed too. If upper layer functions check the minimal packet = length before check padding bytes in the packet, this change will cause the= y treat this packet as an illegal one. How does Linux kernel GRO handle pad= ding packets? Another choice is to trim the padding bytes when the packet merges with ano= ther one. In this case, GRO will only trim padding bytes for reassembled pa= ckets. For example, you can trim padding in merge_two_tcp4_packets(). Thanks, Jiayu > + > /* > * Save IPv4 ID for the packet whose DF bit is 0. For the packet > * whose DF bit is 1, IPv4 ID is ignored. > diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c index > dd71135ada..839f9748b7 100644 > --- a/lib/gro/gro_udp4.c > +++ b/lib/gro/gro_udp4.c > @@ -231,6 +231,10 @@ gro_udp4_reassemble(struct rte_mbuf *pkt, > if (ip_dl <=3D pkt->l3_len) > return -1; >=20 > + /* trim the tail padding bytes */ > + if (pkt->pkt_len > (uint32_t)(ip_dl + pkt->l2_len)) > + rte_pktmbuf_trim(pkt, pkt->pkt_len - ip_dl - pkt->l2_len); > + > ip_dl -=3D pkt->l3_len; > ip_id =3D rte_be_to_cpu_16(ipv4_hdr->packet_id); > frag_offset =3D rte_be_to_cpu_16(ipv4_hdr->fragment_offset); > -- > 2.25.1