diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-18 16:03:44 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-18 16:03:44 +0100 |
commit | 4a684fc627175ee27833d5fcc9569510fa04dfcd (patch) | |
tree | dc9dbefb51d0692cf0700689fd8f7bb043e9340e | |
parent | 435a9a150ea5d3eae891503be0224ea9c9d29bab (diff) | |
download | plan9front-4a684fc627175ee27833d5fcc9569510fa04dfcd.tar.xz |
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).
-rw-r--r-- | sys/man/8/6in4 | 11 | ||||
-rw-r--r-- | sys/src/cmd/ip/6in4.c | 11 | ||||
-rw-r--r-- | sys/src/cmd/ip/ayiya.c | 11 |
3 files changed, 27 insertions, 6 deletions
diff --git a/sys/man/8/6in4 b/sys/man/8/6in4 index 6e44d2a96..d34c652ac 100644 --- a/sys/man/8/6in4 +++ b/sys/man/8/6in4 @@ -6,6 +6,9 @@ [ .B -ag ] [ +.B -m +.I mtu +] [ .B -x .I netmtpt ] [ @@ -26,6 +29,9 @@ [ .B -g ] [ +.B -m +.I mtu +] [ .B -x .I netmtpt ] [ @@ -104,6 +110,11 @@ non-loopback address of the outside IP stack. .B -g use the tunnel as the default route for global IPv6 addresses .TP +.B -m +.I mtu +specifies the outside MTU in bytes from which the inside +tunnel MTU is derived. Deaults to 1500 - 8 (Ethernet - PPPoE). +.TP .B -x use the network mounted at .I netmtpt 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; |