Skip to content

Commit 3962981

Browse files
shemmingerdavem330
authored andcommitted
netvsc: add rtnl annotations in rndis
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>
1 parent 35fbbcc commit 3962981

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

drivers/net/hyperv/hyperv_net.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,6 @@ struct netvsc_device {
787787
struct rcu_head rcu;
788788
};
789789

790-
static inline struct netvsc_device *
791-
net_device_to_netvsc_device(struct net_device *ndev)
792-
{
793-
return ((struct net_device_context *)netdev_priv(ndev))->nvdev;
794-
}
795-
796790
/* NdisInitialize message */
797791
struct rndis_initialize_request {
798792
u32 req_id;

drivers/net/hyperv/netvsc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static void netvsc_destroy_buf(struct hv_device *device)
105105
{
106106
struct nvsp_message *revoke_packet;
107107
struct net_device *ndev = hv_get_drvdata(device);
108-
struct netvsc_device *net_device = net_device_to_netvsc_device(ndev);
108+
struct net_device_context *ndc = netdev_priv(ndev);
109+
struct netvsc_device *net_device = rtnl_dereference(ndc->nvdev);
109110
int ret;
110111

111112
/*
@@ -829,7 +830,8 @@ int netvsc_send(struct net_device_context *ndev_ctx,
829830
struct hv_page_buffer **pb,
830831
struct sk_buff *skb)
831832
{
832-
struct netvsc_device *net_device = rcu_dereference(ndev_ctx->nvdev);
833+
struct netvsc_device *net_device
834+
= rcu_dereference_rtnl(ndev_ctx->nvdev);
833835
struct hv_device *device = ndev_ctx->device_ctx;
834836
int ret = 0;
835837
struct netvsc_channel *nvchan;

drivers/net/hyperv/netvsc_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ static int netvsc_probe(struct hv_device *dev,
15481548

15491549
netif_set_real_num_tx_queues(net, nvdev->num_chn);
15501550
netif_set_real_num_rx_queues(net, nvdev->num_chn);
1551+
rtnl_unlock();
15511552

15521553
netdev_lockdep_set_classes(net);
15531554

drivers/net/hyperv/rndis_filter.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ static struct rndis_device *get_rndis_device(void)
8484
return device;
8585
}
8686

87+
static struct netvsc_device *
88+
net_device_to_netvsc_device(struct net_device *ndev)
89+
{
90+
struct net_device_context *net_device_ctx = netdev_priv(ndev);
91+
92+
return rtnl_dereference(net_device_ctx->nvdev);
93+
}
94+
8795
static struct rndis_request *get_rndis_request(struct rndis_device *dev,
8896
u32 msg_type,
8997
u32 msg_len)
@@ -472,7 +480,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
472480

473481
if (oid == OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES) {
474482
struct net_device_context *ndevctx = netdev_priv(dev->ndev);
475-
struct netvsc_device *nvdev = ndevctx->nvdev;
483+
struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev);
476484
struct ndis_offload *hwcaps;
477485
u32 nvsp_version = nvdev->nvsp_version;
478486
u8 ndis_rev;
@@ -944,7 +952,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
944952
struct rndis_request *request;
945953
struct rndis_halt_request *halt;
946954
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
947-
struct netvsc_device *nvdev = net_device_ctx->nvdev;
955+
struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev);
948956

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

0 commit comments

Comments
 (0)