mirror of https://gitee.com/openkylin/linux.git
vxlan: Relax MTU constraints
Allow the MTU of vxlan devices without an underlying device to be set to larger values (up to a maximum based on IP packet limits and vxlan overhead). Previously, their MTUs could not be set to higher than the conventional ethernet value of 1500. This is a very arbitrary value in the context of vxlan, and prevented vxlan devices from being able to take advantage of jumbo frames etc. The default MTU remains 1500, for compatibility. Signed-off-by: David Wragg <david@weave.works> Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
461547f315
commit
72564b59ff
|
@ -2367,27 +2367,41 @@ static void vxlan_set_multicast_list(struct net_device *dev)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __vxlan_change_mtu(struct net_device *dev,
|
||||||
|
struct net_device *lowerdev,
|
||||||
|
struct vxlan_rdst *dst, int new_mtu, bool strict)
|
||||||
|
{
|
||||||
|
int max_mtu = IP_MAX_MTU;
|
||||||
|
|
||||||
|
if (lowerdev)
|
||||||
|
max_mtu = lowerdev->mtu;
|
||||||
|
|
||||||
|
if (dst->remote_ip.sa.sa_family == AF_INET6)
|
||||||
|
max_mtu -= VXLAN6_HEADROOM;
|
||||||
|
else
|
||||||
|
max_mtu -= VXLAN_HEADROOM;
|
||||||
|
|
||||||
|
if (new_mtu < 68)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (new_mtu > max_mtu) {
|
||||||
|
if (strict)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
new_mtu = max_mtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->mtu = new_mtu;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
|
static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
{
|
{
|
||||||
struct vxlan_dev *vxlan = netdev_priv(dev);
|
struct vxlan_dev *vxlan = netdev_priv(dev);
|
||||||
struct vxlan_rdst *dst = &vxlan->default_dst;
|
struct vxlan_rdst *dst = &vxlan->default_dst;
|
||||||
struct net_device *lowerdev;
|
struct net_device *lowerdev = __dev_get_by_index(vxlan->net,
|
||||||
int max_mtu;
|
dst->remote_ifindex);
|
||||||
|
return __vxlan_change_mtu(dev, lowerdev, dst, new_mtu, true);
|
||||||
lowerdev = __dev_get_by_index(vxlan->net, dst->remote_ifindex);
|
|
||||||
if (lowerdev == NULL)
|
|
||||||
return eth_change_mtu(dev, new_mtu);
|
|
||||||
|
|
||||||
if (dst->remote_ip.sa.sa_family == AF_INET6)
|
|
||||||
max_mtu = lowerdev->mtu - VXLAN6_HEADROOM;
|
|
||||||
else
|
|
||||||
max_mtu = lowerdev->mtu - VXLAN_HEADROOM;
|
|
||||||
|
|
||||||
if (new_mtu < 68 || new_mtu > max_mtu)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
dev->mtu = new_mtu;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
|
static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
|
||||||
|
|
Loading…
Reference in New Issue