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

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).