Skip to content

Commit

Permalink
ipv6: Do not depend on rt->n in ip6_finish_output2().
Browse files Browse the repository at this point in the history
If neigh is not found, create new one.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
yoshfuji authored and davem330 committed Jan 17, 2013
1 parent 707be1f commit 6fd6ce2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions net/ipv6/ip6_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ static int ip6_finish_output2(struct sk_buff *skb)
struct dst_entry *dst = skb_dst(skb);
struct net_device *dev = dst->dev;
struct neighbour *neigh;
struct rt6_info *rt;
struct in6_addr *nexthop;
int ret;

skb->protocol = htons(ETH_P_IPV6);
skb->dev = dev;
Expand Down Expand Up @@ -123,10 +124,17 @@ static int ip6_finish_output2(struct sk_buff *skb)
skb->len);
}

rt = (struct rt6_info *) dst;
neigh = rt->n;
if (neigh)
return dst_neigh_output(dst, neigh, skb);
rcu_read_lock_bh();
nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr);
neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop);
if (unlikely(!neigh))
neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
if (!IS_ERR(neigh)) {
ret = dst_neigh_output(dst, neigh, skb);
rcu_read_unlock_bh();
return ret;
}
rcu_read_unlock_bh();

IP6_INC_STATS_BH(dev_net(dst->dev),
ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
Expand Down

0 comments on commit 6fd6ce2

Please sign in to comment.