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 56DED45B04; Thu, 10 Oct 2024 17:26:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 026D24066D; Thu, 10 Oct 2024 17:26:13 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 97B2D402F1 for ; Thu, 10 Oct 2024 17:26:10 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XPYVh3ddGz6HJxs; Thu, 10 Oct 2024 23:25:48 +0800 (CST) Received: from frapeml100007.china.huawei.com (unknown [7.182.85.133]) by mail.maildlp.com (Postfix) with ESMTPS id 6C1E7140A36; Thu, 10 Oct 2024 23:26:09 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml100007.china.huawei.com (7.182.85.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 10 Oct 2024 17:26:09 +0200 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.039; Thu, 10 Oct 2024 17:26:09 +0200 From: Konstantin Ananyev To: Robin Jarry , "dev@dpdk.org" Subject: RE: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version Thread-Topic: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version Thread-Index: AQHbE9q7pMuHvQWqoEWwzB3VHXp1GrKAKPaA Date: Thu, 10 Oct 2024 15:26:09 +0000 Message-ID: <2aee9a6293664bc3a82983ac16ad0af9@huawei.com> References: <20240821162516.610624-17-rjarry@redhat.com> <20241001081728.301272-1-rjarry@redhat.com> <20241001081728.301272-17-rjarry@redhat.com> In-Reply-To: <20241001081728.301272-17-rjarry@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.170.131] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 > This is a slow path version to verify the version field in IPv6 headers. >=20 > Signed-off-by: Robin Jarry > --- >=20 > Notes: > v2: new patch >=20 > app/test/test_net_ipv6.c | 16 ++++++++++++++++ > lib/net/rte_ip6.h | 17 +++++++++++++++++ > 2 files changed, 33 insertions(+) >=20 > diff --git a/app/test/test_net_ipv6.c b/app/test/test_net_ipv6.c > index b087b5c60d73..79a43a2b5491 100644 > --- a/app/test/test_net_ipv6.c > +++ b/app/test/test_net_ipv6.c > @@ -11,6 +11,21 @@ static const struct rte_ipv6_addr bcast_addr =3D { > }; > static const struct rte_ipv6_addr zero_addr =3D { 0 }; >=20 > +static int > +test_ipv6_check_version(void) > +{ > + struct rte_ipv6_hdr h; > + > + h.vtc_flow =3D 0; > + TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, ""); > + h.vtc_flow =3D RTE_BE32(0x7f00ba44); > + TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, ""); > + h.vtc_flow =3D RTE_BE32(0x6badcaca); > + TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, ""); > + > + return 0; > +} > + > static int > test_ipv6_addr_mask(void) > { > @@ -191,6 +206,7 @@ test_ether_mcast_from_ipv6(void) > static int > test_net_ipv6(void) > { > + TEST_ASSERT_SUCCESS(test_ipv6_check_version(), ""); > TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), ""); > TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), ""); > TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), ""); > diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h > index c552fa54c095..de3ddc0348c5 100644 > --- a/lib/net/rte_ip6.h > +++ b/lib/net/rte_ip6.h > @@ -323,6 +323,23 @@ struct rte_ipv6_hdr { > struct rte_ipv6_addr dst_addr; /**< IP address of destination host(s). = */ > } __rte_packed; >=20 > +#define RTE_IPV6_VTC_FLOW_VERSION RTE_BE32(0x60000000) > +#define RTE_IPV6_VTC_FLOW_VERSION_MASK RTE_BE32(0xf0000000) > + > +/** > + * Check that the IPv6 header version field is valid according to RFC 82= 00 section 3. > + * > + * @return > + * 0 if the version field is valid. -EINVAL otherwise. Probably 0/1 as return values will be nicer. =20 > + */ If it is a new one, then it probably needs to be rte_experimental. > +static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip) > +{ > + rte_be32_t v =3D ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK; > + if (v !=3D RTE_IPV6_VTC_FLOW_VERSION) > + return -EINVAL; > + return 0; > +} > + > /* IPv6 routing extension type definition. */ > #define RTE_IPV6_SRCRT_TYPE_4 4 >=20 > -- > 2.46.1 >=20