diff options
author | Jiri Pirko <jiri@resnulli.us> | 2012-12-27 23:49:37 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-28 15:24:18 -0800 |
commit | 4bf84c35c65f36a344fb7a6cde6274df4120efb8 (patch) | |
tree | 09f7e45f4db6dc8fefd2910286aa3b0fcc5d50c2 /net | |
parent | b5a05550b76fe5b934b6f3b7f4b36ae9513745f6 (diff) |
net: add change_carrier netdev op
This allows a driver to register change_carrier callback which will be
called whenever user will like to change carrier state. This is useful
for devices like dummy, gre, team and so on.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 515473ee52cb..21c5b976dcf3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5027,6 +5027,25 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) } EXPORT_SYMBOL(dev_set_mac_address); +/** + * dev_change_carrier - Change device carrier + * @dev: device + * @new_carries: new value + * + * Change device carrier + */ +int dev_change_carrier(struct net_device *dev, bool new_carrier) +{ + const struct net_device_ops *ops = dev->netdev_ops; + + if (!ops->ndo_change_carrier) + return -EOPNOTSUPP; + if (!netif_device_present(dev)) + return -ENODEV; + return ops->ndo_change_carrier(dev, new_carrier); +} +EXPORT_SYMBOL(dev_change_carrier); + /* * Perform the SIOCxIFxxx calls, inside rcu_read_lock() */ |