diff options
author | stephen hemminger <shemminger@vyatta.com> | 2010-11-15 01:38:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-15 14:13:17 -0500 |
commit | b5ed54e94d324f17c97852296d61a143f01b227a (patch) | |
tree | 2104d3cde24efc1145bc71beb4b61d79ed841132 /net/bridge/br_private.h | |
parent | 61391cde9eefac5cfcf6d214aa80c77e58b1626b (diff) |
bridge: fix RCU races with bridge port
The macro br_port_exists() is not enough protection when only
RCU is being used. There is a tiny race where other CPU has cleared port
handler hook, but is bridge port flag might still be set.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_private.h')
-rw-r--r-- | net/bridge/br_private.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index b862071bf601..46e0bec1d7c5 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -151,11 +151,19 @@ struct net_bridge_port | |||
151 | #endif | 151 | #endif |
152 | }; | 152 | }; |
153 | 153 | ||
154 | #define br_port_get_rcu(dev) \ | ||
155 | ((struct net_bridge_port *) rcu_dereference(dev->rx_handler_data)) | ||
156 | #define br_port_get(dev) ((struct net_bridge_port *) dev->rx_handler_data) | ||
157 | #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) | 154 | #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) |
158 | 155 | ||
156 | static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev) | ||
157 | { | ||
158 | struct net_bridge_port *port = rcu_dereference(dev->rx_handler_data); | ||
159 | return br_port_exists(dev) ? port : NULL; | ||
160 | } | ||
161 | |||
162 | static inline struct net_bridge_port *br_port_get(struct net_device *dev) | ||
163 | { | ||
164 | return br_port_exists(dev) ? dev->rx_handler_data : NULL; | ||
165 | } | ||
166 | |||
159 | struct br_cpu_netstats { | 167 | struct br_cpu_netstats { |
160 | u64 rx_packets; | 168 | u64 rx_packets; |
161 | u64 rx_bytes; | 169 | u64 rx_bytes; |