summaryrefslogtreecommitdiff
path: root/net/ipv4/netfilter/nf_nat_proto_icmp.c
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-08-02 17:35:49 +0200
committerPatrick McHardy <kaber@trash.net>2010-08-02 17:35:49 +0200
commit2452a99dc0496a90abd0090c280671370c0f3e1c (patch)
tree695cfb4bff794c4815f8d55e89426107ad3699de /net/ipv4/netfilter/nf_nat_proto_icmp.c
parentf43dc98b3be36551143e3bbaf1bb3067835c24f4 (diff)
netfilter: nf_nat: don't check if the tuple is unique when there isn't any other choice
The tuple got from unique_tuple() doesn't need to be really unique, so the check for the unique tuple isn't necessary, when there isn't any other choice. Eliminating the unnecessary nf_nat_used_tuple() can save some CPU cycles too. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/ipv4/netfilter/nf_nat_proto_icmp.c')
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_icmp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/netfilter/nf_nat_proto_icmp.c b/net/ipv4/netfilter/nf_nat_proto_icmp.c
index 97003fe312e3..5744c3ec847c 100644
--- a/net/ipv4/netfilter/nf_nat_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_nat_proto_icmp.c
@@ -42,10 +42,10 @@ icmp_unique_tuple(struct nf_conntrack_tuple *tuple,
if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED))
range_size = 0xFFFF;
- for (i = 0; i < range_size; i++, id++) {
+ for (i = 0; ; ++id) {
tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
(id % range_size));
- if (!nf_nat_used_tuple(tuple, ct))
+ if (++i == range_size || !nf_nat_used_tuple(tuple, ct))
return;
}
return;