diff options
author | stephen hemminger <shemminger@vyatta.com> | 2012-11-13 07:53:08 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-14 20:20:44 -0500 |
commit | 1007dd1aa50b0403df370834f647abef1722925c (patch) | |
tree | cd36018c9fa1ae353e7e27f1080950d19d44eaa5 /net/bridge/br_stp.c | |
parent | a2e01a65cd7135dab26d27d4b589b2e5358bec99 (diff) | |
download | op-kernel-dev-1007dd1aa50b0403df370834f647abef1722925c.zip op-kernel-dev-1007dd1aa50b0403df370834f647abef1722925c.tar.gz |
bridge: add root port blocking
This is Linux bridge implementation of root port guard.
If BPDU is received from a leaf (edge) port, it should not
be elected as root port.
Why would you want to do this?
If using STP on a bridge and the downstream bridges are not fully
trusted; this prevents a hostile guest for rerouting traffic.
Why not just use netfilter?
Netfilter does not track of follow spanning tree decisions.
It would be difficult and error prone to try and mirror STP
resolution in netfilter module.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_stp.c')
-rw-r--r-- | net/bridge/br_stp.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c index af9a120..b01849a 100644 --- a/net/bridge/br_stp.c +++ b/net/bridge/br_stp.c @@ -100,6 +100,21 @@ static int br_should_become_root_port(const struct net_bridge_port *p, return 0; } +static void br_root_port_block(const struct net_bridge *br, + struct net_bridge_port *p) +{ + + br_notice(br, "port %u(%s) tried to become root port (blocked)", + (unsigned int) p->port_no, p->dev->name); + + p->state = BR_STATE_LISTENING; + br_log_state(p); + br_ifinfo_notify(RTM_NEWLINK, p); + + if (br->forward_delay > 0) + mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); +} + /* called under bridge lock */ static void br_root_selection(struct net_bridge *br) { @@ -107,7 +122,12 @@ static void br_root_selection(struct net_bridge *br) u16 root_port = 0; list_for_each_entry(p, &br->port_list, list) { - if (br_should_become_root_port(p, root_port)) + if (!br_should_become_root_port(p, root_port)) + continue; + + if (p->flags & BR_ROOT_BLOCK) + br_root_port_block(br, p); + else root_port = p->port_no; } |