kernel: add linux 4.9 support
[openwrt/openwrt.git] / target / linux / generic / patches-4.9 / 641-bridge_port_isolate.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: [PATCH] bridge: port isolate
3
4 Isolating individual bridge ports
5 ---
6 --- a/include/linux/if_bridge.h
7 +++ b/include/linux/if_bridge.h
8 @@ -47,6 +47,7 @@ struct br_ip_list {
9 #define BR_PROXYARP_WIFI BIT(10)
10 #define BR_MCAST_FLOOD BIT(11)
11 #define BR_MULTICAST_TO_UNICAST BIT(12)
12 +#define BR_ISOLATE_MODE BIT(13)
13
14 #define BR_DEFAULT_AGEING_TIME (300 * HZ)
15
16 --- a/net/bridge/br_sysfs_if.c
17 +++ b/net/bridge/br_sysfs_if.c
18 @@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
19 BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
20 BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
21 BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
22 +BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
23
24 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
25 static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
26 @@ -220,6 +221,7 @@ static const struct brport_attribute *br
27 &brport_attr_proxyarp,
28 &brport_attr_proxyarp_wifi,
29 &brport_attr_multicast_flood,
30 + &brport_attr_isolate_mode,
31 NULL
32 };
33
34 --- a/net/bridge/br_forward.c
35 +++ b/net/bridge/br_forward.c
36 @@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
37 void br_forward(const struct net_bridge_port *to,
38 struct sk_buff *skb, bool local_rcv, bool local_orig)
39 {
40 + if (to->flags & BR_ISOLATE_MODE)
41 + to = NULL;
42 +
43 if (to && should_deliver(to, skb)) {
44 if (local_rcv)
45 deliver_clone(to, skb, local_orig);
46 @@ -206,6 +209,8 @@ void br_flood(struct net_bridge *br, str
47 struct net_bridge_port *p;
48
49 list_for_each_entry_rcu(p, &br->port_list, list) {
50 + if (!local_orig && (p->flags & BR_ISOLATE_MODE))
51 + continue;
52 /* Do not flood unicast traffic to ports that turn it off */
53 if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD))
54 continue;
55 --- a/net/bridge/br_input.c
56 +++ b/net/bridge/br_input.c
57 @@ -174,6 +174,9 @@ int br_handle_frame_finish(struct net *n
58 if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
59 br_do_proxy_arp(skb, br, vid, p);
60
61 + if (p->flags & BR_ISOLATE_MODE)
62 + return br_pass_frame_up(skb);
63 +
64 switch (pkt_type) {
65 case BR_PKT_MULTICAST:
66 mdst = br_mdb_get(br, skb, vid);