aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-12-29 18:51:57 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-29 18:51:57 -0500
commit8ade06c616b34b4237c0ed77d1ff0ce04ad7d056 (patch)
tree73cccfb3f6ca9cb8d2d9fcd9aed5a2bffb8ab49d /net/ipv6/route.c
parentf1776dade17cd54562f4bc1d01de89c4908b4dd0 (diff)
ipv6: Fix neigh lookup using NULL device.
In some of the rt6_bind_neighbour() call sites, it hasn't hooked up the rt->dst.dev pointer yet, so we'd deref a NULL pointer when obtaining dev->ifindex for the neighbour hash function computation. Just pass the netdevice explicitly in to fix this problem. Reported-by: Bjarke Istrup Pedersen <gurligebis@gentoo.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 30de9e74a813..4a62c47599b4 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -129,11 +129,14 @@ static struct neighbour *ip6_neigh_lookup(const struct dst_entry *dst, const voi
129 return neigh_create(&nd_tbl, daddr, dst->dev); 129 return neigh_create(&nd_tbl, daddr, dst->dev);
130} 130}
131 131
132static int rt6_bind_neighbour(struct rt6_info *rt) 132static int rt6_bind_neighbour(struct rt6_info *rt, struct net_device *dev)
133{ 133{
134 struct neighbour *n = ip6_neigh_lookup(&rt->dst, &rt->rt6i_gateway); 134 struct neighbour *n = __ipv6_neigh_lookup(&nd_tbl, dev, &rt->rt6i_gateway);
135 if (IS_ERR(n)) 135 if (!n) {
136 return PTR_ERR(n); 136 n = neigh_create(&nd_tbl, &rt->rt6i_gateway, dev);
137 if (IS_ERR(n))
138 return PTR_ERR(n);
139 }
137 dst_set_neighbour(&rt->dst, n); 140 dst_set_neighbour(&rt->dst, n);
138 141
139 return 0; 142 return 0;
@@ -746,7 +749,7 @@ static struct rt6_info *rt6_alloc_cow(const struct rt6_info *ort,
746#endif 749#endif
747 750
748 retry: 751 retry:
749 if (rt6_bind_neighbour(rt)) { 752 if (rt6_bind_neighbour(rt, rt->dst.dev)) {
750 struct net *net = dev_net(rt->dst.dev); 753 struct net *net = dev_net(rt->dst.dev);
751 int saved_rt_min_interval = 754 int saved_rt_min_interval =
752 net->ipv6.sysctl.ip6_rt_gc_min_interval; 755 net->ipv6.sysctl.ip6_rt_gc_min_interval;
@@ -1397,7 +1400,7 @@ int ip6_route_add(struct fib6_config *cfg)
1397 rt->rt6i_prefsrc.plen = 0; 1400 rt->rt6i_prefsrc.plen = 0;
1398 1401
1399 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { 1402 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) {
1400 err = rt6_bind_neighbour(rt); 1403 err = rt6_bind_neighbour(rt, dev);
1401 if (err) 1404 if (err)
1402 goto out; 1405 goto out;
1403 } 1406 }
@@ -2084,7 +2087,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2084 rt->rt6i_flags |= RTF_ANYCAST; 2087 rt->rt6i_flags |= RTF_ANYCAST;
2085 else 2088 else
2086 rt->rt6i_flags |= RTF_LOCAL; 2089 rt->rt6i_flags |= RTF_LOCAL;
2087 err = rt6_bind_neighbour(rt); 2090 err = rt6_bind_neighbour(rt, rt->dst.dev);
2088 if (err) { 2091 if (err) {
2089 dst_free(&rt->dst); 2092 dst_free(&rt->dst);
2090 return ERR_PTR(err); 2093 return ERR_PTR(err);