datapath: remove rtnl_delete_link support for older Linux
[cascardo/ovs.git] / datapath / linux / compat / dev-openvswitch.c
1 #include <linux/if_bridge.h>
2 #include <linux/netdevice.h>
3 #include <linux/version.h>
4 #include <net/rtnetlink.h>
5
6 #include "gso.h"
7 #include "vport.h"
8 #include "vport-internal_dev.h"
9 #include "vport-netdev.h"
10
11 #ifndef HAVE_DEV_DISABLE_LRO
12
13 #ifdef NETIF_F_LRO
14 #include <linux/ethtool.h>
15
16 /**
17  *      dev_disable_lro - disable Large Receive Offload on a device
18  *      @dev: device
19  *
20  *      Disable Large Receive Offload (LRO) on a net device.  Must be
21  *      called under RTNL.  This is needed if received packets may be
22  *      forwarded to another interface.
23  */
24 void dev_disable_lro(struct net_device *dev)
25 {
26         if (dev->ethtool_ops && dev->ethtool_ops->get_flags &&
27             dev->ethtool_ops->set_flags) {
28                 u32 flags = dev->ethtool_ops->get_flags(dev);
29                 if (flags & ETH_FLAG_LRO) {
30                         flags &= ~ETH_FLAG_LRO;
31                         dev->ethtool_ops->set_flags(dev, flags);
32                 }
33         }
34         WARN_ON(dev->features & NETIF_F_LRO);
35 }
36 #else
37 void dev_disable_lro(struct net_device *dev) { }
38 #endif /* NETIF_F_LRO */
39
40 #endif /* HAVE_DEV_DISABLE_LRO */
41
42 int rpl_rtnl_delete_link(struct net_device *dev)
43 {
44         const struct rtnl_link_ops *ops;
45         LIST_HEAD(list_kill);
46
47         ops = dev->rtnl_link_ops;
48         if (!ops || !ops->dellink)
49                 return -EOPNOTSUPP;
50
51         ops->dellink(dev, &list_kill);
52         unregister_netdevice_many(&list_kill);
53
54         return 0;
55 }
56
57 #ifndef USE_UPSTREAM_TUNNEL
58 int ovs_dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
59 {
60         struct ip_tunnel_info *info;
61         struct vport *vport;
62
63         if (!SKB_SETUP_FILL_METADATA_DST(skb))
64                 return -ENOMEM;
65
66         vport = ovs_netdev_get_vport(dev);
67         if (!vport)
68                 return -EINVAL;
69
70         if (!vport->ops->fill_metadata_dst)
71                 return -EINVAL;
72
73         info = skb_tunnel_info(skb);
74         if (!info)
75                 return -ENOMEM;
76         if (unlikely(!(info->mode & IP_TUNNEL_INFO_TX)))
77                 return -EINVAL;
78
79         return vport->ops->fill_metadata_dst(dev, skb);
80 }
81 EXPORT_SYMBOL_GPL(ovs_dev_fill_metadata_dst);
82 #endif