Commit e9f3a685 authored by David S. Miller's avatar David S. Miller

Merge branch 'rxbusy'

Mahesh Bandewar says:

====================
use netdev_is_rx_handler_busy() in few known cases

netdev_rx_handler_register() was recently split into two parts - (a) check
if the handler is used, (b) register the new handler, parts. This is
helpful in scenarios like bonding where at the time of registration there
is too much state to unwind and it should check if the device is free
before building that state. IPvlan and macvlan drivers don't have this
issue however it can make use of the same check instead of using a device
specific check.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 264b87fa 322dc6e0
...@@ -102,8 +102,8 @@ static int ipvlan_port_create(struct net_device *dev) ...@@ -102,8 +102,8 @@ static int ipvlan_port_create(struct net_device *dev)
return -EINVAL; return -EINVAL;
} }
if (netif_is_macvlan_port(dev)) { if (netdev_is_rx_handler_busy(dev)) {
netdev_err(dev, "Master is a macvlan port.\n"); netdev_err(dev, "Device is already in use.\n");
return -EBUSY; return -EBUSY;
} }
......
...@@ -1110,7 +1110,7 @@ static int macvlan_port_create(struct net_device *dev) ...@@ -1110,7 +1110,7 @@ static int macvlan_port_create(struct net_device *dev)
if (dev->type != ARPHRD_ETHER || dev->flags & IFF_LOOPBACK) if (dev->type != ARPHRD_ETHER || dev->flags & IFF_LOOPBACK)
return -EINVAL; return -EINVAL;
if (netif_is_ipvlan_port(dev)) if (netdev_is_rx_handler_busy(dev))
return -EBUSY; return -EBUSY;
port = kzalloc(sizeof(*port), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL);
......
...@@ -3961,9 +3961,7 @@ int netdev_rx_handler_register(struct net_device *dev, ...@@ -3961,9 +3961,7 @@ int netdev_rx_handler_register(struct net_device *dev,
rx_handler_func_t *rx_handler, rx_handler_func_t *rx_handler,
void *rx_handler_data) void *rx_handler_data)
{ {
ASSERT_RTNL(); if (netdev_is_rx_handler_busy(dev))
if (dev->rx_handler)
return -EBUSY; return -EBUSY;
/* Note: rx_handler_data must be set before rx_handler */ /* Note: rx_handler_data must be set before rx_handler */
......
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