hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/inetdevice.h
....@@ -26,7 +26,7 @@
2626 struct net_device *dev;
2727 refcount_t refcnt;
2828 int dead;
29
- struct in_ifaddr *ifa_list; /* IP ifaddr chain */
29
+ struct in_ifaddr __rcu *ifa_list;/* IP ifaddr chain */
3030
3131 struct ip_mc_list __rcu *mc_list; /* IP multicast filter chain */
3232 struct ip_mc_list __rcu * __rcu *mc_hash;
....@@ -136,7 +136,7 @@
136136
137137 struct in_ifaddr {
138138 struct hlist_node hash;
139
- struct in_ifaddr *ifa_next;
139
+ struct in_ifaddr __rcu *ifa_next;
140140 struct in_device *ifa_dev;
141141 struct rcu_head rcu_head;
142142 __be32 ifa_local;
....@@ -178,6 +178,15 @@
178178
179179 int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
180180 int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *);
181
+#ifdef CONFIG_INET
182
+int inet_gifconf(struct net_device *dev, char __user *buf, int len, int size);
183
+#else
184
+static inline int inet_gifconf(struct net_device *dev, char __user *buf,
185
+ int len, int size)
186
+{
187
+ return 0;
188
+}
189
+#endif
181190 void devinet_init(void);
182191 struct in_device *inetdev_by_index(struct net *, int);
183192 __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);
....@@ -186,7 +195,7 @@
186195 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
187196 __be32 mask);
188197 struct in_ifaddr *inet_lookup_ifaddr_rcu(struct net *net, __be32 addr);
189
-static __inline__ bool inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
198
+static inline bool inet_ifa_match(__be32 addr, const struct in_ifaddr *ifa)
190199 {
191200 return !((addr^ifa->ifa_address)&ifa->ifa_mask);
192201 }
....@@ -206,14 +215,13 @@
206215 return false;
207216 }
208217
209
-#define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
210
- for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next)
218
+#define in_dev_for_each_ifa_rtnl(ifa, in_dev) \
219
+ for (ifa = rtnl_dereference((in_dev)->ifa_list); ifa; \
220
+ ifa = rtnl_dereference(ifa->ifa_next))
211221
212
-#define for_ifa(in_dev) { struct in_ifaddr *ifa; \
213
- for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next)
214
-
215
-
216
-#define endfor_ifa(in_dev) }
222
+#define in_dev_for_each_ifa_rcu(ifa, in_dev) \
223
+ for (ifa = rcu_dereference((in_dev)->ifa_list); ifa; \
224
+ ifa = rcu_dereference(ifa->ifa_next))
217225
218226 static inline struct in_device *__in_dev_get_rcu(const struct net_device *dev)
219227 {
....@@ -237,6 +245,20 @@
237245 return rtnl_dereference(dev->ip_ptr);
238246 }
239247
248
+/* called with rcu_read_lock or rtnl held */
249
+static inline bool ip_ignore_linkdown(const struct net_device *dev)
250
+{
251
+ struct in_device *in_dev;
252
+ bool rc = false;
253
+
254
+ in_dev = rcu_dereference_rtnl(dev->ip_ptr);
255
+ if (in_dev &&
256
+ IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev))
257
+ rc = true;
258
+
259
+ return rc;
260
+}
261
+
240262 static inline struct neigh_parms *__in_dev_arp_parms_get_rcu(const struct net_device *dev)
241263 {
242264 struct in_device *in_dev = __in_dev_get_rcu(dev);