netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] geneve: fix max_mtu setting
@ 2016-07-02  7:02 Haishuang Yan
  2016-07-04 21:50 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Haishuang Yan @ 2016-07-02  7:02 UTC (permalink / raw)
  To: David S. Miller, Jesse Gross, Pravin B Shelar, Tom Herbert
  Cc: netdev, linux-kernel, Haishuang Yan

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

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
Changes in v2:
   - As suggested by Jesse Gross, treat AF_UNSPEC same as AF_INET4 to
avoid disallowing potentially valid configrations.
---
 drivers/net/geneve.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 310e0b9c..5de892f 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1036,12 +1036,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)
 {
+	struct geneve_dev *geneve = netdev_priv(dev);
 	/* The max_mtu calculation does not take account of GENEVE
 	 * options, to avoid excluding potentially valid
 	 * configurations.
 	 */
-	int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr)
-		- dev->hard_header_len;
+	int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - 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)
 		return -EINVAL;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] geneve: fix max_mtu setting
  2016-07-02  7:02 [PATCH v2] geneve: fix max_mtu setting Haishuang Yan
@ 2016-07-04 21:50 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-07-04 21:50 UTC (permalink / raw)
  To: yanhaishuang; +Cc: jesse, pshelar, tom, netdev, linux-kernel

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Sat,  2 Jul 2016 15:02:48 +0800

> For ipv6+udp+geneve encapsulation data, the max_mtu should subtract
> sizeof(ipv6hdr), instead of sizeof(iphdr).
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-04 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-02  7:02 [PATCH v2] geneve: fix max_mtu setting Haishuang Yan
2016-07-04 21:50 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).