v1.5 branch refresh based upon upstream master @ c8677ca89e53e3be7988d54280fce166cc894a7e
[librecmc/librecmc.git] / target / linux / generic / hack-4.14 / 641-bridge_port_isolate.patch
1 From e988390850731aa1697ed09d47b0932fac1af175 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Fri, 7 Jul 2017 17:20:03 +0200
4 Subject: bridge: port isolate
5
6 Isolating individual bridge ports
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10  include/linux/if_bridge.h | 1 +
11  net/bridge/br_forward.c   | 5 +++++
12  net/bridge/br_input.c     | 3 +++
13  net/bridge/br_sysfs_if.c  | 2 ++
14  4 files changed, 11 insertions(+)
15
16 --- a/include/linux/if_bridge.h
17 +++ b/include/linux/if_bridge.h
18 @@ -49,6 +49,7 @@ struct br_ip_list {
19  #define BR_MULTICAST_TO_UNICAST        BIT(12)
20  #define BR_VLAN_TUNNEL         BIT(13)
21  #define BR_BCAST_FLOOD         BIT(14)
22 +#define BR_ISOLATE_MODE                BIT(15)
23  
24  #define BR_DEFAULT_AGEING_TIME (300 * HZ)
25  
26 --- a/net/bridge/br_forward.c
27 +++ b/net/bridge/br_forward.c
28 @@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
29  void br_forward(const struct net_bridge_port *to,
30                 struct sk_buff *skb, bool local_rcv, bool local_orig)
31  {
32 +       if (to->flags & BR_ISOLATE_MODE && !local_orig)
33 +               to = NULL;
34 +
35         if (to && should_deliver(to, skb)) {
36                 if (local_rcv)
37                         deliver_clone(to, skb, local_orig);
38 @@ -183,6 +186,8 @@ void br_flood(struct net_bridge *br, str
39         struct net_bridge_port *p;
40  
41         list_for_each_entry_rcu(p, &br->port_list, list) {
42 +               if (!local_orig && (p->flags & BR_ISOLATE_MODE))
43 +                       continue;
44                 /* Do not flood unicast traffic to ports that turn it off, nor
45                  * other traffic if flood off, except for traffic we originate
46                  */
47 --- a/net/bridge/br_input.c
48 +++ b/net/bridge/br_input.c
49 @@ -177,6 +177,9 @@ int br_handle_frame_finish(struct net *n
50         if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
51                 br_do_proxy_arp(skb, br, vid, p);
52  
53 +       if (p->flags & BR_ISOLATE_MODE)
54 +               return br_pass_frame_up(skb);
55 +
56         switch (pkt_type) {
57         case BR_PKT_MULTICAST:
58                 mdst = br_mdb_get(br, skb, vid);
59 --- a/net/bridge/br_sysfs_if.c
60 +++ b/net/bridge/br_sysfs_if.c
61 @@ -174,6 +174,7 @@ BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
62  BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
63  BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
64  BRPORT_ATTR_FLAG(broadcast_flood, BR_BCAST_FLOOD);
65 +BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
66  
67  #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
68  static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
69 @@ -223,6 +224,7 @@ static const struct brport_attribute *br
70         &brport_attr_proxyarp_wifi,
71         &brport_attr_multicast_flood,
72         &brport_attr_broadcast_flood,
73 +       &brport_attr_isolate_mode,
74         NULL
75  };
76