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 420324586B; Mon, 26 Aug 2024 13:23:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C23DA402A7; Mon, 26 Aug 2024 13:23:35 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2044.outbound.protection.outlook.com [40.107.20.44]) by mails.dpdk.org (Postfix) with ESMTP id 44C5440272 for ; Mon, 26 Aug 2024 13:23:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J3Ag2TfVyDlmSzZ7RhqLjPa2yXMdDRQhPcmCl3zcT+FY8gJFrBP9AL+6cRJwl4uiFp9yI/LaNpK4Pbg5RcnQRys5o5o+maQ7bz6bpuIMOR7Piu2cQzrN0xnVoE96C3KpaMMtnaKetmYJJTlE1KRTzMp9S2w4jZr29A1DUIJn5mvnC+0DWrmGRrMSLkmMGr+YRTKKwcG6XINgBTs/2r0DodZ9mVaWf2MuadR4fFqeGAHHjritync+tL3ZdbnoaVkQmfwKb0Tq+hj0wwY6quUX8CYbRMU8SpyMz+QHohqIdqxdij0zJnDbricROjId6ea4yR4hYyha2WC3fNxdd6/8dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=YmiFwiCbMA/gBqUTH4JuoY0DAAIDu1tjDvUJRBK+IkA=; b=lw+V5FpgdkOegNKrSjPrk8kEm5piWLkI/9NTwY+3oaT1y5U9mKAPk4LK+ajUsL0SwIFZTRD59v1S6VcduybHXXb9Vf6RtcgDgqpOOvtGrRLn+qQMIrsQTLNOyu0d/GSsPe1kilPuvhv4Y86NTcwfzCd1E3n9YSNI5ks4xH2RiUoHC6not0w+zLDVpe9LfZOR0/k2h6a+627PxV1b+iYcfopynBIYWS5gPg3OEtntI7bZM//33JxZgexeCqUJeMqux/MJbQRdoUqN6HbcOPtFcc0JbysabWigIcUN7jWiXR9Qz1xwqh6mHi31U11oMgqc2n883dTc0qE4I1KZmeaEsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YmiFwiCbMA/gBqUTH4JuoY0DAAIDu1tjDvUJRBK+IkA=; b=MEPIoKNdW/t8qHmz3YgTvIqYotQLfPBShXdScQubecvMkBoXJRzn8vv+tO/KZOrT/p1SLfna02COiZ2oted28hFKBDI9A7NoZH06tqpKKLiH5dPpsM1OSiS5spjX4KRJx+S3fLXBiR7YBh6FboFwB+NHJrLamZkl6LVJOG5TmOrl88P4CfNcnUDt/ioEPeC8geql3yoRb5ds/S5gT/4fNQsj2BNXS8k7iG58lwW+zgJR2sVfEv6aOlf3f7Tts20G9E4lLDXMQyEQ3DN3Zyjy+c70+kFR6ul0UEQW+yGWkyahrll0ZwLssRczHwSO7pLY1WBwR2w3JOJMwVgYbl3jHQ== Received: from DUZPR01CA0250.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::6) by AS8PR07MB7830.eurprd07.prod.outlook.com (2603:10a6:20b:38f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Mon, 26 Aug 2024 11:23:33 +0000 Received: from DB5PEPF00014B95.eurprd02.prod.outlook.com (2603:10a6:10:4b5:cafe::ae) by DUZPR01CA0250.outlook.office365.com (2603:10a6:10:4b5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24 via Frontend Transport; Mon, 26 Aug 2024 11:23:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by DB5PEPF00014B95.mail.protection.outlook.com (10.167.8.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Mon, 26 Aug 2024 11:23:33 +0000 Received: from seroius18815.sero.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 13:23:32 +0200 Received: from seroiuts03116.sero.gic.ericsson.se (seroiuts03116.sero.gic.ericsson.se [10.210.134.60]) by seroius18815.sero.gic.ericsson.se (Postfix) with ESMTP id 88B6D4020A97; Mon, 26 Aug 2024 13:23:32 +0200 (CEST) Received: by seroiuts03116.sero.gic.ericsson.se (Postfix, from userid 7401342) id 72B68603F76E; Mon, 26 Aug 2024 13:23:32 +0200 (CEST) From: To: CC: , Vignesh PS Subject: [PATCH] ip_frag: support IPv6 reassembly with extensions Date: Mon, 26 Aug 2024 13:23:28 +0200 Message-ID: <20240826112328.3028488-1-vignesh.purushotham.srinivas@ericsson.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B95:EE_|AS8PR07MB7830:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e57cd7e-af9b-472e-1623-08dcc5c1852b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fs/phbcsnVhGWtMla5SFrMu6jjQK+cy895Uq3at5a1p6FzlVtjz+6mhmp16l?= =?us-ascii?Q?eYOBWQ6yqDSrN9w8jQ9GW+bqi00+L/OjMa3cGvgeikHliterjLmRYOs05ZmW?= =?us-ascii?Q?0mOTJFTFfAeVmc7Yvt4MbTpMf1F6GJKFhlLcnqyNHmd8vIzfw+aeJYDR9/lN?= =?us-ascii?Q?vKV3Gp0KyPM2Q2Qck15Nj/FaGZlUkUPBo9tMajn4QxPpuSSZxZ9u8n+uRh+W?= =?us-ascii?Q?Dk1TaXsG8t6KD7R5uZheWKleJo+VjKtepu8vwlUcKLTE5ihcqj4BKAfsNucG?= =?us-ascii?Q?BGxk0YxOYBG+2Z9oi7tHyabFrx7SF0RSBz2cfk9+SkxsdeESWPBJ6B1014ux?= =?us-ascii?Q?nbmtDeFsIsHNah7Fo+2z9ZyQXiowBYnUp434QAHd9BQ5GYXyUD4JweraJrw2?= =?us-ascii?Q?CpCIfVrmyvnxvSoVdqIa+yyCnUZ0uP1pQhu9jmsALOY1UK3/wt5Kl1OgILnF?= =?us-ascii?Q?x+u4sBLmYMOyBlcG62EUWsYznIzhsr7AVtiItlOSjarIyLFV75+/BxTn8Ui3?= =?us-ascii?Q?Y+MKMyBWMEiJ86KPWNDJ1DeDGXoNzNITWTBOLD9KM0/La4P/tPVQdvyjwQRe?= =?us-ascii?Q?2ZNGBeqvPMPvh3SyhT9xuenzB2LnnUs4o5+GYbAcz23gOTxKrE5klyKmsrE6?= =?us-ascii?Q?7+5vvtuHmDDYONjQsBA2NM9EI+ZDm94u4GT7sX8yT5cWDmRyO8PmTALxoP1/?= =?us-ascii?Q?ZmE62FaKGH8UKcZnGEyECtOlZml5BNHxCyBozULGjcOzhekwZAIqBOFV1y9M?= =?us-ascii?Q?/aoCqAblKroyZl2gfnU7ZGUiAszrMZvdwhiYgmK/9Li3ZqFiWs5qXDafp0u5?= =?us-ascii?Q?pJEXyUDKgefSWsnyVTu4Ob1/yw68uRNvs2RsTlfq4O+H59nRqQNDo9fj2obN?= =?us-ascii?Q?iTkCoMU5Dk9GZ7O5t7fQZ0OlCeSoW1zyef8Cp3BXC7LPCs3K3wApiI1eNVpF?= =?us-ascii?Q?rzn36Ote7VHeG1XDuHXRu2di0OtAtymX9kv2BI1B8bw2T7Or6wUwr3PtmCTu?= =?us-ascii?Q?a8mr2q6APzMzZ9bYEEojoLJwFIHeYMmwO3loSVpb/bO9uF7NVECGz/7vWh7l?= =?us-ascii?Q?IHijwUtGFhffoOld/A4PLjoDCyPEiqDwOBYRb9Qps6JxT9guVC7fUbD/Odf3?= =?us-ascii?Q?rTMPsXEU5w31lvaXOyQKUNN3PhihpXCQVQoDfq+xtvShhzHiQ9hP+V79OSww?= =?us-ascii?Q?SJZrYh30ipD+CGc8r4oRfGLBvNlXyJ82olL6pOn5K6kNmwM/3qdjoYIP2GEm?= =?us-ascii?Q?+QaPxSJ0esaQAzmo4ElQcKtmTyg9rYMk+4n97iVj+sErljhJT7SZEkS+jP8B?= =?us-ascii?Q?89SvUP1+GDLqq1K5ZO/fUS4MYg357GS5c3RkX3s0tbxlCT4zEfevm57uczMS?= =?us-ascii?Q?Qb2Andjp1QN6OB9vqXshSjTZppsqT90wg5hh7GiBmEiwgctQRVnYcC9I0F+b?= =?us-ascii?Q?V0pCNtfzETWcbH2pm0sU2MO65JdHh/FH?= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 11:23:33.2539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e57cd7e-af9b-472e-1623-08dcc5c1852b X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B95.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7830 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 From: Vignesh PS Add support to ip_frag library to perform IPv6 reassembly when extension headers are present before the fragment extension in the packet. Signed-off-by: Vignesh PS --- .mailmap | 1 + lib/ip_frag/ip_frag_common.h | 2 + lib/ip_frag/ip_reassembly.h | 2 + lib/ip_frag/rte_ipv6_reassembly.c | 68 +++++++++++++++++++++++++++---- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/.mailmap b/.mailmap index 4a508bafad..69b229a5b7 100644 --- a/.mailmap +++ b/.mailmap @@ -1548,6 +1548,7 @@ Viacheslav Ovsiienko Victor Kaplansky Victor Raj Vidya Sagar Velumuri +Vignesh PS Vignesh Sridhar Vijayakumar Muthuvel Manickam Vijaya Mohan Guvva diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h index 51fc9d47fb..db2665e846 100644 --- a/lib/ip_frag/ip_frag_common.h +++ b/lib/ip_frag/ip_frag_common.h @@ -169,6 +169,8 @@ ip_frag_reset(struct ip_frag_pkt *fp, uint64_t tms) fp->total_size = UINT32_MAX; fp->frag_size = 0; fp->last_idx = IP_MIN_FRAG_NUM; + fp->exts_len = 0; + fp->next_proto = NULL; fp->frags[IP_LAST_FRAG_IDX] = zero_frag; fp->frags[IP_FIRST_FRAG_IDX] = zero_frag; } diff --git a/lib/ip_frag/ip_reassembly.h b/lib/ip_frag/ip_reassembly.h index 54afed5417..429e74f1b3 100644 --- a/lib/ip_frag/ip_reassembly.h +++ b/lib/ip_frag/ip_reassembly.h @@ -54,6 +54,8 @@ struct __rte_cache_aligned ip_frag_pkt { uint32_t total_size; /* expected reassembled size */ uint32_t frag_size; /* size of fragments received */ uint32_t last_idx; /* index of next entry to fill */ + uint32_t exts_len; /* length of extension hdrs for first fragment */ + uint8_t *next_proto; /* pointer of the next_proto field */ struct ip_frag frags[IP_MAX_FRAG_NUM]; /* fragments */ }; diff --git a/lib/ip_frag/rte_ipv6_reassembly.c b/lib/ip_frag/rte_ipv6_reassembly.c index 88863a98d1..8decf592a6 100644 --- a/lib/ip_frag/rte_ipv6_reassembly.c +++ b/lib/ip_frag/rte_ipv6_reassembly.c @@ -91,19 +91,19 @@ ipv6_frag_reassemble(struct ip_frag_pkt *fp) /* update ipv6 header for the reassembled datagram */ ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, m->l2_len); + payload_len += fp->exts_len; ip_hdr->payload_len = rte_cpu_to_be_16(payload_len); /* * remove fragmentation header. note that per RFC2460, we need to update * the last non-fragmentable header with the "next header" field to contain - * type of the first fragmentable header, but we currently don't support - * other headers, so we assume there are no other headers and thus update - * the main IPv6 header instead. + * type of the first fragmentable header. */ - move_len = m->l2_len + m->l3_len - sizeof(*frag_hdr); - frag_hdr = (struct rte_ipv6_fragment_ext *) (ip_hdr + 1); - ip_hdr->proto = frag_hdr->next_header; + frag_hdr = (struct rte_ipv6_fragment_ext *) + ((uint8_t *) (ip_hdr + 1) + fp->exts_len); + *fp->next_proto = frag_hdr->next_header; + move_len = m->l2_len + m->l3_len - sizeof(*frag_hdr); ip_frag_memmove(rte_pktmbuf_mtod_offset(m, char *, sizeof(*frag_hdr)), rte_pktmbuf_mtod(m, char*), move_len); @@ -112,6 +112,39 @@ ipv6_frag_reassemble(struct ip_frag_pkt *fp) return m; } +/* + * Function to crawl through the extension header stack. + * This function breaks as soon a the fragment header is + * found and returns the total length the traversed exts + * and the last extension before the fragment header + */ +static inline uint32_t +ip_frag_get_last_exthdr(struct rte_ipv6_hdr *ip_hdr, uint8_t **last_ext) +{ + uint32_t total_len = 0; + uint8_t num_exts = 0; + size_t ext_len = 0; + *last_ext = (uint8_t *)(ip_hdr + 1); + int next_proto = ip_hdr->proto; +#define MAX_NUM_IPV6_EXTS 8 + + while (next_proto != IPPROTO_FRAGMENT && + num_exts < MAX_NUM_IPV6_EXTS && + (next_proto = rte_ipv6_get_next_ext( + *last_ext, next_proto, &ext_len)) >= 0) { + + total_len += ext_len; + + if (next_proto == IPPROTO_FRAGMENT) + return total_len; + + *last_ext += ext_len; + num_exts++; + } + + return total_len; +} + /* * Process new mbuf with fragment of IPV6 datagram. * Incoming mbuf should have its l2_len/l3_len fields setup correctly. @@ -139,6 +172,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, { struct ip_frag_pkt *fp; struct ip_frag_key key; + uint8_t *last_ipv6_ext; + uint32_t exts_len; uint16_t ip_ofs; int32_t ip_len; int32_t trim; @@ -154,10 +189,10 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, /* * as per RFC2460, payload length contains all extension headers * as well. - * since we don't support anything but frag headers, - * this is what we remove from the payload len. + * so we remove the extension len from the payload len. */ - ip_len = rte_be_to_cpu_16(ip_hdr->payload_len) - sizeof(*frag_hdr); + exts_len = ip_frag_get_last_exthdr(ip_hdr, &last_ipv6_ext); + ip_len = rte_be_to_cpu_16(ip_hdr->payload_len) - exts_len - sizeof(*frag_hdr); trim = mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); IP_FRAG_LOG(DEBUG, "%s:%d:\n" @@ -201,6 +236,21 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, /* process the fragmented packet. */ mb = ip_frag_process(fp, dr, mb, ip_ofs, ip_len, MORE_FRAGS(frag_hdr->frag_data)); + + /* store extension stack info, only for first fragment */ + if (ip_ofs == 0) { + /* + * fp->next_proto points to either the IP's next header + * or th next header of the extension before the fragment + * extension + */ + fp->next_proto = (uint8_t *)&ip_hdr->proto; + if (exts_len > 0) { + fp->exts_len = exts_len; + fp->next_proto = last_ipv6_ext; + } + } + ip_frag_inuse(tbl, fp); IP_FRAG_LOG(DEBUG, "%s:%d:\n" -- 2.34.1