Commit eeaf61d8 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

bridge: add rcu_read_lock on transmit

Long ago, when bridge was converted to RCU, rcu lock was equivalent
to having preempt disabled. RCU has changed a lot since then and
bridge code was still assuming the since transmit was called with
bottom half disabled, it was RCU safe.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Tested-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff847ac2
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "br_private.h" #include "br_private.h"
/* net device transmit always called with no BH (preempt_disabled) */ /* net device transmit always called with BH disabled */
netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct net_bridge *br = netdev_priv(dev); struct net_bridge *br = netdev_priv(dev);
...@@ -46,6 +46,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -46,6 +46,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb_pull(skb, ETH_HLEN); skb_pull(skb, ETH_HLEN);
rcu_read_lock();
if (is_multicast_ether_addr(dest)) { if (is_multicast_ether_addr(dest)) {
if (br_multicast_rcv(br, NULL, skb)) if (br_multicast_rcv(br, NULL, skb))
goto out; goto out;
...@@ -61,6 +62,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -61,6 +62,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
br_flood_deliver(br, skb); br_flood_deliver(br, skb);
out: out:
rcu_read_unlock();
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
......
...@@ -214,7 +214,7 @@ void br_fdb_delete_by_port(struct net_bridge *br, ...@@ -214,7 +214,7 @@ void br_fdb_delete_by_port(struct net_bridge *br,
spin_unlock_bh(&br->hash_lock); spin_unlock_bh(&br->hash_lock);
} }
/* No locking or refcounting, assumes caller has no preempt (rcu_read_lock) */ /* No locking or refcounting, assumes caller has rcu_read_lock */
struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br, struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
const unsigned char *addr) const unsigned char *addr)
{ {
......
...@@ -37,7 +37,7 @@ static int br_pass_frame_up(struct sk_buff *skb) ...@@ -37,7 +37,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
netif_receive_skb); netif_receive_skb);
} }
/* note: already called with rcu_read_lock (preempt_disabled) */ /* note: already called with rcu_read_lock */
int br_handle_frame_finish(struct sk_buff *skb) int br_handle_frame_finish(struct sk_buff *skb)
{ {
const unsigned char *dest = eth_hdr(skb)->h_dest; const unsigned char *dest = eth_hdr(skb)->h_dest;
...@@ -108,7 +108,7 @@ int br_handle_frame_finish(struct sk_buff *skb) ...@@ -108,7 +108,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
goto out; goto out;
} }
/* note: already called with rcu_read_lock (preempt_disabled) */ /* note: already called with rcu_read_lock */
static int br_handle_local_finish(struct sk_buff *skb) static int br_handle_local_finish(struct sk_buff *skb)
{ {
struct net_bridge_port *p = rcu_dereference(skb->dev->br_port); struct net_bridge_port *p = rcu_dereference(skb->dev->br_port);
...@@ -133,7 +133,7 @@ static inline int is_link_local(const unsigned char *dest) ...@@ -133,7 +133,7 @@ static inline int is_link_local(const unsigned char *dest)
/* /*
* Called via br_handle_frame_hook. * Called via br_handle_frame_hook.
* Return NULL if skb is handled * Return NULL if skb is handled
* note: already called with rcu_read_lock (preempt_disabled) * note: already called with rcu_read_lock
*/ */
struct sk_buff *br_handle_frame(struct net_bridge_port *p, struct sk_buff *skb) struct sk_buff *br_handle_frame(struct net_bridge_port *p, struct sk_buff *skb)
{ {
......
...@@ -131,7 +131,7 @@ void br_send_tcn_bpdu(struct net_bridge_port *p) ...@@ -131,7 +131,7 @@ void br_send_tcn_bpdu(struct net_bridge_port *p)
/* /*
* Called from llc. * Called from llc.
* *
* NO locks, but rcu_read_lock (preempt_disabled) * NO locks, but rcu_read_lock
*/ */
void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb, void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment