diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2017-08-31 12:11:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-03 13:54:27 -0400 |
commit | 64327fc811268d4a24de03dac242ea29de6be75f (patch) | |
tree | 8e91ed6bde230252c4225219153af5a1682f8544 /include/net/route.h | |
parent | 138e4ad67afd5c6c318b056b4d17c17f2c0ca5c0 (diff) |
ipv4: Don't override return code from ip_route_input_noref()
After ip_route_input() calls ip_route_input_noref(), another
check on skb_dst() is done, but if this fails, we shouldn't
override the return code from ip_route_input_noref(), as it
could have been more specific (i.e. -EHOSTUNREACH).
This also saves one call to skb_dst_force_safe() and one to
skb_dst() in case the ip_route_input_noref() check fails.
Reported-by: Sabrina Dubroca <sdubroca@redhat.com>
Fixes: 9df16efadd2a ("ipv4: call dst_hold_safe() properly")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Acked-by: Wei Wang <weiwan@google.com>
Acked-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/route.h')
-rw-r--r-- | include/net/route.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/net/route.h b/include/net/route.h index cb0a76d9dde1..1b09a9368c68 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -189,10 +189,11 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, | |||
189 | 189 | ||
190 | rcu_read_lock(); | 190 | rcu_read_lock(); |
191 | err = ip_route_input_noref(skb, dst, src, tos, devin); | 191 | err = ip_route_input_noref(skb, dst, src, tos, devin); |
192 | if (!err) | 192 | if (!err) { |
193 | skb_dst_force_safe(skb); | 193 | skb_dst_force_safe(skb); |
194 | if (!skb_dst(skb)) | 194 | if (!skb_dst(skb)) |
195 | err = -EINVAL; | 195 | err = -EINVAL; |
196 | } | ||
196 | rcu_read_unlock(); | 197 | rcu_read_unlock(); |
197 | 198 | ||
198 | return err; | 199 | return err; |