aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-11-11 02:14:07 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-11 13:29:40 -0500
commit72cdd1d971c0deb1619c5c339270570c43647a78 (patch)
tree15e3c63cf135818ae1b5cbc9d85ef2c48c03804c /net/ipv4/route.c
parent46b13fc5c0f239f36e84665c73087d5fa86bfd86 (diff)
net: get rid of rtable->idev
It seems idev field in struct rtable has no special purpose, but adding extra atomic ops. We hold refcounts on the device itself (using percpu data, so pretty cheap in current kernel). infiniband case is solved using dst.dev instead of idev->dev Removal of this field means routing without route cache is now using shared data, percpu data, and only potential contention is a pair of atomic ops on struct neighbour per forwarded packet. About 5% speedup on routing test. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Hal Rosenstock <hal.rosenstock@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 987bf9adb318..5955965c7953 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -140,13 +140,15 @@ static unsigned long expires_ljiffies;
140 140
141static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie); 141static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie);
142static void ipv4_dst_destroy(struct dst_entry *dst); 142static void ipv4_dst_destroy(struct dst_entry *dst);
143static void ipv4_dst_ifdown(struct dst_entry *dst,
144 struct net_device *dev, int how);
145static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst); 143static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst);
146static void ipv4_link_failure(struct sk_buff *skb); 144static void ipv4_link_failure(struct sk_buff *skb);
147static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu); 145static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu);
148static int rt_garbage_collect(struct dst_ops *ops); 146static int rt_garbage_collect(struct dst_ops *ops);
149 147
148static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
149 int how)
150{
151}
150 152
151static struct dst_ops ipv4_dst_ops = { 153static struct dst_ops ipv4_dst_ops = {
152 .family = AF_INET, 154 .family = AF_INET,
@@ -1433,8 +1435,6 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1433 rt->dst.child = NULL; 1435 rt->dst.child = NULL;
1434 if (rt->dst.dev) 1436 if (rt->dst.dev)
1435 dev_hold(rt->dst.dev); 1437 dev_hold(rt->dst.dev);
1436 if (rt->idev)
1437 in_dev_hold(rt->idev);
1438 rt->dst.obsolete = -1; 1438 rt->dst.obsolete = -1;
1439 rt->dst.lastuse = jiffies; 1439 rt->dst.lastuse = jiffies;
1440 rt->dst.path = &rt->dst; 1440 rt->dst.path = &rt->dst;
@@ -1728,33 +1728,13 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
1728{ 1728{
1729 struct rtable *rt = (struct rtable *) dst; 1729 struct rtable *rt = (struct rtable *) dst;
1730 struct inet_peer *peer = rt->peer; 1730 struct inet_peer *peer = rt->peer;
1731 struct in_device *idev = rt->idev;
1732 1731
1733 if (peer) { 1732 if (peer) {
1734 rt->peer = NULL; 1733 rt->peer = NULL;
1735 inet_putpeer(peer); 1734 inet_putpeer(peer);
1736 } 1735 }
1737
1738 if (idev) {
1739 rt->idev = NULL;
1740 in_dev_put(idev);
1741 }
1742} 1736}
1743 1737
1744static void ipv4_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
1745 int how)
1746{
1747 struct rtable *rt = (struct rtable *) dst;
1748 struct in_device *idev = rt->idev;
1749 if (dev != dev_net(dev)->loopback_dev && idev && idev->dev == dev) {
1750 struct in_device *loopback_idev =
1751 in_dev_get(dev_net(dev)->loopback_dev);
1752 if (loopback_idev) {
1753 rt->idev = loopback_idev;
1754 in_dev_put(idev);
1755 }
1756 }
1757}
1758 1738
1759static void ipv4_link_failure(struct sk_buff *skb) 1739static void ipv4_link_failure(struct sk_buff *skb)
1760{ 1740{
@@ -1910,7 +1890,6 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1910 rth->fl.iif = dev->ifindex; 1890 rth->fl.iif = dev->ifindex;
1911 rth->dst.dev = init_net.loopback_dev; 1891 rth->dst.dev = init_net.loopback_dev;
1912 dev_hold(rth->dst.dev); 1892 dev_hold(rth->dst.dev);
1913 rth->idev = in_dev_get(rth->dst.dev);
1914 rth->fl.oif = 0; 1893 rth->fl.oif = 0;
1915 rth->rt_gateway = daddr; 1894 rth->rt_gateway = daddr;
1916 rth->rt_spec_dst= spec_dst; 1895 rth->rt_spec_dst= spec_dst;
@@ -2050,7 +2029,6 @@ static int __mkroute_input(struct sk_buff *skb,
2050 rth->fl.iif = in_dev->dev->ifindex; 2029 rth->fl.iif = in_dev->dev->ifindex;
2051 rth->dst.dev = (out_dev)->dev; 2030 rth->dst.dev = (out_dev)->dev;
2052 dev_hold(rth->dst.dev); 2031 dev_hold(rth->dst.dev);
2053 rth->idev = in_dev_get(rth->dst.dev);
2054 rth->fl.oif = 0; 2032 rth->fl.oif = 0;
2055 rth->rt_spec_dst= spec_dst; 2033 rth->rt_spec_dst= spec_dst;
2056 2034
@@ -2231,7 +2209,6 @@ local_input:
2231 rth->fl.iif = dev->ifindex; 2209 rth->fl.iif = dev->ifindex;
2232 rth->dst.dev = net->loopback_dev; 2210 rth->dst.dev = net->loopback_dev;
2233 dev_hold(rth->dst.dev); 2211 dev_hold(rth->dst.dev);
2234 rth->idev = in_dev_get(rth->dst.dev);
2235 rth->rt_gateway = daddr; 2212 rth->rt_gateway = daddr;
2236 rth->rt_spec_dst= spec_dst; 2213 rth->rt_spec_dst= spec_dst;
2237 rth->dst.input= ip_local_deliver; 2214 rth->dst.input= ip_local_deliver;
@@ -2417,9 +2394,6 @@ static int __mkroute_output(struct rtable **result,
2417 if (!rth) 2394 if (!rth)
2418 return -ENOBUFS; 2395 return -ENOBUFS;
2419 2396
2420 in_dev_hold(in_dev);
2421 rth->idev = in_dev;
2422
2423 atomic_set(&rth->dst.__refcnt, 1); 2397 atomic_set(&rth->dst.__refcnt, 1);
2424 rth->dst.flags= DST_HOST; 2398 rth->dst.flags= DST_HOST;
2425 if (IN_DEV_CONF_GET(in_dev, NOXFRM)) 2399 if (IN_DEV_CONF_GET(in_dev, NOXFRM))
@@ -2759,9 +2733,6 @@ static int ipv4_dst_blackhole(struct net *net, struct rtable **rp, struct flowi
2759 2733
2760 rt->fl = ort->fl; 2734 rt->fl = ort->fl;
2761 2735
2762 rt->idev = ort->idev;
2763 if (rt->idev)
2764 in_dev_hold(rt->idev);
2765 rt->rt_genid = rt_genid(net); 2736 rt->rt_genid = rt_genid(net);
2766 rt->rt_flags = ort->rt_flags; 2737 rt->rt_flags = ort->rt_flags;
2767 rt->rt_type = ort->rt_type; 2738 rt->rt_type = ort->rt_type;