Commit e542d29c authored by Andreas Roeseler's avatar Andreas Roeseler Committed by Jakub Kicinski

icmp: standardize naming of RFC 8335 PROBE constants

The current definitions of constants for PROBE, currently defined only
in the net-next kernel branch, are inconsistent, with
some beginning with ICMP and others with simply EXT. This patch
attempts to standardize the naming conventions of the constants for
PROBE before their release into a stable Kernel, and to update the
relevant definitions in net/ipv4/icmp.c.

Similarly, the definitions for the code field (previously
ICMP_EXT_MAL_QUERY, etc) use the same prefixes as the type field. This
patch adds _CODE_ to the prefix to clarify the distinction of these
constants.
Signed-off-by: default avatarAndreas Roeseler <andreas.a.roeseler@gmail.com>
Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20210427153635.2591-1-andreas.a.roeseler@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f89271f0
...@@ -70,22 +70,22 @@ ...@@ -70,22 +70,22 @@
#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */
/* Codes for EXT_ECHO (PROBE) */ /* Codes for EXT_ECHO (PROBE) */
#define ICMP_EXT_ECHO 42 #define ICMP_EXT_ECHO 42
#define ICMP_EXT_ECHOREPLY 43 #define ICMP_EXT_ECHOREPLY 43
#define ICMP_EXT_MAL_QUERY 1 /* Malformed Query */ #define ICMP_EXT_CODE_MAL_QUERY 1 /* Malformed Query */
#define ICMP_EXT_NO_IF 2 /* No such Interface */ #define ICMP_EXT_CODE_NO_IF 2 /* No such Interface */
#define ICMP_EXT_NO_TABLE_ENT 3 /* No such Table Entry */ #define ICMP_EXT_CODE_NO_TABLE_ENT 3 /* No such Table Entry */
#define ICMP_EXT_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */ #define ICMP_EXT_CODE_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */
/* Constants for EXT_ECHO (PROBE) */ /* Constants for EXT_ECHO (PROBE) */
#define EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply message */ #define ICMP_EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply message */
#define EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply message */ #define ICMP_EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply message */
#define EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply message */ #define ICMP_EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply message */
#define EXT_ECHO_CTYPE_NAME 1 #define ICMP_EXT_ECHO_CTYPE_NAME 1
#define EXT_ECHO_CTYPE_INDEX 2 #define ICMP_EXT_ECHO_CTYPE_INDEX 2
#define EXT_ECHO_CTYPE_ADDR 3 #define ICMP_EXT_ECHO_CTYPE_ADDR 3
#define ICMP_AFI_IP 1 /* Address Family Identifier for ipv4 */ #define ICMP_AFI_IP 1 /* Address Family Identifier for ipv4 */
#define ICMP_AFI_IP6 2 /* Address Family Identifier for ipv6 */ #define ICMP_AFI_IP6 2 /* Address Family Identifier for ipv6 */
struct icmphdr { struct icmphdr {
__u8 type; __u8 type;
......
...@@ -1033,7 +1033,7 @@ static bool icmp_echo(struct sk_buff *skb) ...@@ -1033,7 +1033,7 @@ static bool icmp_echo(struct sk_buff *skb)
status = 0; status = 0;
dev = NULL; dev = NULL;
switch (iio->extobj_hdr.class_type) { switch (iio->extobj_hdr.class_type) {
case EXT_ECHO_CTYPE_NAME: case ICMP_EXT_ECHO_CTYPE_NAME:
iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(_iio), &_iio); iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(_iio), &_iio);
if (ident_len >= IFNAMSIZ) if (ident_len >= IFNAMSIZ)
goto send_mal_query; goto send_mal_query;
...@@ -1041,14 +1041,14 @@ static bool icmp_echo(struct sk_buff *skb) ...@@ -1041,14 +1041,14 @@ static bool icmp_echo(struct sk_buff *skb)
memcpy(buff, &iio->ident.name, ident_len); memcpy(buff, &iio->ident.name, ident_len);
dev = dev_get_by_name(net, buff); dev = dev_get_by_name(net, buff);
break; break;
case EXT_ECHO_CTYPE_INDEX: case ICMP_EXT_ECHO_CTYPE_INDEX:
iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(iio->extobj_hdr) + iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(iio->extobj_hdr) +
sizeof(iio->ident.ifindex), &_iio); sizeof(iio->ident.ifindex), &_iio);
if (ident_len != sizeof(iio->ident.ifindex)) if (ident_len != sizeof(iio->ident.ifindex))
goto send_mal_query; goto send_mal_query;
dev = dev_get_by_index(net, ntohl(iio->ident.ifindex)); dev = dev_get_by_index(net, ntohl(iio->ident.ifindex));
break; break;
case EXT_ECHO_CTYPE_ADDR: case ICMP_EXT_ECHO_CTYPE_ADDR:
if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) + if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) +
iio->ident.addr.ctype3_hdr.addrlen) iio->ident.addr.ctype3_hdr.addrlen)
goto send_mal_query; goto send_mal_query;
...@@ -1080,23 +1080,23 @@ static bool icmp_echo(struct sk_buff *skb) ...@@ -1080,23 +1080,23 @@ static bool icmp_echo(struct sk_buff *skb)
goto send_mal_query; goto send_mal_query;
} }
if (!dev) { if (!dev) {
icmp_param.data.icmph.code = ICMP_EXT_NO_IF; icmp_param.data.icmph.code = ICMP_EXT_CODE_NO_IF;
goto send_reply; goto send_reply;
} }
/* Fill bits in reply message */ /* Fill bits in reply message */
if (dev->flags & IFF_UP) if (dev->flags & IFF_UP)
status |= EXT_ECHOREPLY_ACTIVE; status |= ICMP_EXT_ECHOREPLY_ACTIVE;
if (__in_dev_get_rcu(dev) && __in_dev_get_rcu(dev)->ifa_list) if (__in_dev_get_rcu(dev) && __in_dev_get_rcu(dev)->ifa_list)
status |= EXT_ECHOREPLY_IPV4; status |= ICMP_EXT_ECHOREPLY_IPV4;
if (!list_empty(&rcu_dereference(dev->ip6_ptr)->addr_list)) if (!list_empty(&rcu_dereference(dev->ip6_ptr)->addr_list))
status |= EXT_ECHOREPLY_IPV6; status |= ICMP_EXT_ECHOREPLY_IPV6;
dev_put(dev); dev_put(dev);
icmp_param.data.icmph.un.echo.sequence |= htons(status); icmp_param.data.icmph.un.echo.sequence |= htons(status);
send_reply: send_reply:
icmp_reply(&icmp_param, skb); icmp_reply(&icmp_param, skb);
return true; return true;
send_mal_query: send_mal_query:
icmp_param.data.icmph.code = ICMP_EXT_MAL_QUERY; icmp_param.data.icmph.code = ICMP_EXT_CODE_MAL_QUERY;
goto send_reply; goto send_reply;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment