diff options
author | Eric Dumazet <edumazet@google.com> | 2012-08-03 17:27:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-04 04:27:57 -0400 |
commit | 9eb43e765368f835d92c93844ebce30da7efeb84 (patch) | |
tree | c8ae2176f95886fafd8e70e7c32f2aa6257ca73d /net/ipv4/route.c | |
parent | 40384999d142552b81aeb596c2ae663dd3ff60ce (diff) |
ipv4: Introduce IN_DEV_NET_ROUTE_LOCALNET
performance profiles show a high cost in the IN_DEV_ROUTE_LOCALNET()
call done in ip_route_input_slow(), because of multiple dereferences,
even if cache lines are clean and available in cpu caches.
Since we already have the 'net' pointer, introduce
IN_DEV_NET_ROUTE_LOCALNET() macro avoiding two dereferences
(dev_net(in_dev->dev))
Also change the tests to use IN_DEV_NET_ROUTE_LOCALNET() only if saddr
or/and daddr are loopback addresse.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e4ba974f143c..21ad369014c0 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1587,11 +1587,14 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1587 | if (ipv4_is_zeronet(daddr)) | 1587 | if (ipv4_is_zeronet(daddr)) |
1588 | goto martian_destination; | 1588 | goto martian_destination; |
1589 | 1589 | ||
1590 | if (likely(!IN_DEV_ROUTE_LOCALNET(in_dev))) { | 1590 | /* Following code try to avoid calling IN_DEV_NET_ROUTE_LOCALNET(), |
1591 | if (ipv4_is_loopback(daddr)) | 1591 | * and call it once if daddr or/and saddr are loopback addresses |
1592 | */ | ||
1593 | if (ipv4_is_loopback(daddr)) { | ||
1594 | if (!IN_DEV_NET_ROUTE_LOCALNET(in_dev, net)) | ||
1592 | goto martian_destination; | 1595 | goto martian_destination; |
1593 | 1596 | } else if (ipv4_is_loopback(saddr)) { | |
1594 | if (ipv4_is_loopback(saddr)) | 1597 | if (!IN_DEV_NET_ROUTE_LOCALNET(in_dev, net)) |
1595 | goto martian_source; | 1598 | goto martian_source; |
1596 | } | 1599 | } |
1597 | 1600 | ||