aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-04-28 17:13:38 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-29 01:25:59 -0400
commit5c1e6aa300a7a669dc469d2dcb20172c6bd8fed9 (patch)
tree61796a49f8b9236eee4730ff8142e79bd43f0f51 /net/ipv6/route.c
parent778865a550e7958c1211242cc481f48d46de0f04 (diff)
net: Make dst_alloc() take more explicit initializations.
Now the dst->dev, dev->obsolete, and dst->flags values can be specified as well. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 19a77d0e0308..e8b2bb9060ef 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -227,9 +227,10 @@ static struct rt6_info ip6_blk_hole_entry_template = {
227#endif 227#endif
228 228
229/* allocate dst with ip6_dst_ops */ 229/* allocate dst with ip6_dst_ops */
230static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops) 230static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops,
231 struct net_device *dev)
231{ 232{
232 return (struct rt6_info *)dst_alloc(ops, 0); 233 return (struct rt6_info *)dst_alloc(ops, dev, 0, 0, 0);
233} 234}
234 235
235static void ip6_dst_destroy(struct dst_entry *dst) 236static void ip6_dst_destroy(struct dst_entry *dst)
@@ -881,10 +882,10 @@ EXPORT_SYMBOL(ip6_route_output);
881 882
882struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig) 883struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig)
883{ 884{
884 struct rt6_info *rt = dst_alloc(&ip6_dst_blackhole_ops, 1); 885 struct rt6_info *rt, *ort = (struct rt6_info *) dst_orig;
885 struct rt6_info *ort = (struct rt6_info *) dst_orig;
886 struct dst_entry *new = NULL; 886 struct dst_entry *new = NULL;
887 887
888 rt = dst_alloc(&ip6_dst_blackhole_ops, ort->dst.dev, 1, 0, 0);
888 if (rt) { 889 if (rt) {
889 new = &rt->dst; 890 new = &rt->dst;
890 891
@@ -893,9 +894,6 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
893 new->output = dst_discard; 894 new->output = dst_discard;
894 895
895 dst_copy_metrics(new, &ort->dst); 896 dst_copy_metrics(new, &ort->dst);
896 new->dev = ort->dst.dev;
897 if (new->dev)
898 dev_hold(new->dev);
899 rt->rt6i_idev = ort->rt6i_idev; 897 rt->rt6i_idev = ort->rt6i_idev;
900 if (rt->rt6i_idev) 898 if (rt->rt6i_idev)
901 in6_dev_hold(rt->rt6i_idev); 899 in6_dev_hold(rt->rt6i_idev);
@@ -1038,13 +1036,12 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1038 if (unlikely(idev == NULL)) 1036 if (unlikely(idev == NULL))
1039 return NULL; 1037 return NULL;
1040 1038
1041 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); 1039 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev);
1042 if (unlikely(rt == NULL)) { 1040 if (unlikely(rt == NULL)) {
1043 in6_dev_put(idev); 1041 in6_dev_put(idev);
1044 goto out; 1042 goto out;
1045 } 1043 }
1046 1044
1047 dev_hold(dev);
1048 if (neigh) 1045 if (neigh)
1049 neigh_hold(neigh); 1046 neigh_hold(neigh);
1050 else { 1047 else {
@@ -1053,7 +1050,6 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1053 neigh = NULL; 1050 neigh = NULL;
1054 } 1051 }
1055 1052
1056 rt->rt6i_dev = dev;
1057 rt->rt6i_idev = idev; 1053 rt->rt6i_idev = idev;
1058 rt->rt6i_nexthop = neigh; 1054 rt->rt6i_nexthop = neigh;
1059 atomic_set(&rt->dst.__refcnt, 1); 1055 atomic_set(&rt->dst.__refcnt, 1);
@@ -1212,7 +1208,7 @@ int ip6_route_add(struct fib6_config *cfg)
1212 goto out; 1208 goto out;
1213 } 1209 }
1214 1210
1215 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); 1211 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL);
1216 1212
1217 if (rt == NULL) { 1213 if (rt == NULL) {
1218 err = -ENOMEM; 1214 err = -ENOMEM;
@@ -1731,7 +1727,8 @@ void rt6_pmtu_discovery(const struct in6_addr *daddr, const struct in6_addr *sad
1731static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) 1727static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
1732{ 1728{
1733 struct net *net = dev_net(ort->rt6i_dev); 1729 struct net *net = dev_net(ort->rt6i_dev);
1734 struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); 1730 struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops,
1731 ort->dst.dev);
1735 1732
1736 if (rt) { 1733 if (rt) {
1737 rt->dst.input = ort->dst.input; 1734 rt->dst.input = ort->dst.input;
@@ -1739,9 +1736,6 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
1739 1736
1740 dst_copy_metrics(&rt->dst, &ort->dst); 1737 dst_copy_metrics(&rt->dst, &ort->dst);
1741 rt->dst.error = ort->dst.error; 1738 rt->dst.error = ort->dst.error;
1742 rt->dst.dev = ort->dst.dev;
1743 if (rt->dst.dev)
1744 dev_hold(rt->dst.dev);
1745 rt->rt6i_idev = ort->rt6i_idev; 1739 rt->rt6i_idev = ort->rt6i_idev;
1746 if (rt->rt6i_idev) 1740 if (rt->rt6i_idev)
1747 in6_dev_hold(rt->rt6i_idev); 1741 in6_dev_hold(rt->rt6i_idev);
@@ -2011,7 +2005,8 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2011 int anycast) 2005 int anycast)
2012{ 2006{
2013 struct net *net = dev_net(idev->dev); 2007 struct net *net = dev_net(idev->dev);
2014 struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); 2008 struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops,
2009 net->loopback_dev);
2015 struct neighbour *neigh; 2010 struct neighbour *neigh;
2016 2011
2017 if (rt == NULL) { 2012 if (rt == NULL) {
@@ -2021,13 +2016,11 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2021 return ERR_PTR(-ENOMEM); 2016 return ERR_PTR(-ENOMEM);
2022 } 2017 }
2023 2018
2024 dev_hold(net->loopback_dev);
2025 in6_dev_hold(idev); 2019 in6_dev_hold(idev);
2026 2020
2027 rt->dst.flags = DST_HOST; 2021 rt->dst.flags = DST_HOST;
2028 rt->dst.input = ip6_input; 2022 rt->dst.input = ip6_input;
2029 rt->dst.output = ip6_output; 2023 rt->dst.output = ip6_output;
2030 rt->rt6i_dev = net->loopback_dev;
2031 rt->rt6i_idev = idev; 2024 rt->rt6i_idev = idev;
2032 rt->dst.obsolete = -1; 2025 rt->dst.obsolete = -1;
2033 2026