From patchwork Thu Sep 30 02:24:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 66107 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 64A1DB6F07 for ; Thu, 30 Sep 2010 12:25:44 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752586Ab0I3CZk (ORCPT ); Wed, 29 Sep 2010 22:25:40 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:52312 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770Ab0I3CZj (ORCPT ); Wed, 29 Sep 2010 22:25:39 -0400 Received: by gxk9 with SMTP id 9so471042gxk.19 for ; Wed, 29 Sep 2010 19:25:38 -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=kuxHdS/a/4hZHfe/S0mhYizv5kpW3wHw8+L7KzZzHZ0=; b=ZPYMJFyLTfWhZidefMFj07/gnmE1J0wWKbrUHwubmQcuAzRb30Cm2swWC70lRyiATc HfWlE0V6JH62vEMplbzZP8jGWygTBTedaAqizuwdla9/vpUG/sqRiJ/QhL2jGlEhSyCJ 8wh7jJUqDCr+ardVRgmzL7c48xQBWOwroWNGA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=wPHaceNRgIf1ssZnPzIZ44nOUh020INAjeUCtijfoHwCWdyD1r5TKbfEyCeXdM04nQ Yt7EFUvjJMNGyH7g2f7KfjPVptIWX3FZ2ErRDFrxnhbFj1bDCC2qYXir4oGBhqou9JcS xfL3YcHI87+daL9f6ZT4nHHCOrFtxv5axQoPA= Received: by 10.224.28.144 with SMTP id m16mr1884171qac.357.1285813538190; Wed, 29 Sep 2010 19:25:38 -0700 (PDT) Received: from localhost.localdomain ([221.238.109.116]) by mx.google.com with ESMTPS id e6sm10267052qcr.5.2010.09.29.19.25.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 29 Sep 2010 19:25:37 -0700 (PDT) From: Changli Gao To: "David S. Miller" Cc: Alexey Kuznetsov , "Pekka Savola (ipv6)" , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , netdev@vger.kernel.org, Changli Gao Subject: [PATCH] net: code cleanups Date: Thu, 30 Sep 2010 10:24:57 +0800 Message-Id: <1285813497-7384-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 Compare operations are more readable, and compilers generate the same code for the both. Use the macros fl4_* to shrink the length of the lines. Signed-off-by: Changli Gao --- net/ipv4/af_inet.c | 7 +++---- net/ipv4/route.c | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 19 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/af_inet.c b/net/ipv4/af_inet.c index f581f77..ef26640 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1338,10 +1338,9 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, iph2 = ip_hdr(p); - if ((iph->protocol ^ iph2->protocol) | - (iph->tos ^ iph2->tos) | - ((__force u32)iph->saddr ^ (__force u32)iph2->saddr) | - ((__force u32)iph->daddr ^ (__force u32)iph2->daddr)) { + if (iph->protocol != iph2->protocol || iph->tos != iph2->tos || + (__force u32)iph->saddr != (__force u32)iph2->saddr || + (__force u32)iph->daddr != (__force u32)iph2->daddr) { NAPI_GRO_CB(p)->same_flow = 0; continue; } diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 98beda4..6b00fde 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -683,19 +683,18 @@ static inline bool rt_caching(const struct net *net) static inline bool compare_hash_inputs(const struct flowi *fl1, const struct flowi *fl2) { - return ((((__force u32)fl1->nl_u.ip4_u.daddr ^ (__force u32)fl2->nl_u.ip4_u.daddr) | - ((__force u32)fl1->nl_u.ip4_u.saddr ^ (__force u32)fl2->nl_u.ip4_u.saddr) | - (fl1->iif ^ fl2->iif)) == 0); + return (__force u32)fl1->fl4_dst == (__force u32)fl2->fl4_dst && + (__force u32)fl1->fl4_src == (__force u32)fl2->fl4_src && + fl1->iif == fl2->iif; } static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) { - return (((__force u32)fl1->nl_u.ip4_u.daddr ^ (__force u32)fl2->nl_u.ip4_u.daddr) | - ((__force u32)fl1->nl_u.ip4_u.saddr ^ (__force u32)fl2->nl_u.ip4_u.saddr) | - (fl1->mark ^ fl2->mark) | - (*(u16 *)&fl1->nl_u.ip4_u.tos ^ *(u16 *)&fl2->nl_u.ip4_u.tos) | - (fl1->oif ^ fl2->oif) | - (fl1->iif ^ fl2->iif)) == 0; + return (__force u32)fl1->fl4_dst == (__force u32)fl2->fl4_dst && + (__force u32)fl1->fl4_src == (__force u32)fl2->fl4_src && + fl1->mark == fl2->mark && + *(u16 *)&fl1->fl4_tos == *(u16 *)&fl2->fl4_tos && + fl1->oif == fl2->oif && fl1->iif == fl2->iif; } static inline int compare_netns(struct rtable *rt1, struct rtable *rt2) @@ -2286,12 +2285,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->fl.fl4_dst ^ (__force u32)daddr) | - ((__force u32)rth->fl.fl4_src ^ (__force u32)saddr) | - (rth->fl.iif ^ iif) | - rth->fl.oif | - (rth->fl.fl4_tos ^ tos)) == 0 && - rth->fl.mark == skb->mark && + if ((__force u32)rth->fl.fl4_dst == (__force u32)daddr && + (__force u32)rth->fl.fl4_src == (__force u32)saddr && + rth->fl.iif == iif && rth->fl.oif == 0 && + rth->fl.fl4_tos == tos && rth->fl.mark == skb->mark && net_eq(dev_net(rth->dst.dev), net) && !rt_is_expired(rth)) { if (noref) {