summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-11-18 16:03:44 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2017-11-18 16:03:44 +0100
commit4a684fc627175ee27833d5fcc9569510fa04dfcd (patch)
treedc9dbefb51d0692cf0700689fd8f7bb043e9340e /sys/src
parent435a9a150ea5d3eae891503be0224ea9c9d29bab (diff)
6in4: add -m mtu option to specify outer MTU
instead of hardcoding the tunnel interface MTU to 1280, we calculate the tunnel MTU from the outside MTU, which can now be specified with the -m mtu option. The deault outside MTU is 1500 - 8 (PPPoE).
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/ip/6in4.c11
-rw-r--r--sys/src/cmd/ip/ayiya.c11
2 files changed, 16 insertions, 6 deletions
diff --git a/sys/src/cmd/ip/6in4.c b/sys/src/cmd/ip/6in4.c
index 7ef633fed..f7e27be62 100644
--- a/sys/src/cmd/ip/6in4.c
+++ b/sys/src/cmd/ip/6in4.c
@@ -46,6 +46,8 @@ struct Iphdr
#define STFHDR offsetof(Iphdr, payload[0])
+int mtu = 1500-8;
+
int anysender;
int gateway;
int debug;
@@ -71,7 +73,7 @@ static void tunnel2ip(int, int);
static void
usage(void)
{
- fprint(2, "usage: %s [-ag] [-x mtpt] [-o mtpt] [-i local4] [local6[/mask]] [remote4 [remote6]]\n",
+ fprint(2, "usage: %s [-ag] [-m mtu] [-x mtpt] [-o mtpt] [-i local4] [local6[/mask]] [remote4 [remote6]]\n",
argv0);
exits("Usage");
}
@@ -191,8 +193,8 @@ setup(int *v6net, int *tunp)
*v6net = open(path, ORDWR);
if (*v6net < 0 || fprint(cfd, "bind pkt") < 0)
sysfatal("can't bind packet interface: %r");
- /* 1280 is MTU, apparently from rfc2460 */
- if (fprint(cfd, "add %I %M %I 1280", local6, localmask, remote6) <= 0)
+ if (fprint(cfd, "add %I %M %I %d", local6, localmask, remote6,
+ mtu - IPV4HDR_LEN) <= 0)
sysfatal("can't set local ipv6 address: %r");
close(cfd);
if (debug)
@@ -255,6 +257,9 @@ main(int argc, char **argv)
case 'g':
gateway++;
break;
+ case 'm':
+ mtu = atoi(EARGF(usage()));
+ break;
case 'x':
outside = inside = EARGF(usage());
break;
diff --git a/sys/src/cmd/ip/ayiya.c b/sys/src/cmd/ip/ayiya.c
index 052d0640f..76d90bc17 100644
--- a/sys/src/cmd/ip/ayiya.c
+++ b/sys/src/cmd/ip/ayiya.c
@@ -76,6 +76,8 @@ struct AYIYA
AYIYA conf;
+int mtu = 1500-8;
+
int gateway;
int debug;
@@ -283,7 +285,7 @@ ayiyarquery(char *q)
static void
usage(void)
{
- fprint(2, "usage: %s [-g] [-x mtpt] [-k secret] local6[/mask] remote4 remote6\n",
+ fprint(2, "usage: %s [-g] [-m mtu] [-x mtpt] [-k secret] local6[/mask] remote4 remote6\n",
argv0);
exits("Usage");
}
@@ -363,8 +365,8 @@ setup(int *v6net)
*v6net = open(path, ORDWR);
if (*v6net < 0 || fprint(cfd, "bind pkt") < 0)
sysfatal("can't bind packet interface: %r");
- /* 1280 is MTU, apparently from rfc2460 */
- if (fprint(cfd, "add %I %M %I 1280", local6, localmask, remote6) <= 0)
+ if (fprint(cfd, "add %I %M %I %d", local6, localmask, remote6,
+ mtu - (IPV4HDR_LEN+8) - (8+conf.idlen+conf.siglen)) <= 0)
sysfatal("can't set local ipv6 address: %r");
close(cfd);
if (debug)
@@ -424,6 +426,9 @@ main(int argc, char **argv)
case 'g':
gateway++;
break;
+ case 'm':
+ mtu = atoi(EARGF(usage()));
+ break;
case 'x':
inside = EARGF(usage());
break;