diff options
author | Eric Dumazet <edumazet@google.com> | 2013-03-30 06:08:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-30 17:31:25 -0400 |
commit | e052f7e64daae6aa7a7ccd003b3c285d99755afb (patch) | |
tree | 4c8b157b5038d77c47ebf58c1dabf8d2915642cd /drivers/net/macvlan.c | |
parent | 4c3d5e7b41dda1b1372bfc2545ef092a1bc5ad33 (diff) |
macvlan: use the right RCU api
Make sure we use proper API to fetch dev->rx_handler_data,
instead of ugly casts.
Rename macvlan_port_get() to macvlan_port_get_rtnl() to document fact
that we hold RTNL when needed, with lockdep support.
This removes sparse warnings as well (CONFIG_SPARSE_RCU_POINTER=y)
CHECK drivers/net/macvlan.c
drivers/net/macvlan.c:706:37: warning: cast removes address space of expression
drivers/net/macvlan.c:775:16: warning: cast removes address space of expression
drivers/net/macvlan.c:924:16: warning: cast removes address space of expression
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvlan.c')
-rw-r--r-- | drivers/net/macvlan.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 73abbc1655d5..70af6dc07d40 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -46,9 +46,16 @@ struct macvlan_port { | |||
46 | 46 | ||
47 | static void macvlan_port_destroy(struct net_device *dev); | 47 | static void macvlan_port_destroy(struct net_device *dev); |
48 | 48 | ||
49 | #define macvlan_port_get_rcu(dev) \ | 49 | static struct macvlan_port *macvlan_port_get_rcu(const struct net_device *dev) |
50 | ((struct macvlan_port *) rcu_dereference(dev->rx_handler_data)) | 50 | { |
51 | #define macvlan_port_get(dev) ((struct macvlan_port *) dev->rx_handler_data) | 51 | return rcu_dereference(dev->rx_handler_data); |
52 | } | ||
53 | |||
54 | static struct macvlan_port *macvlan_port_get_rtnl(const struct net_device *dev) | ||
55 | { | ||
56 | return rtnl_dereference(dev->rx_handler_data); | ||
57 | } | ||
58 | |||
52 | #define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT) | 59 | #define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT) |
53 | 60 | ||
54 | static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port, | 61 | static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port, |
@@ -703,7 +710,7 @@ static int macvlan_port_create(struct net_device *dev) | |||
703 | 710 | ||
704 | static void macvlan_port_destroy(struct net_device *dev) | 711 | static void macvlan_port_destroy(struct net_device *dev) |
705 | { | 712 | { |
706 | struct macvlan_port *port = macvlan_port_get(dev); | 713 | struct macvlan_port *port = macvlan_port_get_rtnl(dev); |
707 | 714 | ||
708 | dev->priv_flags &= ~IFF_MACVLAN_PORT; | 715 | dev->priv_flags &= ~IFF_MACVLAN_PORT; |
709 | netdev_rx_handler_unregister(dev); | 716 | netdev_rx_handler_unregister(dev); |
@@ -772,7 +779,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, | |||
772 | if (err < 0) | 779 | if (err < 0) |
773 | return err; | 780 | return err; |
774 | } | 781 | } |
775 | port = macvlan_port_get(lowerdev); | 782 | port = macvlan_port_get_rtnl(lowerdev); |
776 | 783 | ||
777 | /* Only 1 macvlan device can be created in passthru mode */ | 784 | /* Only 1 macvlan device can be created in passthru mode */ |
778 | if (port->passthru) | 785 | if (port->passthru) |
@@ -921,7 +928,7 @@ static int macvlan_device_event(struct notifier_block *unused, | |||
921 | if (!macvlan_port_exists(dev)) | 928 | if (!macvlan_port_exists(dev)) |
922 | return NOTIFY_DONE; | 929 | return NOTIFY_DONE; |
923 | 930 | ||
924 | port = macvlan_port_get(dev); | 931 | port = macvlan_port_get_rtnl(dev); |
925 | 932 | ||
926 | switch (event) { | 933 | switch (event) { |
927 | case NETDEV_CHANGE: | 934 | case NETDEV_CHANGE: |