Package: iproute
Version: 20070313-1
Severity: normal
Tags: patch

The help/usage screen of ematch cmp and nbyte say recognised symbolic
values for "layer FOO" are link, header and next-header, but the code
does _not_ implement that: it will recognise "next-header" as what is
supposed to be "header" and will not recognise "header". The right
symbolic values seem to be link, network, transport. Here is a patch
that changes the help/usage screen to match the code.

Details:

tc filter add dev dummy0 protocol ip parent 1:0 pref 10 basic match 'cmp(help)' 
flowid 1:1

says:

Usage: cmp(ALIGN at OFFSET [ ATTRS ] { eq | lt | gt } VALUE)
where: ALIGN  := { u8 | u16 | u32 }
       ATTRS  := [ layer LAYER ] [ mask MASK ] [ trans ]
       LAYER  := { link | header | next-header | 0..2 }

but the code is:

                } else if (!bstrcmp(a, "layer")) {
                        (...)
                        layer = parse_layer(a);

and

static inline int parse_layer(struct bstr *b)
{
        if (*((char *) b->data) == 'l')
                return TCF_LAYER_LINK;
        else if (*((char *) b->data) == 'n')
                return TCF_LAYER_NETWORK;
        else if (*((char *) b->data) == 't')
                return TCF_LAYER_TRANSPORT;
        else
                return INT_MAX;
}

-- 
Lionel
diff --recursive -N -u iproute-20070313.deb/debian/changelog iproute-20070313.lio/debian/changelog
--- iproute-20070313.deb/debian/changelog	2007-08-18 18:42:00.000000000 +0200
+++ iproute-20070313.lio/debian/changelog	2007-08-18 18:45:04.136518870 +0200
@@ -1,3 +1,9 @@
+iproute (20070313-2) unstable; urgency=low
+
+  * tc: bring usage help message in sync with code for cmp and nbyte ematch (closes: #TODO)
+
+ --
+
 iproute (20070313-1) unstable; urgency=low
 
   * New upstream release
diff --recursive -N -u iproute-20070313.deb/tc/em_cmp.c iproute-20070313.lio/tc/em_cmp.c
--- iproute-20070313.deb/tc/em_cmp.c	2007-03-13 22:50:56.000000000 +0100
+++ iproute-20070313.lio/tc/em_cmp.c	2007-08-18 18:44:26.773897785 +0200
@@ -1,5 +1,5 @@
 /*
- * em_cmp.c		Simle coparison Ematch
+ * em_cmp.c		Simple comparison Ematch
  *
  *		This program is free software; you can distribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -32,7 +32,7 @@
 	    "Usage: cmp(ALIGN at OFFSET [ ATTRS ] { eq | lt | gt } VALUE)\n" \
 	    "where: ALIGN  := { u8 | u16 | u32 }\n" \
 	    "       ATTRS  := [ layer LAYER ] [ mask MASK ] [ trans ]\n" \
-	    "       LAYER  := { link | header | next-header | 0..%d }\n" \
+	    "       LAYER  := { link | network | transport | 0..%d }\n" \
 	    "\n" \
 	    "Example: cmp(u16 at 3 layer 2 mask 0xff00 gt 20)\n",
 	    TCF_LAYER_MAX);
diff --recursive -N -u iproute-20070313.deb/tc/em_nbyte.c iproute-20070313.lio/tc/em_nbyte.c
--- iproute-20070313.deb/tc/em_nbyte.c	2007-03-13 22:50:56.000000000 +0100
+++ iproute-20070313.lio/tc/em_nbyte.c	2007-08-18 18:45:48.159607231 +0200
@@ -32,7 +32,7 @@
 	    "Usage: nbyte(NEEDLE at OFFSET [layer LAYER])\n" \
 	    "where: NEEDLE := { string | \"c-escape-sequence\" }\n" \
 	    "       OFFSET := int\n" \
-	    "       LAYER  := { link | header | next-header | 0..%d }\n" \
+	    "       LAYER  := { link | network | transport | 0..%d }\n" \
 	    "\n" \
 	    "Example: nbyte(\"ababa\" at 12 layer 1)\n",
 	    TCF_LAYER_MAX);

Reply via email to