From patchwork Thu Jul 22 09:49:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 59559 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E61B4B70A9 for ; Thu, 22 Jul 2010 19:49:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755605Ab0GVJtd (ORCPT ); Thu, 22 Jul 2010 05:49:33 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:46052 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751915Ab0GVJtc (ORCPT ); Thu, 22 Jul 2010 05:49:32 -0400 Received: by pvc7 with SMTP id 7so2967033pvc.19 for ; Thu, 22 Jul 2010 02:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=oadjRMM7emEuBSBDke0dM0FBTy+wYdTLynPMth/+dVw=; b=AfSyl0SP4whRRqLN4kC5jyf7SAgu7nieQzMpTCZMTDX5wJ5z3EMGT8V1b+q23ZQo/E UK4FElGuuhaZA+v+V+uycSKNEHhsUpo4cXy7Q7Mqe1l2qsweC3qTz3226aI7+NBBG9uF s8kP+4vIZJAk5MVxrF/SSFBuqsXSHm8rr0Uv0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=XiZHHWBnBy3fUFooStjh/xiIlrwf+nvGIhDpK5Jq3ZsykgdV+ju9E9wOJ6kgOZnU+0 UF/fNIKFHkb0y3/q2KXsM9hLxP9o3rBcLlj8o8/shMnZFJ0kR69LGHwvqgeqGe9zvI/2 aCJdwROA6w4aKoLZwORSQ1pRNmW62lMGfMjhg= Received: by 10.114.110.10 with SMTP id i10mr2644957wac.70.1279792170725; Thu, 22 Jul 2010 02:49:30 -0700 (PDT) Received: from localhost.localdomain ([221.238.105.80]) by mx.google.com with ESMTPS id b23sm7850036rvf.6.2010.07.22.02.49.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 22 Jul 2010 02:49:29 -0700 (PDT) From: Changli Gao To: Patrick McHardy Cc: "David S. Miller" , netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, Changli Gao Subject: [PATCH] nf_nat_core: merge the same lines Date: Thu, 22 Jul 2010 17:49:00 +0800 Message-Id: <1279792140-10445-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 ---- 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 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;