hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/net/ndisc.h
....@@ -2,6 +2,8 @@
22 #ifndef _NDISC_H
33 #define _NDISC_H
44
5
+#include <net/ipv6_stubs.h>
6
+
57 /*
68 * ICMP codes for neighbour discovery messages
79 */
....@@ -79,12 +81,12 @@
7981 struct nd_msg {
8082 struct icmp6hdr icmph;
8183 struct in6_addr target;
82
- __u8 opt[0];
84
+ __u8 opt[];
8385 };
8486
8587 struct rs_msg {
8688 struct icmp6hdr icmph;
87
- __u8 opt[0];
89
+ __u8 opt[];
8890 };
8991
9092 struct ra_msg {
....@@ -97,7 +99,7 @@
9799 struct icmp6hdr icmph;
98100 struct in6_addr target;
99101 struct in6_addr dest;
100
- __u8 opt[0];
102
+ __u8 opt[];
101103 };
102104
103105 struct nd_opt_hdr {
....@@ -381,6 +383,14 @@
381383 return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev);
382384 }
383385
386
+static inline
387
+struct neighbour *__ipv6_neigh_lookup_noref_stub(struct net_device *dev,
388
+ const void *pkey)
389
+{
390
+ return ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128,
391
+ ndisc_hashfn, pkey, dev);
392
+}
393
+
384394 static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey)
385395 {
386396 struct neighbour *n;
....@@ -405,10 +415,40 @@
405415 unsigned long now = jiffies;
406416
407417 /* avoid dirtying neighbour */
408
- if (n->confirmed != now)
409
- n->confirmed = now;
418
+ if (READ_ONCE(n->confirmed) != now)
419
+ WRITE_ONCE(n->confirmed, now);
410420 }
411421 rcu_read_unlock_bh();
422
+}
423
+
424
+static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
425
+ const void *pkey)
426
+{
427
+ struct neighbour *n;
428
+
429
+ rcu_read_lock_bh();
430
+ n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
431
+ if (n) {
432
+ unsigned long now = jiffies;
433
+
434
+ /* avoid dirtying neighbour */
435
+ if (READ_ONCE(n->confirmed) != now)
436
+ WRITE_ONCE(n->confirmed, now);
437
+ }
438
+ rcu_read_unlock_bh();
439
+}
440
+
441
+/* uses ipv6_stub and is meant for use outside of IPv6 core */
442
+static inline struct neighbour *ip_neigh_gw6(struct net_device *dev,
443
+ const void *addr)
444
+{
445
+ struct neighbour *neigh;
446
+
447
+ neigh = __ipv6_neigh_lookup_noref_stub(dev, addr);
448
+ if (unlikely(!neigh))
449
+ neigh = __neigh_create(ipv6_stub->nd_tbl, addr, dev, false);
450
+
451
+ return neigh;
412452 }
413453
414454 int ndisc_init(void);
....@@ -454,7 +494,7 @@
454494
455495 #ifdef CONFIG_SYSCTL
456496 int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
457
- void __user *buffer, size_t *lenp, loff_t *ppos);
497
+ void *buffer, size_t *lenp, loff_t *ppos);
458498 int ndisc_ifinfo_sysctl_strategy(struct ctl_table *ctl,
459499 void __user *oldval, size_t __user *oldlenp,
460500 void __user *newval, size_t newlen);