diff options
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 5f0043c30b70..19c906f6efa1 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -311,12 +311,21 @@ static inline void rt6_probe(struct rt6_info *rt) | |||
311 | static int inline rt6_check_dev(struct rt6_info *rt, int oif) | 311 | static int inline rt6_check_dev(struct rt6_info *rt, int oif) |
312 | { | 312 | { |
313 | struct net_device *dev = rt->rt6i_dev; | 313 | struct net_device *dev = rt->rt6i_dev; |
314 | if (!oif || dev->ifindex == oif) | 314 | int ret = 0; |
315 | |||
316 | if (!oif) | ||
315 | return 2; | 317 | return 2; |
316 | if ((dev->flags & IFF_LOOPBACK) && | 318 | if (dev->flags & IFF_LOOPBACK) { |
317 | rt->rt6i_idev && rt->rt6i_idev->dev->ifindex == oif) | 319 | if (!WARN_ON(rt->rt6i_idev == NULL) && |
318 | return 1; | 320 | rt->rt6i_idev->dev->ifindex == oif) |
319 | return 0; | 321 | ret = 1; |
322 | else | ||
323 | return 0; | ||
324 | } | ||
325 | if (dev->ifindex == oif) | ||
326 | return 2; | ||
327 | |||
328 | return ret; | ||
320 | } | 329 | } |
321 | 330 | ||
322 | static int inline rt6_check_neigh(struct rt6_info *rt) | 331 | static int inline rt6_check_neigh(struct rt6_info *rt) |
@@ -2040,7 +2049,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2040 | 2049 | ||
2041 | nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); | 2050 | nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtm), flags); |
2042 | if (nlh == NULL) | 2051 | if (nlh == NULL) |
2043 | return -ENOBUFS; | 2052 | return -EMSGSIZE; |
2044 | 2053 | ||
2045 | rtm = nlmsg_data(nlh); | 2054 | rtm = nlmsg_data(nlh); |
2046 | rtm->rtm_family = AF_INET6; | 2055 | rtm->rtm_family = AF_INET6; |
@@ -2111,7 +2120,8 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2111 | return nlmsg_end(skb, nlh); | 2120 | return nlmsg_end(skb, nlh); |
2112 | 2121 | ||
2113 | nla_put_failure: | 2122 | nla_put_failure: |
2114 | return nlmsg_cancel(skb, nlh); | 2123 | nlmsg_cancel(skb, nlh); |
2124 | return -EMSGSIZE; | ||
2115 | } | 2125 | } |
2116 | 2126 | ||
2117 | int rt6_dump_route(struct rt6_info *rt, void *p_arg) | 2127 | int rt6_dump_route(struct rt6_info *rt, void *p_arg) |
@@ -2222,9 +2232,12 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | |||
2222 | goto errout; | 2232 | goto errout; |
2223 | 2233 | ||
2224 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); | 2234 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); |
2225 | /* failure implies BUG in rt6_nlmsg_size() */ | 2235 | if (err < 0) { |
2226 | BUG_ON(err < 0); | 2236 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ |
2227 | 2237 | WARN_ON(err == -EMSGSIZE); | |
2238 | kfree_skb(skb); | ||
2239 | goto errout; | ||
2240 | } | ||
2228 | err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); | 2241 | err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); |
2229 | errout: | 2242 | errout: |
2230 | if (err < 0) | 2243 | if (err < 0) |