2016-12-25 19:11:34 +00:00
|
|
|
From e988390850731aa1697ed09d47b0932fac1af175 Mon Sep 17 00:00:00 2001
|
2017-01-27 13:32:10 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
2016-12-25 19:11:34 +00:00
|
|
|
Date: Fri, 7 Jul 2017 17:20:03 +0200
|
|
|
|
Subject: bridge: port isolate
|
2017-01-27 13:32:10 +00:00
|
|
|
|
|
|
|
Isolating individual bridge ports
|
2016-12-25 19:11:34 +00:00
|
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
2017-01-27 13:32:10 +00:00
|
|
|
---
|
2016-12-25 19:11:34 +00:00
|
|
|
include/linux/if_bridge.h | 1 +
|
|
|
|
net/bridge/br_forward.c | 5 +++++
|
|
|
|
net/bridge/br_input.c | 3 +++
|
|
|
|
net/bridge/br_sysfs_if.c | 2 ++
|
|
|
|
4 files changed, 11 insertions(+)
|
|
|
|
|
|
|
|
Index: linux-4.9.34/include/linux/if_bridge.h
|
|
|
|
===================================================================
|
|
|
|
--- linux-4.9.34.orig/include/linux/if_bridge.h
|
|
|
|
+++ linux-4.9.34/include/linux/if_bridge.h
|
2017-01-27 13:32:10 +00:00
|
|
|
@@ -47,6 +47,7 @@ struct br_ip_list {
|
|
|
|
#define BR_PROXYARP_WIFI BIT(10)
|
|
|
|
#define BR_MCAST_FLOOD BIT(11)
|
|
|
|
#define BR_MULTICAST_TO_UNICAST BIT(12)
|
|
|
|
+#define BR_ISOLATE_MODE BIT(13)
|
|
|
|
|
|
|
|
#define BR_DEFAULT_AGEING_TIME (300 * HZ)
|
|
|
|
|
2016-12-25 19:11:34 +00:00
|
|
|
Index: linux-4.9.34/net/bridge/br_forward.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-4.9.34.orig/net/bridge/br_forward.c
|
|
|
|
+++ linux-4.9.34/net/bridge/br_forward.c
|
2017-01-27 13:32:10 +00:00
|
|
|
@@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
|
|
|
|
void br_forward(const struct net_bridge_port *to,
|
|
|
|
struct sk_buff *skb, bool local_rcv, bool local_orig)
|
|
|
|
{
|
|
|
|
+ if (to->flags & BR_ISOLATE_MODE)
|
|
|
|
+ to = NULL;
|
|
|
|
+
|
|
|
|
if (to && should_deliver(to, skb)) {
|
|
|
|
if (local_rcv)
|
|
|
|
deliver_clone(to, skb, local_orig);
|
|
|
|
@@ -206,6 +209,8 @@ void br_flood(struct net_bridge *br, str
|
|
|
|
struct net_bridge_port *p;
|
|
|
|
|
|
|
|
list_for_each_entry_rcu(p, &br->port_list, list) {
|
|
|
|
+ if (!local_orig && (p->flags & BR_ISOLATE_MODE))
|
|
|
|
+ continue;
|
|
|
|
/* Do not flood unicast traffic to ports that turn it off */
|
|
|
|
if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD))
|
|
|
|
continue;
|
2016-12-25 19:11:34 +00:00
|
|
|
Index: linux-4.9.34/net/bridge/br_input.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-4.9.34.orig/net/bridge/br_input.c
|
|
|
|
+++ linux-4.9.34/net/bridge/br_input.c
|
2017-03-26 10:22:27 +00:00
|
|
|
@@ -175,6 +175,9 @@ int br_handle_frame_finish(struct net *n
|
2017-01-27 13:32:10 +00:00
|
|
|
if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
|
|
|
|
br_do_proxy_arp(skb, br, vid, p);
|
|
|
|
|
|
|
|
+ if (p->flags & BR_ISOLATE_MODE)
|
|
|
|
+ return br_pass_frame_up(skb);
|
|
|
|
+
|
|
|
|
switch (pkt_type) {
|
|
|
|
case BR_PKT_MULTICAST:
|
|
|
|
mdst = br_mdb_get(br, skb, vid);
|
2016-12-25 19:11:34 +00:00
|
|
|
Index: linux-4.9.34/net/bridge/br_sysfs_if.c
|
|
|
|
===================================================================
|
|
|
|
--- linux-4.9.34.orig/net/bridge/br_sysfs_if.c
|
|
|
|
+++ linux-4.9.34/net/bridge/br_sysfs_if.c
|
|
|
|
@@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
|
|
|
|
BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
|
|
|
|
BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
|
|
|
|
BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
|
|
|
|
+BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
|
|
|
|
|
|
|
|
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
|
|
|
static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
|
|
|
|
@@ -220,6 +221,7 @@ static const struct brport_attribute *br
|
|
|
|
&brport_attr_proxyarp,
|
|
|
|
&brport_attr_proxyarp_wifi,
|
|
|
|
&brport_attr_multicast_flood,
|
|
|
|
+ &brport_attr_isolate_mode,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|