netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Avoid extra calculation in ip_route_input_common
@ 2011-12-21  5:12 Michael Wang
  2011-12-21  5:19 ` Michael Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Michael Wang @ 2011-12-21  5:12 UTC (permalink / raw)
  To: netdev@vger.kernel.org; +Cc: Michael Wang

From: Michael Wang <wangyun@linux.vnet.ibm.com>

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 <wangyun@linux.vnet.ibm.com>
---
 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)) {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-12-21  6:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21  5:12 [PATCH] Avoid extra calculation in ip_route_input_common Michael Wang
2011-12-21  5:19 ` Michael Wang
2011-12-21  5:23 ` Joe Perches
2011-12-21  5:39   ` Michael Wang
2011-12-21  5:50     ` Joe Perches
2011-12-21  6:00       ` Michael Wang
2011-12-21  5:57 ` David Miller
2011-12-21  6:04   ` Michael Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).