Skip to contentSkip to conversation

PATCH: 2.4.37.9 MTU change for TUN/TAP interfaces

PATCH Sylvain Rochet 2 participants 2 messages Apr 7, 2010 – Apr 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

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

Best regards,
Sylvain

drivers/net/tun.c +12 -0
diff -Nru linux-2.4.36.6.a/drivers/net/tun.c linux-2.4.36.6.b/drivers/net/tun.c
@@ -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;
 }
 
#1 lore raw

Hello Sylvain,

Quoted 4 lines · Sylvain Rochet

Hi,

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

I never noticed it was not possible to change the MTU on TUN devices, and you seem to be the first one to report it !

Well, considering that 2.6 already supports this and that the change is obvious, I'm OK to merge it.

Thanks,
Willy