aboutsummaryrefslogtreecommitdiffstats
path: root/ip/iptunnel.c
diff options
context:
space:
mode:
authorDavid Ward <david.ward@ll.mit.edu>2013-01-27 13:04:59 +0000
committerStephen Hemminger <stephen@networkplumber.org>2013-02-04 08:56:45 -0800
commite59fd3db2ea86b94fb0e5fc277e5b10f09bc2336 (patch)
tree4854a03774fde06f251981dabc4ffe64f9abce0f /ip/iptunnel.c
parent53403c53af6c7cbc9c3f54b5170fdd0cf367b70a (diff)
downloadandroid_external_iproute2-e59fd3db2ea86b94fb0e5fc277e5b10f09bc2336.tar.gz
android_external_iproute2-e59fd3db2ea86b94fb0e5fc277e5b10f09bc2336.tar.bz2
android_external_iproute2-e59fd3db2ea86b94fb0e5fc277e5b10f09bc2336.zip
ip/iptunnel: Extend TOS syntax
The 'inherit/STRING' or 'inherit/00..ff' syntax indicates that the TOS field of tunneled packets should be copied from the original IP header, but for non-IP packets the value STRING or 00..ff should be used instead. (This syntax is already used by 'ip tunnel show'.) Also clarify the man page and the command usage text (particularly that the TOS is not specified as a decimal number). Signed-off-by: David Ward <david.ward@ll.mit.edu>
Diffstat (limited to 'ip/iptunnel.c')
-rw-r--r--ip/iptunnel.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
index 0cf6cf8..f8b91ba 100644
--- a/ip/iptunnel.c
+++ b/ip/iptunnel.c
@@ -41,7 +41,7 @@ static void usage(void)
fprintf(stderr, "\n");
fprintf(stderr, "Where: NAME := STRING\n");
fprintf(stderr, " ADDR := { IP_ADDRESS | any }\n");
- fprintf(stderr, " TOS := { NUMBER | inherit }\n");
+ fprintf(stderr, " TOS := { STRING | 00..ff | inherit | inherit/STRING | inherit/00..ff }\n");
fprintf(stderr, " TTL := { 1..255 | inherit }\n");
fprintf(stderr, " KEY := { DOTTED_QUAD | NUMBER }\n");
exit(-1);
@@ -188,14 +188,21 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
} else if (strcmp(*argv, "tos") == 0 ||
strcmp(*argv, "tclass") == 0 ||
matches(*argv, "dsfield") == 0) {
+ char *dsfield;
__u32 uval;
NEXT_ARG();
+ dsfield = *argv;
+ strsep(&dsfield, "/");
if (strcmp(*argv, "inherit") != 0) {
- if (rtnl_dsfield_a2n(&uval, *argv))
- invarg("bad TOS value", *argv);
- p->iph.tos = uval;
+ dsfield = *argv;
+ p->iph.tos = 0;
} else
p->iph.tos = 1;
+ if (dsfield) {
+ if (rtnl_dsfield_a2n(&uval, dsfield))
+ invarg("bad TOS value", *argv);
+ p->iph.tos |= uval;
+ }
} else {
if (strcmp(*argv, "name") == 0) {
NEXT_ARG();