summaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorEd Swierk <eswierk@arastra.com>2007-09-16 21:21:38 +0200
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-11 01:51:19 +0200
commit4885a50476b95fa0f4caad179a80783508c2fe86 (patch)
tree55a5b007e593e8ee810e142517854a42b23af6fe /drivers/net/tun.c
parent[IPV6]: Remove redundant RTM_DELLINK message. (diff)
downloadlinux-4885a50476b95fa0f4caad179a80783508c2fe86.tar.xz
linux-4885a50476b95fa0f4caad179a80783508c2fe86.zip
[TAP]: Configurable interface MTU.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--drivers/net/tun.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d279151f065d..d8b8e68ef70b 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -172,6 +172,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;
+}
+
/* Initialize net device. */
static void tun_net_init(struct net_device *dev)
{
@@ -183,6 +195,7 @@ static void tun_net_init(struct net_device *dev)
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;
@@ -195,6 +208,7 @@ static void tun_net_init(struct net_device *dev)
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)) );