Subject: Re: [PATCH 3/6] IPV4 : use xor rather than multiple ands for route compare

From: Eric Dumazet <[email-masked]>
Date: Thu, 10 Apr 2008 11:26:57 +0200

David Miller a écrit :
> From: Stephen Hemminger <[email-masked]>
> Date: Tue, 1 Apr 2008 13:08:42 -0700
>
>   
>> The flow fields are all together, and the other parameters are local variables
>> in registers so that compare should be in one cache line.
>>
>> --- a/net/ipv4/route.c	2008-03-31 17:12:30.000000000 -0700
>> +++ b/net/ipv4/route.c	2008-04-01 13:05:46.000000000 -0700
>> @@ -2079,12 +2079,12 @@ int ip_route_input(struct sk_buff *skb, 
>>  	rcu_read_lock();
>>  	for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
>>  	     rth = rcu_dereference(rth->u.dst.rt_next)) {
>> -		if (rth->fl.fl4_dst == daddr &&
>> -		    rth->fl.fl4_src == saddr &&
>> -		    rth->fl.iif == iif &&
>> -		    rth->fl.oif == 0 &&
>> +		if (((rth->fl.fl4_dst ^ daddr) |
>> +		     (rth->fl.fl4_src ^ saddr) |
>> +		     (rth->fl.iif ^ iif) |
>> +		     rth->fl.oif |
>> +		     (rth->fl.fl4_tos ^ tos)) == 0 &&
>>  		    rth->fl.mark == skb->mark &&
>> -		    rth->fl.fl4_tos == tos &&
>>  		    net_eq(dev_net(rth->u.dst.dev), net) &&
>>  		    rth->rt_genid == atomic_read(&rt_genid)) {
>>  			dst_use(&rth->u.dst, jiffies);
>>     
>
> Eric, any objections to this version?
>   
No objections from me, thank you.

Acked-by: Eric Dumazet <[email-masked]>