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 2E4C745B61; Fri, 18 Oct 2024 00:42:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E71740279; Fri, 18 Oct 2024 00:42:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 606FC40268 for ; Fri, 18 Oct 2024 00:42:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729204933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t/JHOYve0bfOx7+7GigD8GVmDxyQpleoQxsfdjr5QPE=; b=CbBE2v4Ludq3IUuKkGM5qARL1izVkHgAuf9T1Sufy/eTampkD1KodHOyu4qKGzvnAZn/m8 Yj4pSgYDlWHEqlBzM+spoqXmBWx6un8TBxenkj307Ce6zJcO4wmN4SEGNh47vX2z15l5uv TbZYAq+/A0BVTZKxxQna+vmrdZO9i00= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-nx62Q9k6PfuzR0a805U4LQ-1; Thu, 17 Oct 2024 18:42:10 -0400 X-MC-Unique: nx62Q9k6PfuzR0a805U4LQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DBF8C19560BE; Thu, 17 Oct 2024 22:42:08 +0000 (UTC) Received: from ringo.home (unknown [10.39.208.8]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A827A1956086; Thu, 17 Oct 2024 22:42:06 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Aman Singh Cc: Stephen Hemminger , Ferruh Yigit Subject: [PATCH dpdk v2] net: add more icmp types and code Date: Fri, 18 Oct 2024 00:41:53 +0200 Message-ID: <20241017224152.36412-2-rjarry@redhat.com> In-Reply-To: <20241017083322.2166467-1-rjarry@redhat.com> References: <20241017083322.2166467-1-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from RTE_IP_ICMP_ to RTE_ICMP_ to allow differentiation between types and codes. Do not include deprecated message types as described in RFC 6918. Link: https://www.rfc-editor.org/rfc/rfc792 Link: https://www.rfc-editor.org/rfc/rfc6918 Signed-off-by: Robin Jarry Acked-by: Stephen Hemminger Acked-by: Ferruh Yigit --- Notes: v2: added release note app/test-pmd/icmpecho.c | 10 ++++---- doc/guides/rel_notes/release_24_11.rst | 6 +++++ lib/net/rte_icmp.h | 33 ++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 68524484e305..4ef23ae67ac4 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -416,7 +416,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) icmp_h = (struct rte_icmp_hdr *) ((char *)ip_h + sizeof(struct rte_ipv4_hdr)); if (! ((ip_h->next_proto_id == IPPROTO_ICMP) && - (icmp_h->icmp_type == RTE_IP_ICMP_ECHO_REQUEST) && + (icmp_h->icmp_type == RTE_ICMP_TYPE_ECHO_REQUEST) && (icmp_h->icmp_code == 0))) { rte_pktmbuf_free(pkt); continue; @@ -440,7 +440,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) * - switch the request IP source and destination * addresses in the reply IP header, * - keep the IP header checksum unchanged. - * - set RTE_IP_ICMP_ECHO_REPLY in ICMP header. + * - set RTE_ICMP_TYPE_ECHO_REPLY in ICMP header. * ICMP checksum is computed by assuming it is valid in the * echo request and not verified. */ @@ -463,10 +463,10 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) ip_h->src_addr = ip_h->dst_addr; ip_h->dst_addr = ip_addr; } - icmp_h->icmp_type = RTE_IP_ICMP_ECHO_REPLY; + icmp_h->icmp_type = RTE_ICMP_TYPE_ECHO_REPLY; cksum = ~icmp_h->icmp_cksum & 0xffff; - cksum += ~RTE_BE16(RTE_IP_ICMP_ECHO_REQUEST << 8) & 0xffff; - cksum += RTE_BE16(RTE_IP_ICMP_ECHO_REPLY << 8); + cksum += ~RTE_BE16(RTE_ICMP_TYPE_ECHO_REQUEST << 8) & 0xffff; + cksum += RTE_BE16(RTE_ICMP_TYPE_ECHO_REPLY << 8); cksum = (cksum & 0xffff) + (cksum >> 16); cksum = (cksum & 0xffff) + (cksum >> 16); icmp_h->icmp_cksum = ~cksum; diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index d2301461ce35..0e9c81b32b20 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -238,6 +238,12 @@ New Features Added ability for node to advertise and update multiple xstat counters, that can be retrieved using ``rte_graph_cluster_stats_get``. +* **Added new ICMP message types and codes.** + + New ICMP message types and codes from RFC 792 are available in ``rte_icmp.h``. + Message types now use the ``RTE_ICMP_TYPE_`` prefix. + Message codes use the ``RTE_ICMP_CODE_`` prefix. + Removed Items ------------- diff --git a/lib/net/rte_icmp.h b/lib/net/rte_icmp.h index 7a33280aa1e4..e69d68ab6e22 100644 --- a/lib/net/rte_icmp.h +++ b/lib/net/rte_icmp.h @@ -50,8 +50,37 @@ struct rte_icmp_hdr { } __rte_packed; /* ICMP packet types */ -#define RTE_IP_ICMP_ECHO_REPLY 0 -#define RTE_IP_ICMP_ECHO_REQUEST 8 +#define RTE_ICMP_TYPE_ECHO_REPLY 0 +#define RTE_IP_ICMP_ECHO_REPLY \ + (RTE_DEPRECATED(RTE_IP_ICMP_ECHO_REPLY) RTE_ICMP_TYPE_ECHO_REPLY) +#define RTE_ICMP_TYPE_DEST_UNREACHABLE 3 +#define RTE_ICMP_TYPE_REDIRECT 5 +#define RTE_ICMP_TYPE_ECHO_REQUEST 8 +#define RTE_IP_ICMP_ECHO_REQUEST \ + (RTE_DEPRECATED(RTE_IP_ICMP_ECHO_REQUEST) RTE_ICMP_TYPE_ECHO_REQUEST) +#define RTE_ICMP_TYPE_TTL_EXCEEDED 11 +#define RTE_ICMP_TYPE_PARAM_PROBLEM 12 +#define RTE_ICMP_TYPE_TIMESTAMP_REQUEST 13 +#define RTE_ICMP_TYPE_TIMESTAMP_REPLY 14 + +/* Destination Unreachable codes */ +#define RTE_ICMP_CODE_UNREACH_NET 0 +#define RTE_ICMP_CODE_UNREACH_HOST 1 +#define RTE_ICMP_CODE_UNREACH_PROTO 2 +#define RTE_ICMP_CODE_UNREACH_PORT 3 +#define RTE_ICMP_CODE_UNREACH_FRAG 4 +#define RTE_ICMP_CODE_UNREACH_SRC 5 + +/* Time Exceeded codes */ +#define RTE_ICMP_CODE_TTL_EXCEEDED 0 +#define RTE_ICMP_CODE_TTL_FRAG 1 + +/* Redirect codes */ +#define RTE_ICMP_CODE_REDIRECT_NET 0 +#define RTE_ICMP_CODE_REDIRECT_HOST 1 +#define RTE_ICMP_CODE_REDIRECT_TOS_NET 2 +#define RTE_ICMP_CODE_REDIRECT_TOS_HOST 3 + #define RTE_ICMP6_ECHO_REQUEST 128 #define RTE_ICMP6_ECHO_REPLY 129 -- 2.47.0