From patchwork Wed Dec 21 05:12:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Wang X-Patchwork-Id: 132584 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 164CEB70E4 for ; Wed, 21 Dec 2011 16:12:21 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670Ab1LUFMQ (ORCPT ); Wed, 21 Dec 2011 00:12:16 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:53652 "EHLO e28smtp04.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097Ab1LUFMO (ORCPT ); Wed, 21 Dec 2011 00:12:14 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Dec 2011 10:42:11 +0530 Received: from d28relay05.in.ibm.com (9.184.220.62) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Dec 2011 10:42:06 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBL5C5eo3535076 for ; Wed, 21 Dec 2011 10:42:06 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBL5C5ko023586 for ; Wed, 21 Dec 2011 16:12:05 +1100 Received: from [9.186.166.62] (wangyun.cn.ibm.com [9.186.166.62]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBL5C4N9023548; Wed, 21 Dec 2011 16:12:05 +1100 Message-ID: <4EF16AA3.2070303@linux.vnet.ibm.com> Date: Wed, 21 Dec 2011 13:12:03 +0800 From: Michael Wang User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: "netdev@vger.kernel.org" CC: Michael Wang Subject: [PATCH] Avoid extra calculation in ip_route_input_common x-cbid: 11122105-5564-0000-0000-00000096FAF5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Michael Wang If previous condition doesn't meet, the later check will be cancelled. So we don't need to do all the calculation. Signed-off-by: Michael Wang --- net/ipv4/route.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index f30112f..2872bfb 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2362,10 +2362,10 @@ int ip_route_input_common(struct sk_buff *skb, __be32 daddr, __be32 saddr, for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; rth = rcu_dereference(rth->dst.rt_next)) { - if ((((__force u32)rth->rt_key_dst ^ (__force u32)daddr) | - ((__force u32)rth->rt_key_src ^ (__force u32)saddr) | - (rth->rt_route_iif ^ iif) | - (rth->rt_key_tos ^ tos)) == 0 && + if (((__force u32)rth->rt_key_dst ^ (__force u32)daddr) == 0 && + ((__force u32)rth->rt_key_src ^ (__force u32)saddr) == 0 && + rth->rt_route_iif == iif && + rth->rt_key_tos == tos && rth->rt_mark == skb->mark && net_eq(dev_net(rth->dst.dev), net) && !rt_is_expired(rth)) {