dataoath: compat: Do not use upstream fill-meta-data function for compat tunnel
[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
46         ops = dev->rtnl_link_ops;
47         if (!ops || !ops->dellink)
48                 return -EOPNOTSUPP;
49
50 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
51         ops->dellink(dev);
52 #else
53         {
54                 LIST_HEAD(list_kill);
55
56                 ops->dellink(dev, &list_kill);
57                 unregister_netdevice_many(&list_kill);
58         }
59 #endif
60         return 0;
61 }
62
63 #ifndef USE_UPSTREAM_TUNNEL
64 int ovs_dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
65 {
66         struct ip_tunnel_info *info;
67         struct vport *vport;
68
69         if (!SKB_SETUP_FILL_METADATA_DST(skb))
70                 return -ENOMEM;
71
72         vport = ovs_netdev_get_vport(dev);
73         if (!vport)
74                 return -EINVAL;
75
76         if (!vport->ops->fill_metadata_dst)
77                 return -EINVAL;
78
79         info = skb_tunnel_info(skb);
80         if (!info)
81                 return -ENOMEM;
82         if (unlikely(!(info->mode & IP_TUNNEL_INFO_TX)))
83                 return -EINVAL;
84
85         return vport->ops->fill_metadata_dst(dev, skb);
86 }
87 EXPORT_SYMBOL_GPL(ovs_dev_fill_metadata_dst);
88 #endif