hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/net/neighbour.h
....@@ -28,6 +28,7 @@
2828 #include <linux/err.h>
2929 #include <linux/sysctl.h>
3030 #include <linux/workqueue.h>
31
+#include <linux/android_kabi.h>
3132 #include <net/rtnetlink.h>
3233
3334 /*
....@@ -72,7 +73,6 @@
7273 struct net_device *dev;
7374 struct list_head list;
7475 int (*neigh_setup)(struct neighbour *);
75
- void (*neigh_cleanup)(struct neighbour *);
7676 struct neigh_table *tbl;
7777
7878 void *sysctl_table;
....@@ -84,6 +84,8 @@
8484 int reachable_time;
8585 int data[NEIGH_VAR_DATA_MAX];
8686 DECLARE_BITMAP(data_state, NEIGH_VAR_DATA_MAX);
87
+
88
+ ANDROID_KABI_RESERVE(1);
8789 };
8890
8991 static inline void neigh_var_set(struct neigh_parms *p, int index, int val)
....@@ -140,8 +142,8 @@
140142 unsigned long updated;
141143 rwlock_t lock;
142144 refcount_t refcnt;
143
- struct sk_buff_head arp_queue;
144145 unsigned int arp_queue_len_bytes;
146
+ struct sk_buff_head arp_queue;
145147 struct timer_list timer;
146148 unsigned long used;
147149 atomic_t probes;
....@@ -149,13 +151,18 @@
149151 __u8 nud_state;
150152 __u8 type;
151153 __u8 dead;
154
+ u8 protocol;
152155 seqlock_t ha_lock;
153
- unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))];
156
+ unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))] __aligned(8);
154157 struct hh_cache hh;
155158 int (*output)(struct neighbour *, struct sk_buff *);
156159 const struct neigh_ops *ops;
160
+ struct list_head gc_list;
157161 struct rcu_head rcu;
158162 struct net_device *dev;
163
+
164
+ ANDROID_KABI_RESERVE(1);
165
+
159166 u8 primary_key[0];
160167 } __randomize_layout;
161168
....@@ -172,7 +179,8 @@
172179 possible_net_t net;
173180 struct net_device *dev;
174181 u8 flags;
175
- u8 key[0];
182
+ u8 protocol;
183
+ u8 key[];
176184 };
177185
178186 /*
....@@ -202,6 +210,9 @@
202210 int (*pconstructor)(struct pneigh_entry *);
203211 void (*pdestructor)(struct pneigh_entry *);
204212 void (*proxy_redo)(struct sk_buff *skb);
213
+ int (*is_multicast)(const void *pkey);
214
+ bool (*allow_add)(const struct net_device *dev,
215
+ struct netlink_ext_ack *extack);
205216 char *id;
206217 struct neigh_parms parms;
207218 struct list_head parms_list;
....@@ -214,11 +225,15 @@
214225 struct timer_list proxy_timer;
215226 struct sk_buff_head proxy_queue;
216227 atomic_t entries;
228
+ atomic_t gc_entries;
229
+ struct list_head gc_list;
217230 rwlock_t lock;
218231 unsigned long last_rand;
219232 struct neigh_statistics __percpu *stats;
220233 struct neigh_hash_table __rcu *nht;
221234 struct pneigh_entry **phash_buckets;
235
+
236
+ ANDROID_KABI_RESERVE(1);
222237 };
223238
224239 enum {
....@@ -246,10 +261,12 @@
246261 #define NEIGH_UPDATE_F_OVERRIDE 0x00000001
247262 #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002
248263 #define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004
264
+#define NEIGH_UPDATE_F_USE 0x10000000
249265 #define NEIGH_UPDATE_F_EXT_LEARNED 0x20000000
250266 #define NEIGH_UPDATE_F_ISROUTER 0x40000000
251267 #define NEIGH_UPDATE_F_ADMIN 0x80000000
252268
269
+extern const struct nla_policy nda_policy[];
253270
254271 static inline bool neigh_key_eq16(const struct neighbour *n, const void *pkey)
255272 {
....@@ -323,6 +340,7 @@
323340 bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl);
324341 void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
325342 int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
343
+int neigh_carrier_down(struct neigh_table *tbl, struct net_device *dev);
326344 int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
327345 int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
328346 int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
....@@ -384,13 +402,12 @@
384402 void neigh_seq_stop(struct seq_file *, void *);
385403
386404 int neigh_proc_dointvec(struct ctl_table *ctl, int write,
387
- void __user *buffer, size_t *lenp, loff_t *ppos);
405
+ void *buffer, size_t *lenp, loff_t *ppos);
388406 int neigh_proc_dointvec_jiffies(struct ctl_table *ctl, int write,
389
- void __user *buffer,
407
+ void *buffer,
390408 size_t *lenp, loff_t *ppos);
391409 int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
392
- void __user *buffer,
393
- size_t *lenp, loff_t *ppos);
410
+ void *buffer, size_t *lenp, loff_t *ppos);
394411
395412 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
396413 proc_handler *proc_handler);
....@@ -491,14 +508,20 @@
491508 return dev_queue_xmit(skb);
492509 }
493510
494
-static inline int neigh_output(struct neighbour *n, struct sk_buff *skb)
511
+static inline int neigh_output(struct neighbour *n, struct sk_buff *skb,
512
+ bool skip_cache)
495513 {
496514 const struct hh_cache *hh = &n->hh;
497515
498
- if ((n->nud_state & NUD_CONNECTED) && hh->hh_len)
516
+ /* n->nud_state and hh->hh_len could be changed under us.
517
+ * neigh_hh_output() is taking care of the race later.
518
+ */
519
+ if (!skip_cache &&
520
+ (READ_ONCE(n->nud_state) & NUD_CONNECTED) &&
521
+ READ_ONCE(hh->hh_len))
499522 return neigh_hh_output(hh, skb);
500
- else
501
- return n->output(n, skb);
523
+
524
+ return n->output(n, skb);
502525 }
503526
504527 static inline struct neighbour *
....@@ -545,20 +568,17 @@
545568 } while (read_seqretry(&n->ha_lock, seq));
546569 }
547570
548
-static inline void neigh_update_ext_learned(struct neighbour *neigh, u32 flags,
549
- int *notify)
571
+static inline void neigh_update_is_router(struct neighbour *neigh, u32 flags,
572
+ int *notify)
550573 {
551574 u8 ndm_flags = 0;
552575
553
- if (!(flags & NEIGH_UPDATE_F_ADMIN))
554
- return;
555
-
556
- ndm_flags |= (flags & NEIGH_UPDATE_F_EXT_LEARNED) ? NTF_EXT_LEARNED : 0;
557
- if ((neigh->flags ^ ndm_flags) & NTF_EXT_LEARNED) {
558
- if (ndm_flags & NTF_EXT_LEARNED)
559
- neigh->flags |= NTF_EXT_LEARNED;
576
+ ndm_flags |= (flags & NEIGH_UPDATE_F_ISROUTER) ? NTF_ROUTER : 0;
577
+ if ((neigh->flags ^ ndm_flags) & NTF_ROUTER) {
578
+ if (ndm_flags & NTF_ROUTER)
579
+ neigh->flags |= NTF_ROUTER;
560580 else
561
- neigh->flags &= ~NTF_EXT_LEARNED;
581
+ neigh->flags &= ~NTF_ROUTER;
562582 *notify = 1;
563583 }
564584 }