net: dev: add generic protodown handler
authorAndy Roulin <aroulin@cumulusnetworks.com>
Fri, 22 Feb 2019 18:06:36 +0000 (18:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Feb 2019 21:01:04 +0000 (13:01 -0800)
Introduce dev_change_proto_down_generic, a generic ndo_change_proto_down
implementation, which sets the netdev carrier state according to proto_down.

This adds the ability to set protodown on vxlan and macvlan devices in a
generic way for use by control protocols like VRRPD.

Signed-off-by: Andy Roulin <aroulin@cumulusnetworks.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c

index 6997f62cb6a0729be86c0c1c2e6f6f4e534636f3..ffbddd03242bec627f00508ba300d6b9253c35cf 100644 (file)
@@ -3673,6 +3673,7 @@ int dev_get_port_parent_id(struct net_device *dev,
                           struct netdev_phys_item_id *ppid, bool recurse);
 bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
 int dev_change_proto_down(struct net_device *dev, bool proto_down);
+int dev_change_proto_down_generic(struct net_device *dev, bool proto_down);
 struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again);
 struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
                                    struct netdev_queue *txq, int *ret);
index 8a0da95ff4ccbf47487de6e8e566a21f2ba94ad1..2b67f2aa59ddb64d27378bed44f9d262093219e0 100644 (file)
@@ -7954,6 +7954,25 @@ int dev_change_proto_down(struct net_device *dev, bool proto_down)
 }
 EXPORT_SYMBOL(dev_change_proto_down);
 
+/**
+ *     dev_change_proto_down_generic - generic implementation for
+ *     ndo_change_proto_down that sets carrier according to
+ *     proto_down.
+ *
+ *     @dev: device
+ *     @proto_down: new value
+ */
+int dev_change_proto_down_generic(struct net_device *dev, bool proto_down)
+{
+       if (proto_down)
+               netif_carrier_off(dev);
+       else
+               netif_carrier_on(dev);
+       dev->proto_down = proto_down;
+       return 0;
+}
+EXPORT_SYMBOL(dev_change_proto_down_generic);
+
 u32 __dev_xdp_query(struct net_device *dev, bpf_op_t bpf_op,
                    enum bpf_netdev_command cmd)
 {