Skip to content

Commit

Permalink
netvsc: add rtnl annotations in rndis
Browse files Browse the repository at this point in the history
The rndis functions are used when changing device state.
Therefore the references from network device to internal state
are protected by RTNL mutex.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Jul 20, 2017
1 parent 35fbbcc commit 3962981
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
6 changes: 0 additions & 6 deletions drivers/net/hyperv/hyperv_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,6 @@ struct netvsc_device {
struct rcu_head rcu;
};

static inline struct netvsc_device *
net_device_to_netvsc_device(struct net_device *ndev)
{
return ((struct net_device_context *)netdev_priv(ndev))->nvdev;
}

/* NdisInitialize message */
struct rndis_initialize_request {
u32 req_id;
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/hyperv/netvsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ static void netvsc_destroy_buf(struct hv_device *device)
{
struct nvsp_message *revoke_packet;
struct net_device *ndev = hv_get_drvdata(device);
struct netvsc_device *net_device = net_device_to_netvsc_device(ndev);
struct net_device_context *ndc = netdev_priv(ndev);
struct netvsc_device *net_device = rtnl_dereference(ndc->nvdev);
int ret;

/*
Expand Down Expand Up @@ -829,7 +830,8 @@ int netvsc_send(struct net_device_context *ndev_ctx,
struct hv_page_buffer **pb,
struct sk_buff *skb)
{
struct netvsc_device *net_device = rcu_dereference(ndev_ctx->nvdev);
struct netvsc_device *net_device
= rcu_dereference_rtnl(ndev_ctx->nvdev);
struct hv_device *device = ndev_ctx->device_ctx;
int ret = 0;
struct netvsc_channel *nvchan;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/hyperv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,7 @@ static int netvsc_probe(struct hv_device *dev,

netif_set_real_num_tx_queues(net, nvdev->num_chn);
netif_set_real_num_rx_queues(net, nvdev->num_chn);
rtnl_unlock();

netdev_lockdep_set_classes(net);

Expand Down
12 changes: 10 additions & 2 deletions drivers/net/hyperv/rndis_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ static struct rndis_device *get_rndis_device(void)
return device;
}

static struct netvsc_device *
net_device_to_netvsc_device(struct net_device *ndev)
{
struct net_device_context *net_device_ctx = netdev_priv(ndev);

return rtnl_dereference(net_device_ctx->nvdev);
}

static struct rndis_request *get_rndis_request(struct rndis_device *dev,
u32 msg_type,
u32 msg_len)
Expand Down Expand Up @@ -472,7 +480,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,

if (oid == OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES) {
struct net_device_context *ndevctx = netdev_priv(dev->ndev);
struct netvsc_device *nvdev = ndevctx->nvdev;
struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
struct ndis_offload *hwcaps;
u32 nvsp_version = nvdev->nvsp_version;
u8 ndis_rev;
Expand Down Expand Up @@ -944,7 +952,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
struct rndis_request *request;
struct rndis_halt_request *halt;
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);

/* Attempt to do a rndis device halt */
request = get_rndis_request(dev, RNDIS_MSG_HALT,
Expand Down

0 comments on commit 3962981

Please sign in to comment.