diff options
author | Wolfram Sang <wsa@kernel.org> | 2020-05-20 15:27:45 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@kernel.org> | 2020-05-20 15:27:45 +0200 |
commit | f89c326dcaa0cb8c3af7764e75eeed4e3f3c879a (patch) | |
tree | 31a5967da1f04180a1a922258f6947ad17255ee8 /net/ipv6/icmp.c | |
parent | i2c: core: support bus regulator controlling in adapter (diff) | |
parent | MAINTAINERS: add maintainer for mediatek i2c controller driver (diff) | |
download | linux-f89c326dcaa0cb8c3af7764e75eeed4e3f3c879a.tar.xz linux-f89c326dcaa0cb8c3af7764e75eeed4e3f3c879a.zip |
Merge branch 'i2c/for-current-fixed' into i2c/for-5.8
Diffstat (limited to 'net/ipv6/icmp.c')
-rw-r--r-- | net/ipv6/icmp.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 2688f3e82165..fc5000370030 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -229,6 +229,25 @@ static bool icmpv6_xrlim_allow(struct sock *sk, u8 type, return res; } +static bool icmpv6_rt_has_prefsrc(struct sock *sk, u8 type, + struct flowi6 *fl6) +{ + struct net *net = sock_net(sk); + struct dst_entry *dst; + bool res = false; + + dst = ip6_route_output(net, sk, fl6); + if (!dst->error) { + struct rt6_info *rt = (struct rt6_info *)dst; + struct in6_addr prefsrc; + + rt6_get_prefsrc(rt, &prefsrc); + res = !ipv6_addr_any(&prefsrc); + } + dst_release(dst); + return res; +} + /* * an inline helper for the "simple" if statement below * checks if parameter problem report is caused by an @@ -527,7 +546,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, saddr = force_saddr; if (saddr) { fl6.saddr = *saddr; - } else { + } else if (!icmpv6_rt_has_prefsrc(sk, type, &fl6)) { /* select a more meaningful saddr from input if */ struct net_device *in_netdev; |