diff options
author | David S. Miller <davem@davemloft.net> | 2011-04-28 17:31:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-29 01:26:00 -0400 |
commit | cf91166223772ef4a2ed98b9874958bf6a2470df (patch) | |
tree | f8c86cc60798db9e4469031a8dceb5fcb512fb81 /net/ipv4 | |
parent | 5c1e6aa300a7a669dc469d2dcb20172c6bd8fed9 (diff) |
net: Use non-zero allocations in dst_alloc().
Make dst_alloc() and it's users explicitly initialize the entire
entry.
The zero'ing done by kmem_cache_zalloc() was almost entirely
redundant.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/route.c | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index b471d89b57ee..fb9211adf079 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1830,7 +1830,6 @@ static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *oldflp4, | |||
1830 | #endif | 1830 | #endif |
1831 | set_class_tag(rt, itag); | 1831 | set_class_tag(rt, itag); |
1832 | #endif | 1832 | #endif |
1833 | rt->rt_type = type; | ||
1834 | } | 1833 | } |
1835 | 1834 | ||
1836 | static struct rtable *rt_dst_alloc(struct net_device *dev, | 1835 | static struct rtable *rt_dst_alloc(struct net_device *dev, |
@@ -1877,25 +1876,28 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1877 | if (!rth) | 1876 | if (!rth) |
1878 | goto e_nobufs; | 1877 | goto e_nobufs; |
1879 | 1878 | ||
1879 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
1880 | rth->dst.tclassid = itag; | ||
1881 | #endif | ||
1880 | rth->dst.output = ip_rt_bug; | 1882 | rth->dst.output = ip_rt_bug; |
1881 | 1883 | ||
1882 | rth->rt_key_dst = daddr; | 1884 | rth->rt_key_dst = daddr; |
1883 | rth->rt_dst = daddr; | ||
1884 | rth->rt_tos = tos; | ||
1885 | rth->rt_mark = skb->mark; | ||
1886 | rth->rt_key_src = saddr; | 1885 | rth->rt_key_src = saddr; |
1886 | rth->rt_genid = rt_genid(dev_net(dev)); | ||
1887 | rth->rt_flags = RTCF_MULTICAST; | ||
1888 | rth->rt_type = RTN_MULTICAST; | ||
1889 | rth->rt_tos = tos; | ||
1890 | rth->rt_dst = daddr; | ||
1887 | rth->rt_src = saddr; | 1891 | rth->rt_src = saddr; |
1888 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
1889 | rth->dst.tclassid = itag; | ||
1890 | #endif | ||
1891 | rth->rt_route_iif = dev->ifindex; | 1892 | rth->rt_route_iif = dev->ifindex; |
1892 | rth->rt_iif = dev->ifindex; | 1893 | rth->rt_iif = dev->ifindex; |
1893 | rth->rt_oif = 0; | 1894 | rth->rt_oif = 0; |
1895 | rth->rt_mark = skb->mark; | ||
1894 | rth->rt_gateway = daddr; | 1896 | rth->rt_gateway = daddr; |
1895 | rth->rt_spec_dst= spec_dst; | 1897 | rth->rt_spec_dst= spec_dst; |
1896 | rth->rt_genid = rt_genid(dev_net(dev)); | 1898 | rth->rt_peer_genid = 0; |
1897 | rth->rt_flags = RTCF_MULTICAST; | 1899 | rth->peer = NULL; |
1898 | rth->rt_type = RTN_MULTICAST; | 1900 | rth->fi = NULL; |
1899 | if (our) { | 1901 | if (our) { |
1900 | rth->dst.input= ip_local_deliver; | 1902 | rth->dst.input= ip_local_deliver; |
1901 | rth->rt_flags |= RTCF_LOCAL; | 1903 | rth->rt_flags |= RTCF_LOCAL; |
@@ -2017,25 +2019,28 @@ static int __mkroute_input(struct sk_buff *skb, | |||
2017 | } | 2019 | } |
2018 | 2020 | ||
2019 | rth->rt_key_dst = daddr; | 2021 | rth->rt_key_dst = daddr; |
2020 | rth->rt_dst = daddr; | ||
2021 | rth->rt_tos = tos; | ||
2022 | rth->rt_mark = skb->mark; | ||
2023 | rth->rt_key_src = saddr; | 2022 | rth->rt_key_src = saddr; |
2023 | rth->rt_genid = rt_genid(dev_net(rth->dst.dev)); | ||
2024 | rth->rt_flags = flags; | ||
2025 | rth->rt_type = res->type; | ||
2026 | rth->rt_tos = tos; | ||
2027 | rth->rt_dst = daddr; | ||
2024 | rth->rt_src = saddr; | 2028 | rth->rt_src = saddr; |
2025 | rth->rt_gateway = daddr; | ||
2026 | rth->rt_route_iif = in_dev->dev->ifindex; | 2029 | rth->rt_route_iif = in_dev->dev->ifindex; |
2027 | rth->rt_iif = in_dev->dev->ifindex; | 2030 | rth->rt_iif = in_dev->dev->ifindex; |
2028 | rth->rt_oif = 0; | 2031 | rth->rt_oif = 0; |
2032 | rth->rt_mark = skb->mark; | ||
2033 | rth->rt_gateway = daddr; | ||
2029 | rth->rt_spec_dst= spec_dst; | 2034 | rth->rt_spec_dst= spec_dst; |
2035 | rth->rt_peer_genid = 0; | ||
2036 | rth->peer = NULL; | ||
2037 | rth->fi = NULL; | ||
2030 | 2038 | ||
2031 | rth->dst.input = ip_forward; | 2039 | rth->dst.input = ip_forward; |
2032 | rth->dst.output = ip_output; | 2040 | rth->dst.output = ip_output; |
2033 | rth->rt_genid = rt_genid(dev_net(rth->dst.dev)); | ||
2034 | 2041 | ||
2035 | rt_set_nexthop(rth, NULL, res, res->fi, res->type, itag); | 2042 | rt_set_nexthop(rth, NULL, res, res->fi, res->type, itag); |
2036 | 2043 | ||
2037 | rth->rt_flags = flags; | ||
2038 | |||
2039 | *result = rth; | 2044 | *result = rth; |
2040 | err = 0; | 2045 | err = 0; |
2041 | cleanup: | 2046 | cleanup: |
@@ -2187,30 +2192,37 @@ local_input: | |||
2187 | if (!rth) | 2192 | if (!rth) |
2188 | goto e_nobufs; | 2193 | goto e_nobufs; |
2189 | 2194 | ||
2195 | rth->dst.input= ip_local_deliver; | ||
2190 | rth->dst.output= ip_rt_bug; | 2196 | rth->dst.output= ip_rt_bug; |
2191 | rth->rt_genid = rt_genid(net); | 2197 | #ifdef CONFIG_IP_ROUTE_CLASSID |
2198 | rth->dst.tclassid = itag; | ||
2199 | #endif | ||
2192 | 2200 | ||
2193 | rth->rt_key_dst = daddr; | 2201 | rth->rt_key_dst = daddr; |
2194 | rth->rt_dst = daddr; | ||
2195 | rth->rt_tos = tos; | ||
2196 | rth->rt_mark = skb->mark; | ||
2197 | rth->rt_key_src = saddr; | 2202 | rth->rt_key_src = saddr; |
2203 | rth->rt_genid = rt_genid(net); | ||
2204 | rth->rt_flags = flags|RTCF_LOCAL; | ||
2205 | rth->rt_type = res.type; | ||
2206 | rth->rt_tos = tos; | ||
2207 | rth->rt_dst = daddr; | ||
2198 | rth->rt_src = saddr; | 2208 | rth->rt_src = saddr; |
2199 | #ifdef CONFIG_IP_ROUTE_CLASSID | 2209 | #ifdef CONFIG_IP_ROUTE_CLASSID |
2200 | rth->dst.tclassid = itag; | 2210 | rth->dst.tclassid = itag; |
2201 | #endif | 2211 | #endif |
2202 | rth->rt_route_iif = dev->ifindex; | 2212 | rth->rt_route_iif = dev->ifindex; |
2203 | rth->rt_iif = dev->ifindex; | 2213 | rth->rt_iif = dev->ifindex; |
2214 | rth->rt_oif = 0; | ||
2215 | rth->rt_mark = skb->mark; | ||
2204 | rth->rt_gateway = daddr; | 2216 | rth->rt_gateway = daddr; |
2205 | rth->rt_spec_dst= spec_dst; | 2217 | rth->rt_spec_dst= spec_dst; |
2206 | rth->dst.input= ip_local_deliver; | 2218 | rth->rt_peer_genid = 0; |
2207 | rth->rt_flags = flags|RTCF_LOCAL; | 2219 | rth->peer = NULL; |
2220 | rth->fi = NULL; | ||
2208 | if (res.type == RTN_UNREACHABLE) { | 2221 | if (res.type == RTN_UNREACHABLE) { |
2209 | rth->dst.input= ip_error; | 2222 | rth->dst.input= ip_error; |
2210 | rth->dst.error= -err; | 2223 | rth->dst.error= -err; |
2211 | rth->rt_flags &= ~RTCF_LOCAL; | 2224 | rth->rt_flags &= ~RTCF_LOCAL; |
2212 | } | 2225 | } |
2213 | rth->rt_type = res.type; | ||
2214 | hash = rt_hash(daddr, saddr, fl4.flowi4_iif, rt_genid(net)); | 2226 | hash = rt_hash(daddr, saddr, fl4.flowi4_iif, rt_genid(net)); |
2215 | rth = rt_intern_hash(hash, rth, skb, fl4.flowi4_iif); | 2227 | rth = rt_intern_hash(hash, rth, skb, fl4.flowi4_iif); |
2216 | err = 0; | 2228 | err = 0; |
@@ -2391,20 +2403,25 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2391 | if (!rth) | 2403 | if (!rth) |
2392 | return ERR_PTR(-ENOBUFS); | 2404 | return ERR_PTR(-ENOBUFS); |
2393 | 2405 | ||
2406 | rth->dst.output = ip_output; | ||
2407 | |||
2394 | rth->rt_key_dst = oldflp4->daddr; | 2408 | rth->rt_key_dst = oldflp4->daddr; |
2395 | rth->rt_tos = tos; | ||
2396 | rth->rt_key_src = oldflp4->saddr; | 2409 | rth->rt_key_src = oldflp4->saddr; |
2397 | rth->rt_oif = oldflp4->flowi4_oif; | 2410 | rth->rt_genid = rt_genid(dev_net(dev_out)); |
2398 | rth->rt_mark = oldflp4->flowi4_mark; | 2411 | rth->rt_flags = flags; |
2412 | rth->rt_type = type; | ||
2413 | rth->rt_tos = tos; | ||
2399 | rth->rt_dst = fl4->daddr; | 2414 | rth->rt_dst = fl4->daddr; |
2400 | rth->rt_src = fl4->saddr; | 2415 | rth->rt_src = fl4->saddr; |
2401 | rth->rt_route_iif = 0; | 2416 | rth->rt_route_iif = 0; |
2402 | rth->rt_iif = oldflp4->flowi4_oif ? : dev_out->ifindex; | 2417 | rth->rt_iif = oldflp4->flowi4_oif ? : dev_out->ifindex; |
2418 | rth->rt_oif = oldflp4->flowi4_oif; | ||
2419 | rth->rt_mark = oldflp4->flowi4_mark; | ||
2403 | rth->rt_gateway = fl4->daddr; | 2420 | rth->rt_gateway = fl4->daddr; |
2404 | rth->rt_spec_dst= fl4->saddr; | 2421 | rth->rt_spec_dst= fl4->saddr; |
2405 | 2422 | rth->rt_peer_genid = 0; | |
2406 | rth->dst.output=ip_output; | 2423 | rth->peer = NULL; |
2407 | rth->rt_genid = rt_genid(dev_net(dev_out)); | 2424 | rth->fi = NULL; |
2408 | 2425 | ||
2409 | RT_CACHE_STAT_INC(out_slow_tot); | 2426 | RT_CACHE_STAT_INC(out_slow_tot); |
2410 | 2427 | ||
@@ -2432,7 +2449,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2432 | 2449 | ||
2433 | rt_set_nexthop(rth, oldflp4, res, fi, type, 0); | 2450 | rt_set_nexthop(rth, oldflp4, res, fi, type, 0); |
2434 | 2451 | ||
2435 | rth->rt_flags = flags; | ||
2436 | return rth; | 2452 | return rth; |
2437 | } | 2453 | } |
2438 | 2454 | ||