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>
This commit is contained in:
committed by
Patrick McHardy
parent
70a851667d
commit
99ad3c53b3
@@ -262,11 +262,17 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
|
|||||||
proto = __nf_nat_proto_find(orig_tuple->dst.protonum);
|
proto = __nf_nat_proto_find(orig_tuple->dst.protonum);
|
||||||
|
|
||||||
/* Only bother mapping if it's not already in range and unique */
|
/* Only bother mapping if it's not already in range and unique */
|
||||||
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM) &&
|
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
|
||||||
(!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
|
if (range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) {
|
||||||
proto->in_range(tuple, maniptype, &range->min, &range->max)) &&
|
if (proto->in_range(tuple, maniptype, &range->min,
|
||||||
!nf_nat_used_tuple(tuple, ct))
|
&range->max) &&
|
||||||
goto out;
|
(range->min.all == range->max.all ||
|
||||||
|
!nf_nat_used_tuple(tuple, ct)))
|
||||||
|
goto out;
|
||||||
|
} else if (!nf_nat_used_tuple(tuple, ct)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Last change: get protocol to try to obtain unique tuple. */
|
/* Last change: get protocol to try to obtain unique tuple. */
|
||||||
proto->unique_tuple(tuple, range, maniptype, ct);
|
proto->unique_tuple(tuple, range, maniptype, ct);
|
||||||
|
Reference in New Issue
Block a user