aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEd Swierk <eswierk@arastra.com>2007-09-16 15:21:38 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:19 -0400
commit4885a50476b95fa0f4caad179a80783508c2fe86 (patch)
tree55a5b007e593e8ee810e142517854a42b23af6fe /drivers
parent0b69d4bd263c75b3e2ec94f1c72f338b84be817e (diff)
[TAP]: Configurable interface MTU.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-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)
172 } 172 }
173} 173}
174 174
175#define MIN_MTU 68
176#define MAX_MTU 65535
177
178static int
179tun_net_change_mtu(struct net_device *dev, int new_mtu)
180{
181 if (new_mtu < MIN_MTU || new_mtu + dev->hard_header_len > MAX_MTU)
182 return -EINVAL;
183 dev->mtu = new_mtu;
184 return 0;
185}
186
175/* Initialize net device. */ 187/* Initialize net device. */
176static void tun_net_init(struct net_device *dev) 188static void tun_net_init(struct net_device *dev)
177{ 189{
@@ -183,6 +195,7 @@ static void tun_net_init(struct net_device *dev)
183 dev->hard_header_len = 0; 195 dev->hard_header_len = 0;
184 dev->addr_len = 0; 196 dev->addr_len = 0;
185 dev->mtu = 1500; 197 dev->mtu = 1500;
198 dev->change_mtu = tun_net_change_mtu;
186 199
187 /* Zero header length */ 200 /* Zero header length */
188 dev->type = ARPHRD_NONE; 201 dev->type = ARPHRD_NONE;
@@ -195,6 +208,7 @@ static void tun_net_init(struct net_device *dev)
195 dev->set_multicast_list = tun_net_mclist; 208 dev->set_multicast_list = tun_net_mclist;
196 209
197 ether_setup(dev); 210 ether_setup(dev);
211 dev->change_mtu = tun_net_change_mtu;
198 212
199 /* random address already created for us by tun_set_iff, use it */ 213 /* random address already created for us by tun_set_iff, use it */
200 memcpy(dev->dev_addr, tun->dev_addr, min(sizeof(tun->dev_addr), sizeof(dev->dev_addr)) ); 214 memcpy(dev->dev_addr, tun->dev_addr, min(sizeof(tun->dev_addr), sizeof(dev->dev_addr)) );