Patchwork nf_nat_core: merge the same lines

login
register
mail settings
Submitter Changli Gao
Date July 22, 2010, 9:49 a.m.
Message ID <1279792140-10445-1-git-send-email-xiaosuo@gmail.com>
Download mbox | patch
Permalink /patch/59559/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Changli Gao - July 22, 2010, 9:49 a.m.
nf_nat_core: merge the same lines

proto->unique_tuple() will be called finally, if the previous calls fail. This
patch checks the false condition of (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
instead to avoid duplicate line of code: proto->unique_tuple().

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
 net/ipv4/netfilter/nf_nat_core.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrick McHardy - July 23, 2010, 11:28 a.m.
On 22.07.2010 11:49, Changli Gao wrote:
> nf_nat_core: merge the same lines

Please prefix your subjects with "netfilter: " so I don't have to
edit them every time.

> proto->unique_tuple() will be called finally, if the previous calls fail. This
> patch checks the false condition of (range->flags & IP_NAT_RANGE_PROTO_RANDOM)
> instead to avoid duplicate line of code: proto->unique_tuple().

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index c7719b2..037a3a6 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -261,14 +261,9 @@  get_unique_tuple(struct nf_conntrack_tuple *tuple,
 	rcu_read_lock();
 	proto = __nf_nat_proto_find(orig_tuple->dst.protonum);
 
-	/* Change protocol info to have some randomization */
-	if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) {
-		proto->unique_tuple(tuple, range, maniptype, ct);
-		goto out;
-	}
-
 	/* Only bother mapping if it's not already in range and unique */
-	if ((!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
+	if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM) &&
+	    (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
 	     proto->in_range(tuple, maniptype, &range->min, &range->max)) &&
 	    !nf_nat_used_tuple(tuple, ct))
 		goto out;