2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00
Files
openvswitch/datapath/linux/compat/dev-openvswitch.c
Pravin B Shelar aad7cb91ef datapath: compat: Refactor egress tunnel info
upstream tunnel egress info is retrieved using ndo_fill_metadata_dst.
Since we do not have it on older kernel we need to keep vport operation
to do same on these kernels.
Following patch try to merge these to operations into one to avoid code
duplication.
This commit backports fc4099f1 ("openvswitch:
Fix egress tunnel info.")

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
2016-07-08 19:27:48 -07:00

89 lines
1.9 KiB
C

#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