aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/ip6_route.h6
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/route.c8
3 files changed, 10 insertions, 8 deletions
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 5cba2302a7a6..b906f4a131a4 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -194,11 +194,9 @@ static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
194 skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb)); 194 skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
195} 195}
196 196
197static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt, struct in6_addr *dest) 197static inline struct in6_addr *rt6_nexthop(struct rt6_info *rt)
198{ 198{
199 if (rt->rt6i_flags & RTF_GATEWAY || !ipv6_addr_any(&rt->rt6i_gateway)) 199 return &rt->rt6i_gateway;
200 return &rt->rt6i_gateway;
201 return dest;
202} 200}
203 201
204#endif 202#endif
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 12ef531b64ec..878f8027ebf6 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -130,7 +130,7 @@ static int ip6_finish_output2(struct sk_buff *skb)
130 } 130 }
131 131
132 rcu_read_lock_bh(); 132 rcu_read_lock_bh();
133 nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr); 133 nexthop = rt6_nexthop((struct rt6_info *)dst);
134 neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop); 134 neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop);
135 if (unlikely(!neigh)) 135 if (unlikely(!neigh))
136 neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false); 136 neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false);
@@ -898,7 +898,7 @@ static int ip6_dst_lookup_tail(struct sock *sk,
898 */ 898 */
899 rt = (struct rt6_info *) *dst; 899 rt = (struct rt6_info *) *dst;
900 rcu_read_lock_bh(); 900 rcu_read_lock_bh();
901 n = __ipv6_neigh_lookup_noref(rt->dst.dev, rt6_nexthop(rt, &fl6->daddr)); 901 n = __ipv6_neigh_lookup_noref(rt->dst.dev, rt6_nexthop(rt));
902 err = n && !(n->nud_state & NUD_VALID) ? -EINVAL : 0; 902 err = n && !(n->nud_state & NUD_VALID) ? -EINVAL : 0;
903 rcu_read_unlock_bh(); 903 rcu_read_unlock_bh();
904 904
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index bacce6c08644..225de3ec8351 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -848,7 +848,6 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort,
848 if (ort->rt6i_dst.plen != 128 && 848 if (ort->rt6i_dst.plen != 128 &&
849 ipv6_addr_equal(&ort->rt6i_dst.addr, daddr)) 849 ipv6_addr_equal(&ort->rt6i_dst.addr, daddr))
850 rt->rt6i_flags |= RTF_ANYCAST; 850 rt->rt6i_flags |= RTF_ANYCAST;
851 rt->rt6i_gateway = *daddr;
852 } 851 }
853 852
854 rt->rt6i_flags |= RTF_CACHE; 853 rt->rt6i_flags |= RTF_CACHE;
@@ -1245,6 +1244,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1245 rt->dst.flags |= DST_HOST; 1244 rt->dst.flags |= DST_HOST;
1246 rt->dst.output = ip6_output; 1245 rt->dst.output = ip6_output;
1247 atomic_set(&rt->dst.__refcnt, 1); 1246 atomic_set(&rt->dst.__refcnt, 1);
1247 rt->rt6i_gateway = fl6->daddr;
1248 rt->rt6i_dst.addr = fl6->daddr; 1248 rt->rt6i_dst.addr = fl6->daddr;
1249 rt->rt6i_dst.plen = 128; 1249 rt->rt6i_dst.plen = 128;
1250 rt->rt6i_idev = idev; 1250 rt->rt6i_idev = idev;
@@ -1801,7 +1801,10 @@ static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,
1801 in6_dev_hold(rt->rt6i_idev); 1801 in6_dev_hold(rt->rt6i_idev);
1802 rt->dst.lastuse = jiffies; 1802 rt->dst.lastuse = jiffies;
1803 1803
1804 rt->rt6i_gateway = ort->rt6i_gateway; 1804 if (ort->rt6i_flags & RTF_GATEWAY)
1805 rt->rt6i_gateway = ort->rt6i_gateway;
1806 else
1807 rt->rt6i_gateway = *dest;
1805 rt->rt6i_flags = ort->rt6i_flags; 1808 rt->rt6i_flags = ort->rt6i_flags;
1806 if ((ort->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) == 1809 if ((ort->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ==
1807 (RTF_DEFAULT | RTF_ADDRCONF)) 1810 (RTF_DEFAULT | RTF_ADDRCONF))
@@ -2088,6 +2091,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2088 else 2091 else
2089 rt->rt6i_flags |= RTF_LOCAL; 2092 rt->rt6i_flags |= RTF_LOCAL;
2090 2093
2094 rt->rt6i_gateway = *addr;
2091 rt->rt6i_dst.addr = *addr; 2095 rt->rt6i_dst.addr = *addr;
2092 rt->rt6i_dst.plen = 128; 2096 rt->rt6i_dst.plen = 128;
2093 rt->rt6i_table = fib6_get_table(net, RT6_TABLE_LOCAL); 2097 rt->rt6i_table = fib6_get_table(net, RT6_TABLE_LOCAL);