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 E5480A00C4; Wed, 27 Jul 2022 10:01:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE5EF40141; Wed, 27 Jul 2022 10:01:13 +0200 (CEST) Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2072.outbound.protection.outlook.com [40.107.255.72]) by mails.dpdk.org (Postfix) with ESMTP id B9F9E400D7; Wed, 27 Jul 2022 10:01:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ak/fsolQtpwjlnIory2RYIVn5k/wjmnYWw0idfZ5NoCgABv54b3NZXol/n19/81aSC4WuEsjYq5mClbz3jYtS7y2v1c96wHTrxW/frDQse0nqw+xwpi6v4QJLze3xFoAvPRjf32TuPcxgjV9WMEIX4a7AQlNASnh64KY70S9V4phShKIawDCJeiAu14uQ0icH6XE4ff+q/A6NuDY0wLZCn5NGt0lzYRDRhL04F/4qKhTE1NmzhQolSfsIaizAPpSDneBua4EDSm79Oaw09YO7WqRMA9I3arvRiIssmYhDbdAUYM4mUM+GkOmPGw6vacYY6E2tKqf9RzHlPJdQioDWg== 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=0fMfQ/w4YuXAJrqjvn0Q8WlTX50BILfGSLfy/CakftI=; b=j7qsmmt5fYlq8vG6vESnScDu30ZvvvWmLS9zlFZLMzQ6mMRWJXl5vvO3s392JlduAHvvJ3AjHAeM5DC1XWH8ISe769H8iJ2Q3VolvBCRGUH0B8sIh19ZTzTEQXygGbQRHx/Id776aqLYZ6qCJI7c2JyFUZ8DR1uCkLopRobSBDNT2KoaNTwSZG65+fr0VFlV0SYEyimCbSrP3CE4wZyUVyZHrJRURuVa+8UWzFJP5c4QwIkTp8v/LZvAhE+SySCdfjknw58T8CdiNEHLVxXyMUkkqqFMPUy+bd3kNVZH1IPZWoJX7h0lwp4ultc4M13nXbQ3u7X9XQ+Cf3e0KSnJpw== 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=0fMfQ/w4YuXAJrqjvn0Q8WlTX50BILfGSLfy/CakftI=; b=MFVtN+uS6+NNGOdeS3qICOHVUFNEJkrwU5rRSisFT3286IyPtkDA7o5n27lnen04uQNT+ebS4pfWhmHhUegMK0BEg9sJEkskscYsQm5yputyNHHnW6DX9LC+uZGTlkjO+Z+E2Ws2cgSR5KuELcfUJiGIbuEEy2LaYHwT+p6iFk4tP6xj6t63PxbFwRdT9e7YlKJduU7Q+IYrqdP36H/Hpac2uevPrgNjn78xzbpO73raTaFi6H2283DYzFuqW1jv7jZ1kGuTNcH0iKrv1P3H16A6F29XvvreWmeyDMJPFRKMrvZAucQBEVLfp5aMuvcWvT947hVDHdbbS6LTTf7iHw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; Received: from KL1PR0601MB4530.apcprd06.prod.outlook.com (2603:1096:820:64::10) by SEZPR06MB5453.apcprd06.prod.outlook.com (2603:1096:101:cd::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Wed, 27 Jul 2022 08:01:08 +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.5458.025; Wed, 27 Jul 2022 08:01:08 +0000 From: Jun Qiu To: dev@dpdk.org Cc: jiayu.hu@intel.com, stable@dpdk.org Subject: [PATCH] gro: fix gro with ethernet tail padding bytes Date: Wed, 27 Jul 2022 08:00:36 +0000 Message-Id: <20220727080036.27263-1-jun.qiu@jaguarmicro.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To KL1PR0601MB4530.apcprd06.prod.outlook.com (2603:1096:820:64::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fd4cde5-0cee-4db7-e6d1-08da6fa629a2 X-MS-TrafficTypeDiagnostic: SEZPR06MB5453:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xHS4IQ5Q8ZgRNlUZJqEnDcrDYQeTpGCPRS2jrBTlFDd5xWDvVY+7ocQCLySenczaV4MJB6xazK1VbfZFqZZ71ON3WtNjuMMYzMOT3omuEMLKqzjQYoeVunvcWCG5vGN+v6JaVt4faMaT7ubhx1MZXF4NwCCTrg1Wo0CspCRhBumrWFEq1ozaIzl6edX956hChm+sCc0O7PRVwJwQsfnwWDHvt16t4RigAVijy/ND4lLY7+8N+LEMjhRuaFtAZzDU7OcnQY1xK7o1ZYFTsqsaP+ZRgH8K+w7koxUJLI7SFWQQXF2vro4LCgtrHXqYUVlI8SgiCx64fKF1gLMFHfysZRvoWhgUP6tSb/O8boM8sTOr60b9WAgAALj/n8eEs4x0BcXsgAMwM706Su1fRyUeHODNsr+pXatdpscuVYdTg0kuqs06wA+Xhyc+xCCXGDufMaD1dnLsJL+r+mMN3P6nB7qlXSCqBX2dHXl7DAM2YkCon8+4ZDRKt0QUJTEPfdS+V/rGAAPUpNK12zuMUS4ifFORMPxabr/kiNIMSDMbpEbYzaAH/sdDz6QQD80CPSRHyCgx55YbSBzn9VHePfu/C1ACPRZ0ieEeHYptY8cVcsZWfuG1oclptYa8dD5b7he1gYRMnSKZ+In6sAbUTJLdOuOioluCiE48TtsKWI7PiBY+gt6w72/9LEgMvYvszyvcdU4ONuBWC8dZI8aVHY8ojLgOnGHqxNL9VBkUv6B1r2c= 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)(346002)(39830400003)(376002)(366004)(396003)(136003)(4326008)(41300700001)(2906002)(86362001)(38350700002)(26005)(6666004)(38100700002)(66946007)(66476007)(52116002)(66556008)(6506007)(8676002)(83380400001)(478600001)(36756003)(2616005)(1076003)(5660300002)(8936002)(6916009)(44832011)(186003)(6512007)(6486002)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sa9UkQXOU4CGIMAMtZjRSTHdXGC456Kk+lBwF3cmaoKqm5veYfFt9+RQ+uxSSaI+rZsVAlUnHjAUNvKi15bzDFdQr4oXRteExJE5jCpQ4JRlJ+uIE9Nxk/wqXHu4BjcigSznqbYy35vHSjQPrNQlzgjiVYvmY76IOw0++RwuJRyYXUrxtCBX/51buHR1nmrNZTWQzbdXmMZayzjWMiKfx98BIC7Vs8iriBaTjGK5ReUzMPzWomHWYEVFaxQJq9zYLfazgrJ9kcOyq+Hxv6FvGyJWIXLL2lL/PRgMcVye+habU5Q2tmnSWNJu2ayQ58HJLSyEHDf/7JQ6Quiuwxg60x/6qiqsLZs0n5minmDJwSIg0X1FEyKmAvDJiNogOz76y6pOIJyGfdU9TnSsoRJIcsr2gSPWX79PinPZp22tBa0= X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fd4cde5-0cee-4db7-e6d1-08da6fa629a2 X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4530.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2022 08:01:08.1704 (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: mn9xP7wHniKYcw8075aK9oO+oHvzEEIU+3s0pUR3kraH5NhFQz36eV0oKILDECxzB1jORzaJxokOQm7qUiO+Zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5453 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 Exclude CRC fields, the minimum Ethernet packet length is 60 bytes. 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 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. Fixes: 0d2cbe59b719 ("lib/gro: support TCP/IPv4") Cc: stable@dpdk.org Signed-off-by: Jun Qiu --- lib/gro/gro_tcp4.c | 7 ++++++- lib/gro/gro_udp4.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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; struct tcp4_flow_key key; @@ -233,6 +233,11 @@ gro_tcp4_reassemble(struct rte_mbuf *pkt, if (tcp_dl <= 0) return -1; + /* trim the tail padding bytes */ + ip_tlen = 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); + /* * 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 <= pkt->l3_len) return -1; + /* 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 -= pkt->l3_len; ip_id = rte_be_to_cpu_16(ipv4_hdr->packet_id); frag_offset = rte_be_to_cpu_16(ipv4_hdr->fragment_offset); -- 2.25.1