From 9c67defe98f04f72f19dfd09c8030e1de4b8bf0f Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Wed, 18 Apr 2007 14:00:11 +0000 Subject: Fix iptables-save with --random option --- extensions/libipt_MASQUERADE.c | 5 ++++- extensions/libipt_SAME.c | 6 ++++++ extensions/libipt_SNAT.c | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'extensions') diff --git a/extensions/libipt_MASQUERADE.c b/extensions/libipt_MASQUERADE.c index 17fc4f60..c24bb321 100644 --- a/extensions/libipt_MASQUERADE.c +++ b/extensions/libipt_MASQUERADE.c @@ -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, diff --git a/extensions/libipt_SAME.c b/extensions/libipt_SAME.c index 1a379580..7211f608 100644 --- a/extensions/libipt_SAME.c +++ b/extensions/libipt_SAME.c @@ -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 = { diff --git a/extensions/libipt_SNAT.c b/extensions/libipt_SNAT.c index 9979bbf4..ed60ec2d 100644 --- a/extensions/libipt_SNAT.c +++ b/extensions/libipt_SNAT.c @@ -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 "); } } -- cgit v1.2.3