Skip to content

Commit

Permalink
net: add more ICMP types and codes
Browse files Browse the repository at this point in the history
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>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
  • Loading branch information
rjarry authored and tmonjalo committed Oct 18, 2024
1 parent 51a639c commit 87bde5a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
10 changes: 5 additions & 5 deletions app/test-pmd/icmpecho.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions doc/guides/rel_notes/release_24_11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ New Features

* Added mempool driver support for CN20K SoC.

* **Added more ICMP message types and codes.**

New ICMP message types and codes from RFC 792 were added in ``rte_icmp.h``.

* **Added link speed lanes API.**

Added functions to query or force the link lanes configuration.
Expand Down Expand Up @@ -278,6 +282,10 @@ API Changes
releases: it handles key=value and only-key cases.
* Both ``rte_kvargs_process`` and ``rte_kvargs_process_opt`` reject a NULL ``kvlist`` parameter.

* net: The ICMP message types ``RTE_IP_ICMP_ECHO_REPLY`` and ``RTE_IP_ICMP_ECHO_REQUEST``
are marked as deprecated, and are replaced
by ``RTE_ICMP_TYPE_ECHO_REPLY`` and ``RTE_ICMP_TYPE_ECHO_REQUEST``.

* drivers/net/ena: Removed ``enable_llq``, ``normal_llq_hdr`` and ``large_llq_hdr`` devargs
and replaced it with a new shared devarg ``llq_policy`` that keeps the same logic.

Expand Down
33 changes: 31 additions & 2 deletions lib/net/rte_icmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 87bde5a

Please sign in to comment.