netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Wragg <david-1SEAoVOfG6VEzL6FDj/jAg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org
Cc: David Wragg <david-1SEAoVOfG6VEzL6FDj/jAg@public.gmane.org>,
	Tom Herbert <tom-BjP2VixgY4xUbtYUoyoikg@public.gmane.org>
Subject: [PATCH net] geneve: Refine MTU limit
Date: Tue, 16 Feb 2016 12:33:19 +0000	[thread overview]
Message-ID: <1455625999-9781-1-git-send-email-david@weave.works> (raw)

While GENEVE allows variable length options, the maximum length of the
options is 63 * 4 bytes.  So we can reasonably set an MTU limit other
than IP_MAX_MTU, as the other tunnel devices do.

Signed-off-by: David Wragg <david@weave.works>
---
 drivers/net/geneve.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 028e387..f57f9bc 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -37,6 +37,9 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
 
 #define GENEVE_VER 0
 #define GENEVE_BASE_HLEN (sizeof(struct udphdr) + sizeof(struct genevehdr))
+#define GENEVE_MAX_OPTIONS_LEN (63 * 4)
+#define GENEVE_MAX_MTU (IP_MAX_MTU - sizeof(struct iphdr) - GENEVE_BASE_HLEN \
+						- GENEVE_MAX_OPTIONS_LEN)
 
 /* per-network namespace private data for this module */
 struct geneve_net {
@@ -1041,11 +1044,9 @@ 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)
 {
-	/* GENEVE overhead is not fixed, so we can't enforce a more
-	 * precise max MTU.
-	 */
-	if (new_mtu < 68 || new_mtu > IP_MAX_MTU)
+	if (new_mtu < 68 || new_mtu > GENEVE_MAX_MTU)
 		return -EINVAL;
+
 	dev->mtu = new_mtu;
 	return 0;
 }
@@ -1459,7 +1460,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
 	/* openvswitch users expect packet sizes to be unrestricted,
 	 * so set the largest MTU we can.
 	 */
-	err = geneve_change_mtu(dev, IP_MAX_MTU);
+	err = geneve_change_mtu(dev, GENEVE_MAX_MTU);
 	if (err)
 		goto err;
 
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

             reply	other threads:[~2016-02-16 12:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 12:33 David Wragg [this message]
     [not found] ` <1455625999-9781-1-git-send-email-david-1SEAoVOfG6VEzL6FDj/jAg@public.gmane.org>
2016-02-16 18:32   ` [PATCH net] geneve: Refine MTU limit Jesse Gross
2016-02-18 16:41     ` David Wragg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455625999-9781-1-git-send-email-david@weave.works \
    --to=david-1seaovofg6vezl6fdj/jag@public.gmane.org \
    --cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tom-BjP2VixgY4xUbtYUoyoikg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).