]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Fix iptables-save with --random option
authorPatrick McHardy <kaber@trash.net>
Wed, 18 Apr 2007 14:00:11 +0000 (14:00 +0000)
committerPatrick McHardy <kaber@trash.net>
Wed, 18 Apr 2007 14:00:11 +0000 (14:00 +0000)
extensions/libipt_MASQUERADE.c
extensions/libipt_SAME.c
extensions/libipt_SNAT.c

index 17fc4f60a2c87fec4bb2541f55013eb1d767ecb9..c24bb32135aa87a0488dc94677e71042116ee4d4 100644 (file)
@@ -138,7 +138,7 @@ print(const struct ipt_ip *ip,
        }
 
        if (r->flags & IP_NAT_RANGE_PROTO_RANDOM)
-               printf("random");
+               printf("random ");
 }
 
 /* Saves the union ipt_targinfo in parsable form to stdout. */
@@ -155,6 +155,9 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
                        printf("-%hu", ntohs(r->max.tcp.port));
                printf(" ");
        }
+
+       if (r->flags & IP_NAT_RANGE_PROTO_RANDOM)
+               printf("--random ");
 }
 
 static struct iptables_target masq = { NULL,
index 1a37958026009af74cd1125c0d9b2daaf52ad485..7211f608a2bc1f4b96a5313aa8b69f35b46bf2e2 100644 (file)
@@ -190,6 +190,7 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
        int count;
        struct ipt_same_info *mr
                = (struct ipt_same_info *)target->data;
+       int random = 0;
 
        for (count = 0; count < mr->rangesize; count++) {
                struct ip_nat_range *r = &mr->range[count];
@@ -203,10 +204,15 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
                        printf(" ");
                else
                        printf("-%s ", addr_to_dotted(&a));
+               if (r->flags & IP_NAT_RANGE_PROTO_RANDOM) 
+                       random = 1;
        }
        
        if (mr->info & IPT_SAME_NODST)
                printf("--nodst ");
+
+       if (random)
+               printf("--random ");
 }
 
 static struct iptables_target same = {
index 9979bbf4004f5ca874e92c97213425afe3bebbec..ed60ec2d0233e21c4ff887338f4a795e3cffb8d3 100644 (file)
@@ -214,8 +214,6 @@ static void print_range(const struct ip_nat_range *r)
                if (r->max.tcp.port != r->min.tcp.port)
                        printf("-%hu", ntohs(r->max.tcp.port));
        }
-       if (r->flags & IP_NAT_RANGE_PROTO_RANDOM)
-               printf(" random");
 }
 
 /* Prints out the targinfo. */
@@ -231,6 +229,8 @@ print(const struct ipt_ip *ip,
        for (i = 0; i < info->mr.rangesize; i++) {
                print_range(&info->mr.range[i]);
                printf(" ");
+               if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM)
+                       printf("random ");
        }
 }
 
@@ -245,6 +245,8 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
                printf("--to-source ");
                print_range(&info->mr.range[i]);
                printf(" ");
+               if (info->mr.range[i].flags & IP_NAT_RANGE_PROTO_RANDOM)
+                       printf("--random ");
        }
 }