PATCH: 2.4.37.9 MTU change for TUN/TAP interfaces

From: Sylvain Rochet
Date: Wed Apr 07 2010 - 16:26:54 EST


Hi,

This patch add the ability to change the MTU of TUN/TAP interfaces for
the 2.4.x kernels series.

Best regards,
Sylvain
diff -Nru linux-2.4.36.6.a/drivers/net/tun.c linux-2.4.36.6.b/drivers/net/tun.c
--- linux-2.4.36.6.a/drivers/net/tun.c 2008-06-06 18:25:34.000000000 +0200
+++ linux-2.4.36.6.b/drivers/net/tun.c 2010-04-07 17:51:33.000000000 +0200
@@ -118,6 +118,17 @@
return &tun->stats;
}

+#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;
+}
+
+
/* Initialize net device. */
int tun_net_init(struct net_device *dev)
{
@@ -156,6 +167,7 @@
break;
};

+ dev->change_mtu = tun_net_change_mtu;
return 0;
}

Attachment: signature.asc
Description: Digital signature