aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-09-16 13:45:19 -0400
committerPatrick McHardy <kaber@trash.net>2010-09-16 13:45:19 -0400
commit99ad3c53b36a056a472927de9c79eda231ecc6fe (patch)
tree61224a837d3eb7e6504fe49d10613b3717ccd67f /net/ipv4
parent70a851667dbd7aa3f7be9609d6580ca9861230b3 (diff)
netfilter: nf_nat_core: don't check if the tuple is used if there is no other choice
Eliminate nf_nat_used_tuple() to save some CPU cycles when there is no other choice. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index 8c8632d9b93c..2c084b3a8f0c 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -262,11 +262,17 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
262 proto = __nf_nat_proto_find(orig_tuple->dst.protonum); 262 proto = __nf_nat_proto_find(orig_tuple->dst.protonum);
263 263
264 /* Only bother mapping if it's not already in range and unique */ 264 /* Only bother mapping if it's not already in range and unique */
265 if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM) && 265 if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
266 (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) || 266 if (range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) {
267 proto->in_range(tuple, maniptype, &range->min, &range->max)) && 267 if (proto->in_range(tuple, maniptype, &range->min,
268 !nf_nat_used_tuple(tuple, ct)) 268 &range->max) &&
269 goto out; 269 (range->min.all == range->max.all ||
270 !nf_nat_used_tuple(tuple, ct)))
271 goto out;
272 } else if (!nf_nat_used_tuple(tuple, ct)) {
273 goto out;
274 }
275 }
270 276
271 /* Last change: get protocol to try to obtain unique tuple. */ 277 /* Last change: get protocol to try to obtain unique tuple. */
272 proto->unique_tuple(tuple, range, maniptype, ct); 278 proto->unique_tuple(tuple, range, maniptype, ct);