diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-04-10 07:00:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-10 07:00:28 -0400 |
commit | c0b8c32b1c96afc9b32b717927330025cc1c501e (patch) | |
tree | 34997f5e86aa375746ecbe4f2c8899b4fa774a5e /net/ipv4/route.c | |
parent | 996b1dbadcbcafb899f022303e01d46ab87920eb (diff) |
IPV4: use xor rather than multiple ands for route compare
The comparison in ip_route_input is a hot path, by recoding the C
"and" as bit operations, fewer conditional branches get generated
so the code should be faster. Maybe someday Gcc will be smart
enough to do this?
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a1c5b8dbdfed..139799f8a8a1 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2077,12 +2077,12 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2077 | rcu_read_lock(); | 2077 | rcu_read_lock(); |
2078 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; | 2078 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; |
2079 | rth = rcu_dereference(rth->u.dst.rt_next)) { | 2079 | rth = rcu_dereference(rth->u.dst.rt_next)) { |
2080 | if (rth->fl.fl4_dst == daddr && | 2080 | if (((rth->fl.fl4_dst ^ daddr) | |
2081 | rth->fl.fl4_src == saddr && | 2081 | (rth->fl.fl4_src ^ saddr) | |
2082 | rth->fl.iif == iif && | 2082 | (rth->fl.iif ^ iif) | |
2083 | rth->fl.oif == 0 && | 2083 | rth->fl.oif | |
2084 | (rth->fl.fl4_tos ^ tos)) == 0 && | ||
2084 | rth->fl.mark == skb->mark && | 2085 | rth->fl.mark == skb->mark && |
2085 | rth->fl.fl4_tos == tos && | ||
2086 | net_eq(dev_net(rth->u.dst.dev), net) && | 2086 | net_eq(dev_net(rth->u.dst.dev), net) && |
2087 | rth->rt_genid == atomic_read(&rt_genid)) { | 2087 | rth->rt_genid == atomic_read(&rt_genid)) { |
2088 | dst_use(&rth->u.dst, jiffies); | 2088 | dst_use(&rth->u.dst, jiffies); |