Commit 212ee4b5 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'rfc8335-probe'



Andreas Roeseler says:

====================
add support for RFC 8335 PROBE

The popular utility ping has several severe limitations, such as the
inability to query specific interfaces on a node and requiring
bidirectional connectivity between the probing and probed interfaces.
RFC 8335 attempts to solve these limitations by creating the new utility
PROBE which is a specialized ICMP message that makes use of the ICMP
Extension Structure outlined in RFC 4884.

This patchset adds definitions for the ICMP Extended Echo Request and
Reply (PROBE) types for both IPV4 and IPV6, adds a sysctl to enable
responses to PROBE messages, expands the list of supported ICMP messages
to accommodate PROBE types, adds ipv6_dev_find into ipv6_stubs, and adds
functionality to respond to PROBE requests.

Changes:
v1 -> v2:
 - Add AFI definitions
 - Switch to functions such as dev_get_by_name and ip_dev_find to lookup
   net devices

v2 -> v3:
Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
 - Add verification of incoming messages before looking up netdev
 - Add prefix for PROBE specific defined variables
 - Use proc_dointvec_minmax with zero and one for sysctl
 - Create struct icmp_ext_echo_iio for parsing incoming packets
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
 - Include net/addrconf.h library for ipv6_dev_find

v3 -> v4:
 - Use in_addr instead of __be32 for storing IPV4 addresses
 - Use IFNAMSIZ to statically allocate space for name in
   icmp_ext_echo_iio
Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
 - Use skb_header_pointer to verify fields in incoming message
 - Add check to ensure that extobj_hdr.length is valid
 - Check to ensure object payload is padded with ASCII NULL characters
   when probing by name, as specified by RFC 8335
 - Statically allocate buff using IFNAMSIZ
 - Add rcu blocking around ipv6_dev_find
 - Use __in_dev_get_rcu to access IPV4 addresses of identified
   net_device
 - Remove check for ICMPV6 PROBE types

v4 -> v5:
 - Statically allocate buff to size IFNAMSIZ on declaration
 - Remove goto probe in favor of single branch
 - Remove strict check for incoming PROBE request padding to nearest
   32-bit boundary
Reported-by: default avatarkernel test robot <lkp@intel.com>

v5 -> v6:
 - Add documentation for icmp_echo_enable_probe sysctl
 - Remove RCU locking around ipv6_dev_find()
 - Assign iio based on ctype
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents fdb5cc6a d329ea5b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1143,6 +1143,12 @@ icmp_echo_ignore_all - BOOLEAN

	Default: 0

icmp_echo_enable_probe - BOOLEAN
        If set to one, then the kernel will respond to RFC 8335 PROBE
        requests sent to it.

        Default: 0

icmp_echo_ignore_broadcasts - BOOLEAN
	If set non-zero, then the kernel will ignore all ICMP ECHO and
	TIMESTAMP requests sent to it via broadcast/multicast.
+2 −0
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ struct ipv6_stub {

	int (*ipv6_fragment)(struct net *net, struct sock *sk, struct sk_buff *skb,
			     int (*output)(struct net *, struct sock *, struct sk_buff *));
	struct net_device *(*ipv6_dev_find)(struct net *net, const struct in6_addr *addr,
					    struct net_device *dev);
};
extern const struct ipv6_stub *ipv6_stub __read_mostly;

+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ struct netns_ipv4 {
#endif

	u8 sysctl_icmp_echo_ignore_all;
	u8 sysctl_icmp_echo_enable_probe;
	u8 sysctl_icmp_echo_ignore_broadcasts;
	u8 sysctl_icmp_ignore_bogus_error_responses;
	u8 sysctl_icmp_errors_use_inbound_ifaddr;
+42 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@

#include <linux/types.h>
#include <asm/byteorder.h>
#include <linux/in.h>
#include <linux/if.h>
#include <linux/in6.h>

#define ICMP_ECHOREPLY		0	/* Echo Reply			*/
#define ICMP_DEST_UNREACH	3	/* Destination Unreachable	*/
@@ -66,6 +69,23 @@
#define ICMP_EXC_TTL		0	/* TTL count exceeded		*/
#define ICMP_EXC_FRAGTIME	1	/* Fragment Reass time exceeded	*/

/* Codes for EXT_ECHO (PROBE) */
#define ICMP_EXT_ECHO		42
#define ICMP_EXT_ECHOREPLY	43
#define ICMP_EXT_MAL_QUERY	1	/* Malformed Query */
#define ICMP_EXT_NO_IF		2	/* No such Interface */
#define ICMP_EXT_NO_TABLE_ENT	3	/* No such Table Entry */
#define ICMP_EXT_MULT_IFS	4	/* Multiple Interfaces Satisfy Query */

/* Constants for EXT_ECHO (PROBE) */
#define EXT_ECHOREPLY_ACTIVE	(1 << 2)/* active bit in reply message */
#define EXT_ECHOREPLY_IPV4	(1 << 1)/* ipv4 bit in reply message */
#define EXT_ECHOREPLY_IPV6	1	/* ipv6 bit in reply message */
#define EXT_ECHO_CTYPE_NAME	1
#define EXT_ECHO_CTYPE_INDEX	2
#define EXT_ECHO_CTYPE_ADDR	3
#define ICMP_AFI_IP		1	/* Address Family Identifier for ipv4 */
#define ICMP_AFI_IP6		2	/* Address Family Identifier for ipv6 */

struct icmphdr {
  __u8		type;
@@ -118,4 +138,26 @@ struct icmp_extobj_hdr {
	__u8		class_type;
};

/* RFC 8335: 2.1 Header for c-type 3 payload */
struct icmp_ext_echo_ctype3_hdr {
	__be16		afi;
	__u8		addrlen;
	__u8		reserved;
};

/* RFC 8335: 2.1 Interface Identification Object */
struct icmp_ext_echo_iio {
	struct icmp_extobj_hdr extobj_hdr;
	union {
		char name[IFNAMSIZ];
		__be32 ifindex;
		struct {
			struct icmp_ext_echo_ctype3_hdr ctype3_hdr;
			union {
				struct in_addr	ipv4_addr;
				struct in6_addr	ipv6_addr;
			} ip_addr;
		} addr;
	} ident;
};
#endif /* _UAPI_LINUX_ICMP_H */
+3 −0
Original line number Diff line number Diff line
@@ -140,6 +140,9 @@ struct icmp6hdr {
#define ICMPV6_UNK_OPTION		2
#define ICMPV6_HDR_INCOMP		3

/* Codes for EXT_ECHO (PROBE) */
#define ICMPV6_EXT_ECHO_REQUEST		160
#define ICMPV6_EXT_ECHO_REPLY		161
/*
 *	constants for (set|get)sockopt
 */
Loading