Skip to content

Commit

Permalink
macvtap: Consistently use rcu functions
Browse files Browse the repository at this point in the history
Currently macvtap uses rcu_bh functions in its
user facing fuction macvtap_get_user() and macvtap_put_user().
However, its packet handlers use normal rcu as the rcu_read_lock()
is taken in netif_receive_skb().  We can safely discontinue
the usage or rcu with bh disabled.

Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Yasevich authored and davem330 committed Jun 25, 2013
1 parent 441ac0f commit ac4e4af
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,

skb_probe_transport_header(skb, ETH_HLEN);

rcu_read_lock_bh();
vlan = rcu_dereference_bh(q->vlan);
rcu_read_lock();
vlan = rcu_dereference(q->vlan);
/* copy skb_ubuf_info for callback when skb has no error */
if (zerocopy) {
skb_shinfo(skb)->destructor_arg = m->msg_control;
Expand All @@ -766,19 +766,19 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
macvlan_start_xmit(skb, vlan->dev);
else
kfree_skb(skb);
rcu_read_unlock_bh();
rcu_read_unlock();

return total_len;

err_kfree:
kfree_skb(skb);

err:
rcu_read_lock_bh();
vlan = rcu_dereference_bh(q->vlan);
rcu_read_lock();
vlan = rcu_dereference(q->vlan);
if (vlan)
vlan->dev->stats.tx_dropped++;
rcu_read_unlock_bh();
rcu_read_unlock();

return err;
}
Expand Down Expand Up @@ -854,11 +854,11 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
copied += len;

done:
rcu_read_lock_bh();
vlan = rcu_dereference_bh(q->vlan);
rcu_read_lock();
vlan = rcu_dereference(q->vlan);
if (vlan)
macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
rcu_read_unlock_bh();
rcu_read_unlock();

return ret ? ret : copied;
}
Expand Down

0 comments on commit ac4e4af

Please sign in to comment.