Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _NDISC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _NDISC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <net/ipv6_stubs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	ICMP codes for neighbour discovery messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define NDISC_ROUTER_SOLICITATION	133
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define NDISC_ROUTER_ADVERTISEMENT	134
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define NDISC_NEIGHBOUR_SOLICITATION	135
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define NDISC_NEIGHBOUR_ADVERTISEMENT	136
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define NDISC_REDIRECT			137
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Router type: cross-layer information from link-layer to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * IPv6 layer reported by certain link types (e.g., RFC4214).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define NDISC_NODETYPE_UNSPEC		0	/* unspecified (default) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define NDISC_NODETYPE_HOST		1	/* host or unauthorized router */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define NDISC_NODETYPE_NODEFAULT	2	/* non-default router */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define NDISC_NODETYPE_DEFAULT		3	/* default router */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *	ndisc options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	__ND_OPT_PREFIX_INFO_END = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	ND_OPT_SOURCE_LL_ADDR = 1,	/* RFC2461 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	ND_OPT_TARGET_LL_ADDR = 2,	/* RFC2461 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	ND_OPT_PREFIX_INFO = 3,		/* RFC2461 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	ND_OPT_REDIRECT_HDR = 4,	/* RFC2461 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	ND_OPT_MTU = 5,			/* RFC2461 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	ND_OPT_NONCE = 14,              /* RFC7527 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	__ND_OPT_ARRAY_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	ND_OPT_ROUTE_INFO = 24,		/* RFC4191 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	ND_OPT_RDNSS = 25,		/* RFC5006 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	ND_OPT_DNSSL = 31,		/* RFC6106 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	ND_OPT_6CO = 34,		/* RFC6775 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	ND_OPT_CAPTIVE_PORTAL = 37,	/* RFC7710 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	ND_OPT_PREF64 = 38,		/* RFC8781 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	__ND_OPT_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define MAX_RTR_SOLICITATION_DELAY	HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define ND_REACHABLE_TIME		(30*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define ND_RETRANS_TIMER		HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #include <linux/icmpv6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #include <linux/in6.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #include <linux/if_arp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #include <linux/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #include <net/neighbour.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /* Set to 3 to get tracing... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define ND_DEBUG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define ND_PRINTK(val, level, fmt, ...)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (val <= ND_DEBUG)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		net_##level##_ratelimited(fmt, ##__VA_ARGS__);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) struct ctl_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct inet6_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) struct net_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) struct net_proto_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) struct sk_buff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) struct prefix_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) extern struct neigh_table nd_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) struct nd_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)         struct icmp6hdr	icmph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)         struct in6_addr	target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	__u8		opt[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) struct rs_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	struct icmp6hdr	icmph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	__u8		opt[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) struct ra_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)         struct icmp6hdr		icmph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	__be32			reachable_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__be32			retrans_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) struct rd_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct icmp6hdr icmph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct in6_addr	target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct in6_addr	dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	__u8		opt[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct nd_opt_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	__u8		nd_opt_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	__u8		nd_opt_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* ND options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct ndisc_options {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #ifdef CONFIG_IPV6_ROUTE_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct nd_opt_hdr *nd_opts_ri;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct nd_opt_hdr *nd_opts_ri_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct nd_opt_hdr *nd_useropts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct nd_opt_hdr *nd_useropts_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct nd_opt_hdr *nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define nd_opts_src_lladdr		nd_opt_array[ND_OPT_SOURCE_LL_ADDR]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define nd_opts_tgt_lladdr		nd_opt_array[ND_OPT_TARGET_LL_ADDR]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define nd_opts_pi			nd_opt_array[ND_OPT_PREFIX_INFO]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define nd_opts_pi_end			nd_opt_array[__ND_OPT_PREFIX_INFO_END]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define nd_opts_rh			nd_opt_array[ND_OPT_REDIRECT_HDR]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define nd_opts_mtu			nd_opt_array[ND_OPT_MTU]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define nd_opts_nonce			nd_opt_array[ND_OPT_NONCE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define nd_802154_opts_src_lladdr	nd_802154_opt_array[ND_OPT_SOURCE_LL_ADDR]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define nd_802154_opts_tgt_lladdr	nd_802154_opt_array[ND_OPT_TARGET_LL_ADDR]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 					  u8 *opt, int opt_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 					  struct ndisc_options *ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			      int data_len, int pad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define NDISC_OPS_REDIRECT_DATA_SPACE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  * This structure defines the hooks for IPv6 neighbour discovery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  * The following hooks can be defined; unless noted otherwise, they are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * optional and can be filled with a null pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * int (*is_useropt)(u8 nd_opt_type):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  *     This function is called when IPv6 decide RA userspace options. if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *     this function returns 1 then the option given by nd_opt_type will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *     be handled as userspace option additional to the IPv6 options.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * int (*parse_options)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  *			struct nd_opt_hdr *nd_opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  *			struct ndisc_options *ndopts):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *     This function is called while parsing ndisc ops and put each position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  *     as pointer into ndopts. If this function return unequal 0, then this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *     function took care about the ndisc option, if 0 then the IPv6 ndisc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  *     option parser will take care about that option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * void (*update)(const struct net_device *dev, struct neighbour *n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  *		  u32 flags, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  *		  const struct ndisc_options *ndopts):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  *     This function is called when IPv6 ndisc updates the neighbour cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  *     entry. Additional options which can be updated may be previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  *     parsed by parse_opts callback and accessible over ndopts parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * int (*opt_addr_space)(const struct net_device *dev, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *			 struct neighbour *neigh, u8 *ha_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  *			 u8 **ha):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *     This function is called when the necessary option space will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  *     calculated before allocating a skb. The parameters neigh, ha_buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *     abd ha are available on NDISC_REDIRECT messages only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * void (*fill_addr_option)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *			    struct sk_buff *skb, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *			    const u8 *ha):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *     This function is called when the skb will finally fill the option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *     fields inside skb. NOTE: this callback should fill the option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *     fields to the skb which are previously indicated by opt_space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *     parameter. That means the decision to add such option should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *     not lost between these two callbacks, e.g. protected by interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *     up state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * void (*prefix_rcv_add_addr)(struct net *net, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *			       const struct prefix_info *pinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *			       struct inet6_dev *in6_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *			       struct in6_addr *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  *			       int addr_type, u32 addr_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  *			       bool sllao, bool tokenized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  *			       __u32 valid_lft, u32 prefered_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *			       bool dev_addr_generated):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  *     This function is called when a RA messages is received with valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  *     PIO option fields and an IPv6 address will be added to the interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *     for autoconfiguration. The parameter dev_addr_generated reports about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  *     if the address was based on dev->dev_addr or not. This can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  *     to add a second address if link-layer operates with two link layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  *     addresses. E.g. 802.15.4 6LoWPAN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct ndisc_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	int	(*is_useropt)(u8 nd_opt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	int	(*parse_options)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				 struct nd_opt_hdr *nd_opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				 struct ndisc_options *ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	void	(*update)(const struct net_device *dev, struct neighbour *n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			  u32 flags, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			  const struct ndisc_options *ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	int	(*opt_addr_space)(const struct net_device *dev, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				  struct neighbour *neigh, u8 *ha_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 				  u8 **ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	void	(*fill_addr_option)(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 				    struct sk_buff *skb, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 				    const u8 *ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	void	(*prefix_rcv_add_addr)(struct net *net, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 				       const struct prefix_info *pinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 				       struct inet6_dev *in6_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 				       struct in6_addr *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 				       int addr_type, u32 addr_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 				       bool sllao, bool tokenized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				       __u32 valid_lft, u32 prefered_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				       bool dev_addr_generated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static inline int ndisc_ops_is_useropt(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				       u8 nd_opt_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if (dev->ndisc_ops && dev->ndisc_ops->is_useropt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		return dev->ndisc_ops->is_useropt(nd_opt_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static inline int ndisc_ops_parse_options(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 					  struct nd_opt_hdr *nd_opt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					  struct ndisc_options *ndopts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (dev->ndisc_ops && dev->ndisc_ops->parse_options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		return dev->ndisc_ops->parse_options(dev, nd_opt, ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static inline void ndisc_ops_update(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 					  struct neighbour *n, u32 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 					  u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 					  const struct ndisc_options *ndopts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if (dev->ndisc_ops && dev->ndisc_ops->update)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		dev->ndisc_ops->update(dev, n, flags, icmp6_type, ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static inline int ndisc_ops_opt_addr_space(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 					   u8 icmp6_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	if (dev->ndisc_ops && dev->ndisc_ops->opt_addr_space &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	    icmp6_type != NDISC_REDIRECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		return dev->ndisc_ops->opt_addr_space(dev, icmp6_type, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 						      NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static inline int ndisc_ops_redirect_opt_addr_space(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 						    struct neighbour *neigh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 						    u8 *ha_buf, u8 **ha)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if (dev->ndisc_ops && dev->ndisc_ops->opt_addr_space)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		return dev->ndisc_ops->opt_addr_space(dev, NDISC_REDIRECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 						      neigh, ha_buf, ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static inline void ndisc_ops_fill_addr_option(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 					      struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 					      u8 icmp6_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if (dev->ndisc_ops && dev->ndisc_ops->fill_addr_option &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	    icmp6_type != NDISC_REDIRECT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		dev->ndisc_ops->fill_addr_option(dev, skb, icmp6_type, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static inline void ndisc_ops_fill_redirect_addr_option(const struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 						       struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 						       const u8 *ha)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	if (dev->ndisc_ops && dev->ndisc_ops->fill_addr_option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		dev->ndisc_ops->fill_addr_option(dev, skb, NDISC_REDIRECT, ha);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static inline void ndisc_ops_prefix_rcv_add_addr(struct net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 						 struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 						 const struct prefix_info *pinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 						 struct inet6_dev *in6_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 						 struct in6_addr *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 						 int addr_type, u32 addr_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 						 bool sllao, bool tokenized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 						 __u32 valid_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 						 u32 prefered_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 						 bool dev_addr_generated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (dev->ndisc_ops && dev->ndisc_ops->prefix_rcv_add_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		dev->ndisc_ops->prefix_rcv_add_addr(net, dev, pinfo, in6_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 						    addr, addr_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 						    addr_flags, sllao,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 						    tokenized, valid_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 						    prefered_lft,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 						    dev_addr_generated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  * Return the padding between the option length and the start of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  * link addr.  Currently only IP-over-InfiniBand needs this, although
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * also need a pad of 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static inline int ndisc_addr_option_pad(unsigned short type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	case ARPHRD_INFINIBAND: return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	default:                return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static inline int __ndisc_opt_addr_space(unsigned char addr_len, int pad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	return NDISC_OPT_SPACE(addr_len + pad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) #if IS_ENABLED(CONFIG_IPV6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static inline int ndisc_opt_addr_space(struct net_device *dev, u8 icmp6_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	return __ndisc_opt_addr_space(dev->addr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 				      ndisc_addr_option_pad(dev->type)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		ndisc_ops_opt_addr_space(dev, icmp6_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) static inline int ndisc_redirect_opt_addr_space(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 						struct neighbour *neigh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 						u8 *ops_data_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 						u8 **ops_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	return __ndisc_opt_addr_space(dev->addr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 				      ndisc_addr_option_pad(dev->type)) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		ndisc_ops_redirect_opt_addr_space(dev, neigh, ops_data_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 						  ops_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static inline u8 *__ndisc_opt_addr_data(struct nd_opt_hdr *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 					unsigned char addr_len, int prepad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	u8 *lladdr = (u8 *)(p + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	int lladdrlen = p->nd_opt_len << 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	if (lladdrlen != __ndisc_opt_addr_space(addr_len, prepad))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	return lladdr + prepad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				      struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	return __ndisc_opt_addr_data(p, dev->addr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				     ndisc_addr_option_pad(dev->type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, __u32 *hash_rnd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	const u32 *p32 = pkey;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		(p32[1] * hash_rnd[1]) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		(p32[2] * hash_rnd[2]) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		(p32[3] * hash_rnd[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct neighbour *__ipv6_neigh_lookup_noref_stub(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 						 const void *pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	return ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 				     ndisc_hashfn, pkey, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	struct neighbour *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	rcu_read_lock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	n = __ipv6_neigh_lookup_noref(dev, pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	if (n && !refcount_inc_not_zero(&n->refcnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		n = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	rcu_read_unlock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	return n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) static inline void __ipv6_confirm_neigh(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 					const void *pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	struct neighbour *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	rcu_read_lock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	n = __ipv6_neigh_lookup_noref(dev, pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	if (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		/* avoid dirtying neighbour */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		if (READ_ONCE(n->confirmed) != now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			WRITE_ONCE(n->confirmed, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	rcu_read_unlock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 					     const void *pkey)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	struct neighbour *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	rcu_read_lock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	if (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		/* avoid dirtying neighbour */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		if (READ_ONCE(n->confirmed) != now)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 			WRITE_ONCE(n->confirmed, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	rcu_read_unlock_bh();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) /* uses ipv6_stub and is meant for use outside of IPv6 core */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static inline struct neighbour *ip_neigh_gw6(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 					     const void *addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	struct neighbour *neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	neigh = __ipv6_neigh_lookup_noref_stub(dev, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	if (unlikely(!neigh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		neigh = __neigh_create(ipv6_stub->nd_tbl, addr, dev, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	return neigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) int ndisc_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int ndisc_late_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) void ndisc_late_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) void ndisc_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) int ndisc_rcv(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		   const struct in6_addr *daddr, const struct in6_addr *saddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		   u64 nonce);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) void ndisc_send_rs(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		   const struct in6_addr *saddr, const struct in6_addr *daddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		   const struct in6_addr *solicited_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		   bool router, bool solicited, bool override, bool inc_opt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		 int dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) void ndisc_update(const struct net_device *dev, struct neighbour *neigh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		  const u8 *lladdr, u8 new, u32 flags, u8 icmp6_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		  struct ndisc_options *ndopts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)  *	IGMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) int igmp6_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) int igmp6_late_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) void igmp6_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) void igmp6_late_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) int igmp6_event_query(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) int igmp6_event_report(struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #ifdef CONFIG_SYSCTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 			       void *buffer, size_t *lenp, loff_t *ppos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) int ndisc_ifinfo_sysctl_strategy(struct ctl_table *ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 				 void __user *oldval, size_t __user *oldlenp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 				 void __user *newval, size_t newlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) void inet6_ifinfo_notify(int event, struct inet6_dev *idev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) #endif