From: Michael Wang <wangyun@linux.vnet.ibm.com>
To: Michael Wang <wangyun@linux.vnet.ibm.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH] Avoid extra calculation in ip_route_input_common
Date: Wed, 21 Dec 2011 13:19:57 +0800 [thread overview]
Message-ID: <4EF16C7D.1060608@linux.vnet.ibm.com> (raw)
In-Reply-To: <4EF16AA3.2070303@linux.vnet.ibm.com>
Please tell me if this patch is silly...
I really want to know the reason we need to use ^ and | instead of if and &&.
On 12/21/2011 01:12 PM, Michael Wang wrote:
> 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) |
And I also wonder whether I can use "rth->rt_key_dst == daddr" here or not...
Thanks & Regards,
Michael Wang
> - ((__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)) {
next prev parent reply other threads:[~2011-12-21 5:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 5:12 [PATCH] Avoid extra calculation in ip_route_input_common Michael Wang
2011-12-21 5:19 ` Michael Wang [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EF16C7D.1060608@linux.vnet.ibm.com \
--to=wangyun@linux.vnet.ibm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.