Commit e052f7e6 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4c3d5e7b
...@@ -46,9 +46,16 @@ struct macvlan_port { ...@@ -46,9 +46,16 @@ struct macvlan_port {
static void macvlan_port_destroy(struct net_device *dev); static void macvlan_port_destroy(struct net_device *dev);
#define macvlan_port_get_rcu(dev) \ static struct macvlan_port *macvlan_port_get_rcu(const struct net_device *dev)
((struct macvlan_port *) rcu_dereference(dev->rx_handler_data)) {
#define macvlan_port_get(dev) ((struct macvlan_port *) dev->rx_handler_data) 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) #define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT)
static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *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) ...@@ -703,7 +710,7 @@ static int macvlan_port_create(struct net_device *dev)
static void macvlan_port_destroy(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; dev->priv_flags &= ~IFF_MACVLAN_PORT;
netdev_rx_handler_unregister(dev); netdev_rx_handler_unregister(dev);
...@@ -772,7 +779,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, ...@@ -772,7 +779,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
if (err < 0) if (err < 0)
return err; return err;
} }
port = macvlan_port_get(lowerdev); port = macvlan_port_get_rtnl(lowerdev);
/* Only 1 macvlan device can be created in passthru mode */ /* Only 1 macvlan device can be created in passthru mode */
if (port->passthru) if (port->passthru)
...@@ -921,7 +928,7 @@ static int macvlan_device_event(struct notifier_block *unused, ...@@ -921,7 +928,7 @@ static int macvlan_device_event(struct notifier_block *unused,
if (!macvlan_port_exists(dev)) if (!macvlan_port_exists(dev))
return NOTIFY_DONE; return NOTIFY_DONE;
port = macvlan_port_get(dev); port = macvlan_port_get_rtnl(dev);
switch (event) { switch (event) {
case NETDEV_CHANGE: case NETDEV_CHANGE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment