summaryrefslogtreecommitdiffstats
path: root/net/ipv4/netfilter/nf_nat_proto_common.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_common.c
parentf43dc98b3be36551143e3bbaf1bb3067835c24f4 (diff)
downloadlinux-stable-2452a99dc0496a90abd0090c280671370c0f3e1c.tar.gz
linux-stable-2452a99dc0496a90abd0090c280671370c0f3e1c.tar.bz2
linux-stable-2452a99dc0496a90abd0090c280671370c0f3e1c.zip
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_common.c')
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_common.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c
index 2844a0383a11..3e61faf23a9a 100644
--- a/net/ipv4/netfilter/nf_nat_proto_common.c
+++ b/net/ipv4/netfilter/nf_nat_proto_common.c
@@ -81,9 +81,9 @@ void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
else
off = *rover;
- for (i = 0; i < range_size; i++, off++) {
+ for (i = 0; ; ++off) {
*portptr = htons(min + off % range_size);
- if (nf_nat_used_tuple(tuple, ct))
+ if (++i != range_size && nf_nat_used_tuple(tuple, ct))
continue;
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM))
*rover = off;