bridge: Encapsulate data path neighbor suppression logic
authorIdo Schimmel <idosch@nvidia.com>
Wed, 19 Apr 2023 15:34:56 +0000 (18:34 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Apr 2023 07:25:50 +0000 (08:25 +0100)
Currently, there are various places in the bridge data path that check
whether neighbor suppression is enabled on a given bridge port.

As a preparation for per-{Port, VLAN} neighbor suppression, encapsulate
this logic in a function and pass the VLAN ID of the packet as an
argument.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_arp_nd_proxy.c
net/bridge/br_forward.c
net/bridge/br_private.h

index 016a25a..16c3a1c 100644 (file)
@@ -158,7 +158,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
                return;
 
        if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {
-               if (p && (p->flags & BR_NEIGH_SUPPRESS))
+               if (br_is_neigh_suppress_enabled(p, vid))
                        return;
                if (parp->ar_op != htons(ARPOP_RREQUEST) &&
                    parp->ar_op != htons(ARPOP_RREPLY) &&
@@ -202,8 +202,8 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
                        bool replied = false;
 
                        if ((p && (p->flags & BR_PROXYARP)) ||
-                           (f->dst && (f->dst->flags & (BR_PROXYARP_WIFI |
-                                                        BR_NEIGH_SUPPRESS)))) {
+                           (f->dst && (f->dst->flags & BR_PROXYARP_WIFI)) ||
+                           br_is_neigh_suppress_enabled(f->dst, vid)) {
                                if (!vid)
                                        br_arp_send(br, p, skb->dev, sip, tip,
                                                    sha, n->ha, sha, 0, 0);
@@ -407,7 +407,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
 
        BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
 
-       if (p && (p->flags & BR_NEIGH_SUPPRESS))
+       if (br_is_neigh_suppress_enabled(p, vid))
                return;
 
        if (msg->icmph.icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT &&
@@ -461,7 +461,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
                if (f) {
                        bool replied = false;
 
-                       if (f->dst && (f->dst->flags & BR_NEIGH_SUPPRESS)) {
+                       if (br_is_neigh_suppress_enabled(f->dst, vid)) {
                                if (vid != 0)
                                        br_nd_send(br, p, skb, n,
                                                   skb->vlan_proto,
@@ -483,3 +483,8 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
        }
 }
 #endif
+
+bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid)
+{
+       return p && (p->flags & BR_NEIGH_SUPPRESS);
+}
index 94a8d75..5774470 100644 (file)
@@ -226,7 +226,8 @@ void br_flood(struct net_bridge *br, struct sk_buff *skb,
                if (p->flags & BR_PROXYARP)
                        continue;
                if (BR_INPUT_SKB_CB(skb)->proxyarp_replied &&
-                   (p->flags & (BR_PROXYARP_WIFI | BR_NEIGH_SUPPRESS)))
+                   ((p->flags & BR_PROXYARP_WIFI) ||
+                    br_is_neigh_suppress_enabled(p, vid)))
                        continue;
 
                prev = maybe_deliver(prev, p, skb, local_orig);
index b17fc82..2119729 100644 (file)
@@ -2220,4 +2220,5 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
 void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
                       u16 vid, struct net_bridge_port *p, struct nd_msg *msg);
 struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *m);
+bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid);
 #endif