* [PATCH net] ping: fix the sk_bound_dev_if match in ping_lookup
@ 2022-01-22 11:40 Xin Long
2022-01-24 12:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2022-01-22 11:40 UTC (permalink / raw)
To: network dev; +Cc: davem, kuba, Vasiliy Kulikov, Hangbin Liu
When 'ping' changes to use PING socket instead of RAW socket by:
# sysctl -w net.ipv4.ping_group_range="0 100"
the selftests 'router_broadcast.sh' will fail, as such command
# ip vrf exec vrf-h1 ping -I veth0 198.51.100.255 -b
can't receive the response skb by the PING socket. It's caused by mismatch
of sk_bound_dev_if and dif in ping_rcv() when looking up the PING socket,
as dif is vrf-h1 if dif's master was set to vrf-h1.
This patch is to fix this regression by also checking the sk_bound_dev_if
against sdif so that the packets can stil be received even if the socket
is not bound to the vrf device but to the real iif.
Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/ipv4/ping.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 0e56df3a45e2..bcf7bc71cb56 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -220,7 +220,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)
continue;
}
- if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)
+ if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif &&
+ sk->sk_bound_dev_if != inet_sdif(skb))
continue;
sock_hold(sk);
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] ping: fix the sk_bound_dev_if match in ping_lookup
2022-01-22 11:40 [PATCH net] ping: fix the sk_bound_dev_if match in ping_lookup Xin Long
@ 2022-01-24 12:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-24 12:40 UTC (permalink / raw)
To: Xin Long; +Cc: netdev, davem, kuba, segoon, liuhangbin
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 22 Jan 2022 06:40:56 -0500 you wrote:
> When 'ping' changes to use PING socket instead of RAW socket by:
>
> # sysctl -w net.ipv4.ping_group_range="0 100"
>
> the selftests 'router_broadcast.sh' will fail, as such command
>
> # ip vrf exec vrf-h1 ping -I veth0 198.51.100.255 -b
>
> [...]
Here is the summary with links:
- [net] ping: fix the sk_bound_dev_if match in ping_lookup
https://git.kernel.org/netdev/net/c/2afc3b5a31f9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-24 12:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 11:40 [PATCH net] ping: fix the sk_bound_dev_if match in ping_lookup Xin Long
2022-01-24 12:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).