generic: mtd backport for Spansion S25FL164K
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-4.1 / 642-bridge_port_isolate.patch
1 --- a/include/linux/if_bridge.h
2 +++ b/include/linux/if_bridge.h
3 @@ -45,6 +45,7 @@ struct br_ip_list {
4 #define BR_PROXYARP BIT(8)
5 #define BR_LEARNING_SYNC BIT(9)
6 #define BR_PROXYARP_WIFI BIT(10)
7 +#define BR_ISOLATE_MODE BIT(11)
8
9 extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
10
11 --- a/net/bridge/br_sysfs_if.c
12 +++ b/net/bridge/br_sysfs_if.c
13 @@ -173,6 +173,22 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
14 BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
15 BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
16
17 +static ssize_t show_isolate_mode(struct net_bridge_port *p, char *buf)
18 +{
19 + int isolate_mode = (p->flags & BR_ISOLATE_MODE) ? 1 : 0;
20 + return sprintf(buf, "%d\n", isolate_mode);
21 +}
22 +static ssize_t store_isolate_mode(struct net_bridge_port *p, unsigned long v)
23 +{
24 + if (v)
25 + p->flags |= BR_ISOLATE_MODE;
26 + else
27 + p->flags &= ~BR_ISOLATE_MODE;
28 + return 0;
29 +}
30 +static BRPORT_ATTR(isolate_mode, S_IRUGO | S_IWUSR,
31 + show_isolate_mode, store_isolate_mode);
32 +
33 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
34 static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
35 {
36 @@ -217,6 +233,7 @@ static const struct brport_attribute *br
37 #endif
38 &brport_attr_proxyarp,
39 &brport_attr_proxyarp_wifi,
40 + &brport_attr_isolate_mode,
41 NULL
42 };
43
44 --- a/net/bridge/br_input.c
45 +++ b/net/bridge/br_input.c
46 @@ -185,8 +185,8 @@ int br_handle_frame_finish(struct sock *
47
48 unicast = false;
49 br->dev->stats.multicast++;
50 - } else if ((dst = __br_fdb_get(br, dest, vid)) &&
51 - dst->is_local) {
52 + } else if ((p->flags & BR_ISOLATE_MODE) ||
53 + ((dst = __br_fdb_get(br, dest, vid)) && dst->is_local)) {
54 skb2 = skb;
55 /* Do not forward the packet since it's local. */
56 skb = NULL;
57 --- a/net/bridge/br_forward.c
58 +++ b/net/bridge/br_forward.c
59 @@ -118,7 +118,7 @@ EXPORT_SYMBOL_GPL(br_deliver);
60 /* called with rcu_read_lock */
61 void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
62 {
63 - if (should_deliver(to, skb)) {
64 + if (should_deliver(to, skb) && !(to->flags & BR_ISOLATE_MODE)) {
65 if (skb0)
66 deliver_clone(to, skb, __br_forward);
67 else
68 @@ -174,7 +174,7 @@ static void br_flood(struct net_bridge *
69 struct sk_buff *skb0,
70 void (*__packet_hook)(const struct net_bridge_port *p,
71 struct sk_buff *skb),
72 - bool unicast)
73 + bool unicast, bool forward)
74 {
75 struct net_bridge_port *p;
76 struct net_bridge_port *prev;
77 @@ -182,6 +182,8 @@ static void br_flood(struct net_bridge *
78 prev = NULL;
79
80 list_for_each_entry_rcu(p, &br->port_list, list) {
81 + if (forward && (p->flags & BR_ISOLATE_MODE))
82 + continue;
83 /* Do not flood unicast traffic to ports that turn it off */
84 if (unicast && !(p->flags & BR_FLOOD))
85 continue;
86 @@ -216,14 +218,14 @@ out:
87 /* called with rcu_read_lock */
88 void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb, bool unicast)
89 {
90 - br_flood(br, skb, NULL, __br_deliver, unicast);
91 + br_flood(br, skb, NULL, __br_deliver, unicast, false);
92 }
93
94 /* called under bridge lock */
95 void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
96 struct sk_buff *skb2, bool unicast)
97 {
98 - br_flood(br, skb, skb2, __br_forward, unicast);
99 + br_flood(br, skb, skb2, __br_forward, unicast, true);
100 }
101
102 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING