]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
netvsc: add rtnl annotations in rndis
authorstephen hemminger <stephen@networkplumber.org>
Wed, 19 Jul 2017 18:53:19 +0000 (11:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Jul 2017 05:20:05 +0000 (22:20 -0700)
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>
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/hyperv/rndis_filter.c

index d13572879e7e734a3c1e305821ca60afb16e97bc..afb65f753574483abcfc58cb63cf7cf4b5971920 100644 (file)
@@ -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;
index c15640c6fd837de47f5a0ead9ff6da00c5d5ed82..0a9d9feedc3f4d6e31cdfe80cee3f9aa3d4f078a 100644 (file)
@@ -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;
 
        /*
@@ -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;
index 1238600d717e34ebe99ae47d88aa929fb4313319..a164981c15f7a261eccbb29e85edf8d1c6c07309 100644 (file)
@@ -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);
 
index 9ab67c8309ff2098b6918f8d4390051f2eae6642..e439886f72c11613ccd9ea21a9c8db16bd4b3f8b 100644 (file)
@@ -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)
@@ -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;
@@ -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,