netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Configurable tap interface MTU
@ 2007-09-11 14:42 Ed Swierk
  2007-09-11 17:20 ` Rick Jones
  2007-09-12  3:29 ` Herbert Xu
  0 siblings, 2 replies; 5+ messages in thread
From: Ed Swierk @ 2007-09-11 14:42 UTC (permalink / raw)
  To: netdev, maxk; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

This patch makes it possible to change the MTU on a tap interface.
Increasing the MTU beyond the 1500-byte default is useful for
applications that interoperate with Ethernet devices supporting jumbo
frames.

The patch caps the MTU somewhat arbitrarily at 16000 bytes. This is
slightly lower than the value used by the e1000 driver, so it seems
like a safe upper limit.

Signed-off-by: Ed Swierk <eswierk@arastra.com>

---

[-- Attachment #2: tap-change-mtu.patch --]
[-- Type: application/octet-stream, Size: 931 bytes --]

Index: linux-2.6.22.6/drivers/net/tun.c
===================================================================
--- linux-2.6.22.6.orig/drivers/net/tun.c
+++ linux-2.6.22.6/drivers/net/tun.c
@@ -171,6 +171,18 @@ tun_net_mclist(struct net_device *dev)
 	}
 }
 
+#define MIN_MTU 68
+#define MAX_MTU 16000
+
+static int
+tun_net_change_mtu(struct net_device *dev, int new_mtu)
+{
+	if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return 0;
+}
+
 static struct net_device_stats *tun_net_stats(struct net_device *dev)
 {
 	struct tun_struct *tun = netdev_priv(dev);
@@ -200,6 +212,7 @@ static void tun_net_init(struct net_devi
 		dev->set_multicast_list = tun_net_mclist;
 
 		ether_setup(dev);
+		dev->change_mtu = tun_net_change_mtu;
 
 		/* random address already created for us by tun_set_iff, use it */
 		memcpy(dev->dev_addr, tun->dev_addr, min(sizeof(tun->dev_addr), sizeof(dev->dev_addr)) );

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

* Re: [PATCH] Configurable tap interface MTU
  2007-09-11 14:42 [PATCH] Configurable tap interface MTU Ed Swierk
@ 2007-09-11 17:20 ` Rick Jones
  2007-09-12  3:29 ` Herbert Xu
  1 sibling, 0 replies; 5+ messages in thread
From: Rick Jones @ 2007-09-11 17:20 UTC (permalink / raw)
  To: Ed Swierk; +Cc: netdev, maxk, linux-kernel

Ed Swierk wrote:
> This patch makes it possible to change the MTU on a tap interface.
> Increasing the MTU beyond the 1500-byte default is useful for
> applications that interoperate with Ethernet devices supporting jumbo
> frames.
> 
> The patch caps the MTU somewhat arbitrarily at 16000 bytes. This is
> slightly lower than the value used by the e1000 driver, so it seems
> like a safe upper limit.

FWIW the OFED 1.2 bits take the MTU of IPoIB up to 65520 bytes :)

rick jones

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

* Re: [PATCH] Configurable tap interface MTU
  2007-09-11 14:42 [PATCH] Configurable tap interface MTU Ed Swierk
  2007-09-11 17:20 ` Rick Jones
@ 2007-09-12  3:29 ` Herbert Xu
  2007-09-12 16:54   ` Ed Swierk
  1 sibling, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2007-09-12  3:29 UTC (permalink / raw)
  To: Ed Swierk; +Cc: netdev, maxk, linux-kernel

Ed Swierk <eswierk@arastra.com> wrote:
> 
> The patch caps the MTU somewhat arbitrarily at 16000 bytes. This is
> slightly lower than the value used by the e1000 driver, so it seems
> like a safe upper limit.

Please make it 65535 without an Ethernet header and 65521
with an Ethernet header.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] Configurable tap interface MTU
  2007-09-12  3:29 ` Herbert Xu
@ 2007-09-12 16:54   ` Ed Swierk
  2007-09-16 19:22     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Ed Swierk @ 2007-09-12 16:54 UTC (permalink / raw)
  To: Herbert Xu, netdev, maxk, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 404 bytes --]

On 9/11/07, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Please make it 65535 without an Ethernet header and 65521
> with an Ethernet header.

Here is a revised patch that allows MTUs up to 65535 for tap
interfaces and up to 65521 for tun interfaces.

(If I set the MTU to 65521 on a tun interface, ping complains "message
too long" when I send a 65521-byte packet; 65520 works okay, though.)

--Ed

[-- Attachment #2: tap-change-mtu.patch --]
[-- Type: application/octet-stream, Size: 1185 bytes --]

Index: linux-2.6.22.6/drivers/net/tun.c
===================================================================
--- linux-2.6.22.6.orig/drivers/net/tun.c
+++ linux-2.6.22.6/drivers/net/tun.c
@@ -171,6 +171,18 @@ tun_net_mclist(struct net_device *dev)
 	}
 }
 
+#define MIN_MTU 68
+#define MAX_MTU 65535
+
+static int
+tun_net_change_mtu(struct net_device *dev, int new_mtu)
+{
+	if (new_mtu < MIN_MTU || new_mtu + dev->hard_header_len > MAX_MTU)
+		return -EINVAL;
+	dev->mtu = new_mtu;
+	return 0;
+}
+
 static struct net_device_stats *tun_net_stats(struct net_device *dev)
 {
 	struct tun_struct *tun = netdev_priv(dev);
@@ -188,6 +200,7 @@ static void tun_net_init(struct net_devi
 		dev->hard_header_len = 0;
 		dev->addr_len = 0;
 		dev->mtu = 1500;
+		dev->change_mtu = tun_net_change_mtu;
 
 		/* Zero header length */
 		dev->type = ARPHRD_NONE;
@@ -200,6 +213,7 @@ static void tun_net_init(struct net_devi
 		dev->set_multicast_list = tun_net_mclist;
 
 		ether_setup(dev);
+		dev->change_mtu = tun_net_change_mtu;
 
 		/* random address already created for us by tun_set_iff, use it */
 		memcpy(dev->dev_addr, tun->dev_addr, min(sizeof(tun->dev_addr), sizeof(dev->dev_addr)) );

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

* Re: [PATCH] Configurable tap interface MTU
  2007-09-12 16:54   ` Ed Swierk
@ 2007-09-16 19:22     ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2007-09-16 19:22 UTC (permalink / raw)
  To: eswierk; +Cc: herbert, netdev, maxk, linux-kernel

From: "Ed Swierk" <eswierk@arastra.com>
Date: Wed, 12 Sep 2007 09:54:35 -0700

> On 9/11/07, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> > Please make it 65535 without an Ethernet header and 65521
> > with an Ethernet header.
> 
> Here is a revised patch that allows MTUs up to 65535 for tap
> interfaces and up to 65521 for tun interfaces.
> 
> (If I set the MTU to 65521 on a tun interface, ping complains "message
> too long" when I send a 65521-byte packet; 65520 works okay, though.)

Applied to net-2.6.24

Please provide a proper Signed-off-by: line and a full
changelog with every patch submission and revision in
the future.

Thanks.


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

end of thread, other threads:[~2007-09-16 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-11 14:42 [PATCH] Configurable tap interface MTU Ed Swierk
2007-09-11 17:20 ` Rick Jones
2007-09-12  3:29 ` Herbert Xu
2007-09-12 16:54   ` Ed Swierk
2007-09-16 19:22     ` 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).