From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Aman Singh <aman.deep.singh@intel.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Ferruh Yigit <ferruh.yigit@amd.com>
Subject: [PATCH dpdk v2] net: add more icmp types and code
Date: Fri, 18 Oct 2024 00:41:53 +0200 [thread overview]
Message-ID: <20241017224152.36412-2-rjarry@redhat.com> (raw)
In-Reply-To: <20241017083322.2166467-1-rjarry@redhat.com>
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 <rjarry@redhat.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
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
next prev parent reply other threads:[~2024-10-17 22:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 8:33 [PATCH dpdk] " Robin Jarry
2024-10-17 16:02 ` Stephen Hemminger
2024-10-17 22:22 ` Ferruh Yigit
2024-10-17 22:33 ` Robin Jarry
2024-10-17 22:48 ` Ferruh Yigit
2024-10-17 22:41 ` Robin Jarry [this message]
2024-10-18 0:39 ` [PATCH dpdk v2] " Morten Brørup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241017224152.36412-2-rjarry@redhat.com \
--to=rjarry@redhat.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).