net: add more icmp types and code
PATCH 1/1 net: add more icmp types and code
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.
--- app/test-pmd/icmpecho.c | 10 +++++----- lib/net/rte_icmp.h | 31 +++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-)
app/test-pmd/icmpecho.c +5 -5
@@ -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;
lib/net/rte_icmp.h +29 -2
@@ -50,8 +50,35 @@ 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
Signature · 1 line
2.47.0
Quoted 5 lines · On Thu, 17 Oct 2024 10:33:22 +0200 Robin Jarry <[email protected]> wrote:
Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation between types and codes.Signed-off-by Robin Jarry <[email protected]>
Should add a release note for this
Ferruh Yigit
Acked-byQuoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Thu, 17 Oct 2024 10:33:22 +0200 Robin Jarry <[email protected]> wrote:
Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation between types and codes.
Quoted 6 lines
Quoted 1 line
Signed-off-by Robin Jarry <[email protected]>Should add a release note for this
+1 to get this in 24.11
@Thomas, probably it is better to get this for -rc1 and as next-net already pulled can this directly go to main?
Btw, is following also required? Just because it is documented in RFC:
15 Information Request
16 Information Reply
Ack stands if above added or not.
Ferruh Yigit, Oct 18, 2024 at 00:22:
Quoted 15 lines · Stephen Hemminger
Quoted 7 lines
Quoted 4 lines · On Thu, 17 Oct 2024 10:33:22 +0200 Robin Jarry <[email protected]> wrote:
Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation between types and codes.Quoted 6 lines
Quoted 1 line
Signed-off-by Robin Jarry <[email protected]>Should add a release note for this
Quoted 7 lines
+1 to get this in 24.11
Acked-by Ferruh Yigit <[email protected]>@Thomas, probably it is better to get this for -rc1 and as next-net already pulled can this directly go to main?
I will probably send a v2 with a release note.
Quoted 4 lines
Btw, is following also required? Just because it is documented in RFC:
15 Information Request
16 Information Reply
It seems some of the original codes have been deprecated:
https://www.rfc-editor.org/rfc/rfc6918#section-2.2
Quoted 1 line
Ack stands if above added or not.
Quoted 28 lines · Robin Jarry
Ferruh Yigit, Oct 18, 2024 at 00:22:
Quoted 16 lines · Stephen Hemminger
Quoted 8 lines
Quoted 5 lines · On Thu, 17 Oct 2024 10:33:22 +0200 Robin Jarry <[email protected]> wrote:
Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation
between types and codes.Quoted 6 lines
Quoted 1 line
Signed-off-by Robin Jarry <[email protected]>Should add a release note for this
Quoted 7 lines
+1 to get this in 24.11
Acked-by Ferruh Yigit <[email protected]>@Thomas, probably it is better to get this for -rc1 and as next-net already pulled can this directly go to main?
I will probably send a v2 with a release note.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Btw, is following also required? Just because it is documented in RFC:
15 Information Request
16 Information ReplyIt seems some of the original codes have been deprecated:
Ack
PATCH v2 1/1 net: add more icmp types and code
In reply to Robin JarryAdd 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.
---
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(-)
app/test-pmd/icmpecho.c +5 -5
@@ -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;
doc/guides/rel_notes/release_24_11.rst +6 -0
@@ -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 -------------
lib/net/rte_icmp.h +31 -2
@@ -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
Signature · 1 line
2.47.0
Quoted 8 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Friday, 18 October 2024 00.42Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation
between types and codes.
Quoted 8 lines
Do not include deprecated message types as described in RFC 6918.
Signed-off-by Robin Jarry <[email protected]>Acked-by Ferruh Yigit <[email protected]>---
18/10/2024 02:39, Morten Brørup:
Quoted 10 lines
Quoted 10 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Friday, 18 October 2024 00.42Add more ICMP message types and codes based on RFC 792. Change the namespace prefix from
RTE_IP_ICMP_toRTE_ICMP_to allow differentiation
between types and codes.Do not include deprecated message types as described in RFC 6918.
Quoted 7 lines
Quoted 5 lines
Acked-by Morten Brørup <[email protected]>
Highlighted the API changes in the release notes,
and applied, thanks.