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