kernel: split patches folder up into backport, pending and hack folders
[openwrt/openwrt.git] / target / linux / generic / hack-4.9 / 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 Index: linux-4.9.34/include/linux/if_bridge.h
17 ===================================================================
18 --- linux-4.9.34.orig/include/linux/if_bridge.h
19 +++ linux-4.9.34/include/linux/if_bridge.h
20 @@ -47,6 +47,7 @@ struct br_ip_list {
21 #define BR_PROXYARP_WIFI BIT(10)
22 #define BR_MCAST_FLOOD BIT(11)
23 #define BR_MULTICAST_TO_UNICAST BIT(12)
24 +#define BR_ISOLATE_MODE BIT(13)
25
26 #define BR_DEFAULT_AGEING_TIME (300 * HZ)
27
28 Index: linux-4.9.34/net/bridge/br_forward.c
29 ===================================================================
30 --- linux-4.9.34.orig/net/bridge/br_forward.c
31 +++ linux-4.9.34/net/bridge/br_forward.c
32 @@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
33 void br_forward(const struct net_bridge_port *to,
34 struct sk_buff *skb, bool local_rcv, bool local_orig)
35 {
36 + if (to->flags & BR_ISOLATE_MODE)
37 + to = NULL;
38 +
39 if (to && should_deliver(to, skb)) {
40 if (local_rcv)
41 deliver_clone(to, skb, local_orig);
42 @@ -206,6 +209,8 @@ void br_flood(struct net_bridge *br, str
43 struct net_bridge_port *p;
44
45 list_for_each_entry_rcu(p, &br->port_list, list) {
46 + if (!local_orig && (p->flags & BR_ISOLATE_MODE))
47 + continue;
48 /* Do not flood unicast traffic to ports that turn it off */
49 if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD))
50 continue;
51 Index: linux-4.9.34/net/bridge/br_input.c
52 ===================================================================
53 --- linux-4.9.34.orig/net/bridge/br_input.c
54 +++ linux-4.9.34/net/bridge/br_input.c
55 @@ -175,6 +175,9 @@ int br_handle_frame_finish(struct net *n
56 if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
57 br_do_proxy_arp(skb, br, vid, p);
58
59 + if (p->flags & BR_ISOLATE_MODE)
60 + return br_pass_frame_up(skb);
61 +
62 switch (pkt_type) {
63 case BR_PKT_MULTICAST:
64 mdst = br_mdb_get(br, skb, vid);
65 Index: linux-4.9.34/net/bridge/br_sysfs_if.c
66 ===================================================================
67 --- linux-4.9.34.orig/net/bridge/br_sysfs_if.c
68 +++ linux-4.9.34/net/bridge/br_sysfs_if.c
69 @@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
70 BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
71 BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
72 BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
73 +BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
74
75 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
76 static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
77 @@ -220,6 +221,7 @@ static const struct brport_attribute *br
78 &brport_attr_proxyarp,
79 &brport_attr_proxyarp_wifi,
80 &brport_attr_multicast_flood,
81 + &brport_attr_isolate_mode,
82 NULL
83 };
84