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