]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxt_conntrack: improve error message on parsing violation
authorTom Eastep <teastep@shorewall.net>
Thu, 18 Aug 2011 22:11:16 +0000 (15:11 -0700)
committerJan Engelhardt <jengelh@medozas.de>
Sat, 27 Aug 2011 16:36:19 +0000 (18:36 +0200)
Tom Eastep noted:

$ iptables -A foo -m conntrack --ctorigdstport 22
iptables v1.4.12: conntrack rev 2 does not support port ranges
Try `iptables -h' or 'iptables --help' for more information.

Commit v1.4.12-41-g1ad6407 takes care of the actual cause of the bug,
but let's include Tom's patch nevertheless for the better error
message in case one actually does specify a range with rev 2.

References: http://marc.info/?l=netfilter-devel&m=131370592105298&w=2
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
extensions/libxt_conntrack.c

index 060b9477fa10552313ce7b86d3dddb17b8022710..fff69f8abe330fde87a04a3d56bd12c3be03f1eb 100644 (file)
@@ -129,13 +129,20 @@ static const struct xt_option_entry conntrack2_mt_opts[] = {
         .flags = XTOPT_INVERT},
        {.name = "ctexpire", .id = O_CTEXPIRE, .type = XTTYPE_UINT32RC,
         .flags = XTOPT_INVERT},
-       {.name = "ctorigsrcport", .id = O_CTORIGSRCPORT, .type = XTTYPE_PORT,
+       /*
+        * Rev 1 and 2 only store one port, and we would normally use
+        * %XTTYPE_PORT (rather than %XTTYPE_PORTRC) for that. The resulting
+        * error message - in case a user passed a range nevertheless -
+        * "port 22:23 resolved to nothing" is not quite as useful as using
+        * %XTTYPE_PORTC and libxt_conntrack's own range test.
+        */
+       {.name = "ctorigsrcport", .id = O_CTORIGSRCPORT, .type = XTTYPE_PORTRC,
         .flags = XTOPT_INVERT | XTOPT_NBO},
-       {.name = "ctorigdstport", .id = O_CTORIGDSTPORT, .type = XTTYPE_PORT,
+       {.name = "ctorigdstport", .id = O_CTORIGDSTPORT, .type = XTTYPE_PORTRC,
         .flags = XTOPT_INVERT | XTOPT_NBO},
-       {.name = "ctreplsrcport", .id = O_CTREPLSRCPORT, .type = XTTYPE_PORT,
+       {.name = "ctreplsrcport", .id = O_CTREPLSRCPORT, .type = XTTYPE_PORTRC,
         .flags = XTOPT_INVERT | XTOPT_NBO},
-       {.name = "ctrepldstport", .id = O_CTREPLDSTPORT, .type = XTTYPE_PORT,
+       {.name = "ctrepldstport", .id = O_CTREPLDSTPORT, .type = XTTYPE_PORTRC,
         .flags = XTOPT_INVERT | XTOPT_NBO},
        {.name = "ctdir", .id = O_CTDIR, .type = XTTYPE_STRING},
        XTOPT_TABLEEND,