Commit e052f7e64daae6aa7a7ccd003b3c285d99755afb

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 4c3d5e7b41

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>

Showing 1 changed file with 13 additions and 6 deletions Side-by-side Diff

drivers/net/macvlan.c
... ... @@ -46,9 +46,16 @@
46 46  
47 47 static void macvlan_port_destroy(struct net_device *dev);
48 48  
49   -#define macvlan_port_get_rcu(dev) \
50   - ((struct macvlan_port *) rcu_dereference(dev->rx_handler_data))
51   -#define macvlan_port_get(dev) ((struct macvlan_port *) dev->rx_handler_data)
  49 +static struct macvlan_port *macvlan_port_get_rcu(const struct net_device *dev)
  50 +{
  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 59 #define macvlan_port_exists(dev) (dev->priv_flags & IFF_MACVLAN_PORT)
53 60  
54 61 static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port,
... ... @@ -703,7 +710,7 @@
703 710  
704 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 715 dev->priv_flags &= ~IFF_MACVLAN_PORT;
709 716 netdev_rx_handler_unregister(dev);
... ... @@ -772,7 +779,7 @@
772 779 if (err < 0)
773 780 return err;
774 781 }
775   - port = macvlan_port_get(lowerdev);
  782 + port = macvlan_port_get_rtnl(lowerdev);
776 783  
777 784 /* Only 1 macvlan device can be created in passthru mode */
778 785 if (port->passthru)
... ... @@ -921,7 +928,7 @@
921 928 if (!macvlan_port_exists(dev))
922 929 return NOTIFY_DONE;
923 930  
924   - port = macvlan_port_get(dev);
  931 + port = macvlan_port_get_rtnl(dev);
925 932  
926 933 switch (event) {
927 934 case NETDEV_CHANGE: