Skip to content

Commit 6fd6ce2

Browse files
yoshfujidavem330
authored andcommitted
ipv6: Do not depend on rt->n in ip6_finish_output2().
If neigh is not found, create new one. Signed-off-by: YOSHIFUJI Hideaki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 707be1f commit 6fd6ce2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

net/ipv6/ip6_output.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ static int ip6_finish_output2(struct sk_buff *skb)
8888
struct dst_entry *dst = skb_dst(skb);
8989
struct net_device *dev = dst->dev;
9090
struct neighbour *neigh;
91-
struct rt6_info *rt;
91+
struct in6_addr *nexthop;
92+
int ret;
9293

9394
skb->protocol = htons(ETH_P_IPV6);
9495
skb->dev = dev;
@@ -123,10 +124,17 @@ static int ip6_finish_output2(struct sk_buff *skb)
123124
skb->len);
124125
}
125126

126-
rt = (struct rt6_info *) dst;
127-
neigh = rt->n;
128-
if (neigh)
129-
return dst_neigh_output(dst, neigh, skb);
127+
rcu_read_lock_bh();
128+
nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr);
129+
neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop);
130+
if (unlikely(!neigh))
131+
neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
132+
if (!IS_ERR(neigh)) {
133+
ret = dst_neigh_output(dst, neigh, skb);
134+
rcu_read_unlock_bh();
135+
return ret;
136+
}
137+
rcu_read_unlock_bh();
130138

131139
IP6_INC_STATS_BH(dev_net(dst->dev),
132140
ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);

0 commit comments

Comments
 (0)