Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5d5e8d5 authored by Haishuang Yan's avatar Haishuang Yan Committed by David S. Miller
Browse files

geneve: fix max_mtu setting



For ipv6+udp+geneve encapsulation data, the max_mtu should subtract
sizeof(ipv6hdr), instead of sizeof(iphdr).

Signed-off-by: default avatarHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b291c418
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -1072,12 +1072,17 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)


static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)
static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)
{
{
	struct geneve_dev *geneve = netdev_priv(dev);
	/* The max_mtu calculation does not take account of GENEVE
	/* The max_mtu calculation does not take account of GENEVE
	 * options, to avoid excluding potentially valid
	 * options, to avoid excluding potentially valid
	 * configurations.
	 * configurations.
	 */
	 */
	int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr)
	int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - dev->hard_header_len;
		- dev->hard_header_len;

	if (geneve->remote.sa.sa_family == AF_INET6)
		max_mtu -= sizeof(struct ipv6hdr);
	else
		max_mtu -= sizeof(struct iphdr);


	if (new_mtu < 68)
	if (new_mtu < 68)
		return -EINVAL;
		return -EINVAL;