hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/net/bridge/br_arp_nd_proxy.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Handle bridge arp/nd proxy/suppress
34 *
....@@ -6,11 +7,6 @@
67 *
78 * Authors:
89 * Roopa Prabhu <roopa@cumulusnetworks.com>
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License
12
- * as published by the Free Software Foundation; either version
13
- * 2 of the License, or (at your option) any later version.
1410 */
1511
1612 #include <linux/kernel.h>
....@@ -21,6 +17,7 @@
2117 #include <linux/if_vlan.h>
2218 #include <linux/inetdevice.h>
2319 #include <net/addrconf.h>
20
+#include <net/ipv6_stubs.h>
2421 #if IS_ENABLED(CONFIG_IPV6)
2522 #include <net/ip6_checksum.h>
2623 #endif
....@@ -39,7 +36,7 @@
3936 }
4037 }
4138
42
- br->neigh_suppress_enabled = neigh_suppress;
39
+ br_opt_toggle(br, BROPT_NEIGH_SUPPRESS_ENABLED, neigh_suppress);
4340 }
4441
4542 #if IS_ENABLED(CONFIG_INET)
....@@ -91,9 +88,10 @@
9188 }
9289 }
9390
94
-static int br_chk_addr_ip(struct net_device *dev, void *data)
91
+static int br_chk_addr_ip(struct net_device *dev,
92
+ struct netdev_nested_priv *priv)
9593 {
96
- __be32 ip = *(__be32 *)data;
94
+ __be32 ip = *(__be32 *)priv->data;
9795 struct in_device *in_dev;
9896 __be32 addr = 0;
9997
....@@ -110,11 +108,15 @@
110108
111109 static bool br_is_local_ip(struct net_device *dev, __be32 ip)
112110 {
113
- if (br_chk_addr_ip(dev, &ip))
111
+ struct netdev_nested_priv priv = {
112
+ .data = (void *)&ip,
113
+ };
114
+
115
+ if (br_chk_addr_ip(dev, &priv))
114116 return true;
115117
116118 /* check if ip is configured on upper dev */
117
- if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip, &ip))
119
+ if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip, &priv))
118120 return true;
119121
120122 return false;
....@@ -130,7 +132,7 @@
130132 u8 *arpptr, *sha;
131133 __be32 sip, tip;
132134
133
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = false;
135
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
134136
135137 if ((dev->flags & IFF_NOARP) ||
136138 !pskb_may_pull(skb, arp_hdr_len(dev)))
....@@ -155,14 +157,14 @@
155157 ipv4_is_multicast(tip))
156158 return;
157159
158
- if (br->neigh_suppress_enabled) {
160
+ if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {
159161 if (p && (p->flags & BR_NEIGH_SUPPRESS))
160162 return;
161163 if (parp->ar_op != htons(ARPOP_RREQUEST) &&
162164 parp->ar_op != htons(ARPOP_RREPLY) &&
163165 (ipv4_is_zeronet(sip) || sip == tip)) {
164166 /* prevent flooding to neigh suppress ports */
165
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
167
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
166168 return;
167169 }
168170 }
....@@ -177,11 +179,12 @@
177179 return;
178180 }
179181
180
- if (br->neigh_suppress_enabled && br_is_local_ip(vlandev, tip)) {
182
+ if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) &&
183
+ br_is_local_ip(vlandev, tip)) {
181184 /* its our local ip, so don't proxy reply
182185 * and don't forward to neigh suppress ports
183186 */
184
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
187
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
185188 return;
186189 }
187190
....@@ -215,8 +218,9 @@
215218 /* If we have replied or as long as we know the
216219 * mac, indicate to arp replied
217220 */
218
- if (replied || br->neigh_suppress_enabled)
219
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
221
+ if (replied ||
222
+ br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
223
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
220224 }
221225
222226 neigh_release(n);
....@@ -364,9 +368,10 @@
364368 }
365369 }
366370
367
-static int br_chk_addr_ip6(struct net_device *dev, void *data)
371
+static int br_chk_addr_ip6(struct net_device *dev,
372
+ struct netdev_nested_priv *priv)
368373 {
369
- struct in6_addr *addr = (struct in6_addr *)data;
374
+ struct in6_addr *addr = (struct in6_addr *)priv->data;
370375
371376 if (ipv6_chk_addr(dev_net(dev), addr, dev, 0))
372377 return 1;
....@@ -377,11 +382,15 @@
377382 static bool br_is_local_ip6(struct net_device *dev, struct in6_addr *addr)
378383
379384 {
380
- if (br_chk_addr_ip6(dev, addr))
385
+ struct netdev_nested_priv priv = {
386
+ .data = (void *)addr,
387
+ };
388
+
389
+ if (br_chk_addr_ip6(dev, &priv))
381390 return true;
382391
383392 /* check if ip is configured on upper dev */
384
- if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip6, addr))
393
+ if (netdev_walk_all_upper_dev_rcu(dev, br_chk_addr_ip6, &priv))
385394 return true;
386395
387396 return false;
....@@ -396,7 +405,7 @@
396405 struct ipv6hdr *iphdr;
397406 struct neighbour *n;
398407
399
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = false;
408
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
400409
401410 if (p && (p->flags & BR_NEIGH_SUPPRESS))
402411 return;
....@@ -404,7 +413,7 @@
404413 if (msg->icmph.icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT &&
405414 !msg->icmph.icmp6_solicited) {
406415 /* prevent flooding to neigh suppress ports */
407
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
416
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
408417 return;
409418 }
410419
....@@ -417,7 +426,7 @@
417426
418427 if (ipv6_addr_any(saddr) || !ipv6_addr_cmp(saddr, daddr)) {
419428 /* prevent flooding to neigh suppress ports */
420
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
429
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
421430 return;
422431 }
423432
....@@ -435,7 +444,7 @@
435444 /* its our own ip, so don't proxy reply
436445 * and don't forward to arp suppress ports
437446 */
438
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
447
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
439448 return;
440449 }
441450
....@@ -466,8 +475,9 @@
466475 * mac, indicate to NEIGH_SUPPRESS ports that we
467476 * have replied
468477 */
469
- if (replied || br->neigh_suppress_enabled)
470
- BR_INPUT_SKB_CB(skb)->proxyarp_replied = true;
478
+ if (replied ||
479
+ br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED))
480
+ BR_INPUT_SKB_CB(skb)->proxyarp_replied = 1;
471481 }
472482 neigh_release(n);
473483 }