Skip to content

Commit

Permalink
Merge branch 'rxbusy'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 20, 2017
2 parents 264b87f + 322dc6e commit e9f3a68
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ipvlan/ipvlan_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ static int ipvlan_port_create(struct net_device *dev)
return -EINVAL;
}

if (netif_is_macvlan_port(dev)) {
netdev_err(dev, "Master is a macvlan port.\n");
if (netdev_is_rx_handler_busy(dev)) {
netdev_err(dev, "Device is already in use.\n");
return -EBUSY;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ static int macvlan_port_create(struct net_device *dev)
if (dev->type != ARPHRD_ETHER || dev->flags & IFF_LOOPBACK)
return -EINVAL;

if (netif_is_ipvlan_port(dev))
if (netdev_is_rx_handler_busy(dev))
return -EBUSY;

port = kzalloc(sizeof(*port), GFP_KERNEL);
Expand Down
4 changes: 1 addition & 3 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3961,9 +3961,7 @@ int netdev_rx_handler_register(struct net_device *dev,
rx_handler_func_t *rx_handler,
void *rx_handler_data)
{
ASSERT_RTNL();

if (dev->rx_handler)
if (netdev_is_rx_handler_busy(dev))
return -EBUSY;

/* Note: rx_handler_data must be set before rx_handler */
Expand Down

0 comments on commit e9f3a68

Please sign in to comment.