* [PATCH net-next] macvlan: use the right RCU api
@ 2013-03-30 20:08 Eric Dumazet
2013-03-30 21:32 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2013-03-30 20:08 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
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>
---
drivers/net/macvlan.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 73abbc1..70af6dc 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -46,9 +46,16 @@ struct macvlan_port {
static void macvlan_port_destroy(struct net_device *dev);
-#define macvlan_port_get_rcu(dev) \
- ((struct macvlan_port *) rcu_dereference(dev->rx_handler_data))
-#define macvlan_port_get(dev) ((struct macvlan_port *) dev->rx_handler_data)
+static struct macvlan_port *macvlan_port_get_rcu(const struct net_device *dev)
+{
+ return rcu_dereference(dev->rx_handler_data);
+}
+
+static struct macvlan_port *macvlan_port_get_rtnl(const struct net_device *dev)
+{
+ return rtnl_dereference(dev->rx_handler_data);
+}
+
#define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT)
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)
static void macvlan_port_destroy(struct net_device *dev)
{
- struct macvlan_port *port = macvlan_port_get(dev);
+ struct macvlan_port *port = macvlan_port_get_rtnl(dev);
dev->priv_flags &= ~IFF_MACVLAN_PORT;
netdev_rx_handler_unregister(dev);
@@ -772,7 +779,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
if (err < 0)
return err;
}
- port = macvlan_port_get(lowerdev);
+ port = macvlan_port_get_rtnl(lowerdev);
/* Only 1 macvlan device can be created in passthru mode */
if (port->passthru)
@@ -921,7 +928,7 @@ static int macvlan_device_event(struct notifier_block *unused,
if (!macvlan_port_exists(dev))
return NOTIFY_DONE;
- port = macvlan_port_get(dev);
+ port = macvlan_port_get_rtnl(dev);
switch (event) {
case NETDEV_CHANGE:
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] macvlan: use the right RCU api
2013-03-30 20:08 [PATCH net-next] macvlan: use the right RCU api Eric Dumazet
@ 2013-03-30 21:32 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-03-30 21:32 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 30 Mar 2013 13:08:44 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> 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>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-30 21:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-30 20:08 [PATCH net-next] macvlan: use the right RCU api Eric Dumazet
2013-03-30 21:32 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).