]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libipt_[SD]NAT: avoid false error about multiple destinations specified
authorJan Engelhardt <jengelh@medozas.de>
Thu, 12 May 2011 22:15:45 +0000 (00:15 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Fri, 13 May 2011 00:00:01 +0000 (02:00 +0200)
iptables-restore v1.4.10: DNAT: Multiple --to-destination not supported

xtables_option_parse sets cb->xflags already, so that it cannot be
directly used to test whether an option is being used for the second
time. Thus use a private option/flag (X_TO_DEST/SRC) that is not under
the control of xtables_option_parse.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
extensions/libipt_DNAT.c
extensions/libipt_SNAT.c

index 8c4c9c25bfab69c2ec49674d5568436c6d6a0550..3b55c69c3c9c4c4df673bca85560487ed5c880e9 100644 (file)
@@ -12,8 +12,10 @@ enum {
        O_TO_DEST = 0,
        O_RANDOM,
        O_PERSISTENT,
-       F_TO_DEST = 1 << O_TO_DEST,
-       F_RANDOM  = 1 << O_RANDOM,
+       O_X_TO_DEST, /* hidden flag */
+       F_TO_DEST   = 1 << O_TO_DEST,
+       F_RANDOM    = 1 << O_RANDOM,
+       F_X_TO_DEST = 1 << O_X_TO_DEST,
 };
 
 /* Dest NAT data consists of a multi-range, indicating where to map
@@ -164,7 +166,7 @@ static void DNAT_parse(struct xt_option_call *cb)
        xtables_option_parse(cb);
        switch (cb->entry->id) {
        case O_TO_DEST:
-               if (cb->xflags & F_TO_DEST) {
+               if (cb->xflags & F_X_TO_DEST) {
                        if (!kernel_version)
                                get_kernel_version();
                        if (kernel_version > LINUX_VERSION(2, 6, 10))
@@ -175,6 +177,7 @@ static void DNAT_parse(struct xt_option_call *cb)
                /* WTF do we need this for?? */
                if (cb->xflags & F_RANDOM)
                        info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
+               cb->xflags |= F_X_TO_DEST;
                break;
        case O_RANDOM:
                if (cb->xflags & F_TO_DEST)
index 369104173029059de3b9649e755f5c625e4c1151..80233060812d413ce91a9ceae53a2d8d9f0f4ed9 100644 (file)
@@ -12,8 +12,10 @@ enum {
        O_TO_SRC = 0,
        O_RANDOM,
        O_PERSISTENT,
-       F_TO_SRC = 1 << O_TO_SRC,
-       F_RANDOM = 1 << O_RANDOM,
+       O_X_TO_SRC,
+       F_TO_SRC   = 1 << O_TO_SRC,
+       F_RANDOM   = 1 << O_RANDOM,
+       F_X_TO_SRC = 1 << O_X_TO_SRC,
 };
 
 /* Source NAT data consists of a multi-range, indicating where to map
@@ -164,7 +166,7 @@ static void SNAT_parse(struct xt_option_call *cb)
        xtables_option_parse(cb);
        switch (cb->entry->id) {
        case O_TO_SRC:
-               if (cb->xflags & F_TO_SRC) {
+               if (cb->xflags & F_X_TO_SRC) {
                        if (!kernel_version)
                                get_kernel_version();
                        if (kernel_version > LINUX_VERSION(2, 6, 10))
@@ -175,6 +177,7 @@ static void SNAT_parse(struct xt_option_call *cb)
                /* WTF do we need this for?? */
                if (cb->xflags & F_RANDOM)
                        info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
+               cb->xflags |= F_X_TO_SRC;
                break;
        case O_RANDOM:
                if (cb->xflags & F_TO_SRC)