* [PATCH net V3] net: ping6: Fix ping -6 with interface name
@ 2022-05-31 8:45 Tariq Toukan
2022-05-31 14:31 ` David Ahern
2022-06-01 11:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Tariq Toukan @ 2022-05-31 8:45 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Eric Dumazet, David Ahern
Cc: netdev, Hideaki YOSHIFUJI, Paolo Abeni, Aya Levin, Gal Pressman,
Saeed Mahameed, Tariq Toukan
From: Aya Levin <ayal@nvidia.com>
When passing interface parameter to ping -6:
$ ping -6 ::11:141:84:9 -I eth2
Results in:
PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
ping: sendmsg: Invalid argument
ping: sendmsg: Invalid argument
Initialize the fl6's outgoing interface (OIF) before triggering
ip6_datagram_send_ctl. Don't wipe fl6 after ip6_datagram_send_ctl() as
changes in fl6 that may happen in the function are overwritten explicitly.
Update comment accordingly.
Fixes: 13651224c00b ("net: ping6: support setting basic SOL_IPV6 options via cmsg")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
net/ipv6/ping.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
V3:
Per David Ahern's comment, moved fl6.flowi6_oif init to the
shared flow right after the memset.
V2:
Per David Ahern's comment, moved memset before if (msg->msg_controllen),
and updated the code comment accordingly.
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
index ff033d16549e..ecf3a553a0dc 100644
--- a/net/ipv6/ping.c
+++ b/net/ipv6/ping.c
@@ -101,6 +101,9 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
ipc6.sockc.tsflags = sk->sk_tsflags;
ipc6.sockc.mark = sk->sk_mark;
+ memset(&fl6, 0, sizeof(fl6));
+ fl6.flowi6_oif = oif;
+
if (msg->msg_controllen) {
struct ipv6_txoptions opt = {};
@@ -112,17 +115,14 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
return err;
/* Changes to txoptions and flow info are not implemented, yet.
- * Drop the options, fl6 is wiped below.
+ * Drop the options.
*/
ipc6.opt = NULL;
}
- memset(&fl6, 0, sizeof(fl6));
-
fl6.flowi6_proto = IPPROTO_ICMPV6;
fl6.saddr = np->saddr;
fl6.daddr = *daddr;
- fl6.flowi6_oif = oif;
fl6.flowi6_mark = ipc6.sockc.mark;
fl6.flowi6_uid = sk->sk_uid;
fl6.fl6_icmp_type = user_icmph.icmp6_type;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net V3] net: ping6: Fix ping -6 with interface name
2022-05-31 8:45 [PATCH net V3] net: ping6: Fix ping -6 with interface name Tariq Toukan
@ 2022-05-31 14:31 ` David Ahern
2022-06-01 9:40 ` Aya Levin
2022-06-01 11:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2022-05-31 14:31 UTC (permalink / raw)
To: Tariq Toukan, David S. Miller, Jakub Kicinski, Eric Dumazet
Cc: netdev, Hideaki YOSHIFUJI, Paolo Abeni, Aya Levin, Gal Pressman,
Saeed Mahameed
On 5/31/22 2:45 AM, Tariq Toukan wrote:
> From: Aya Levin <ayal@nvidia.com>
>
> When passing interface parameter to ping -6:
> $ ping -6 ::11:141:84:9 -I eth2
> Results in:
> PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
> ping: sendmsg: Invalid argument
> ping: sendmsg: Invalid argument
>
> Initialize the fl6's outgoing interface (OIF) before triggering
> ip6_datagram_send_ctl. Don't wipe fl6 after ip6_datagram_send_ctl() as
> changes in fl6 that may happen in the function are overwritten explicitly.
> Update comment accordingly.
>
> Fixes: 13651224c00b ("net: ping6: support setting basic SOL_IPV6 options via cmsg")
> Signed-off-by: Aya Levin <ayal@nvidia.com>
> Reviewed-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
> net/ipv6/ping.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> V3:
> Per David Ahern's comment, moved fl6.flowi6_oif init to the
> shared flow right after the memset.
>
> V2:
> Per David Ahern's comment, moved memset before if (msg->msg_controllen),
> and updated the code comment accordingly.
>
Reviewed-by: David Ahern <dsahern@kernel.org>
The patch set with the Fixes tag added selftests using cmsg_sender.c.
You can extend it to support IPV6_PKTINFO and submit a selftest for this
case to -next when it opens.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net V3] net: ping6: Fix ping -6 with interface name
2022-05-31 14:31 ` David Ahern
@ 2022-06-01 9:40 ` Aya Levin
0 siblings, 0 replies; 4+ messages in thread
From: Aya Levin @ 2022-06-01 9:40 UTC (permalink / raw)
To: David Ahern, Tariq Toukan, David S. Miller, Jakub Kicinski, Eric Dumazet
Cc: netdev, Hideaki YOSHIFUJI, Paolo Abeni, Gal Pressman, Saeed Mahameed
On 5/31/2022 5:31 PM, David Ahern wrote:
> On 5/31/22 2:45 AM, Tariq Toukan wrote:
>> From: Aya Levin <ayal@nvidia.com>
>>
>> When passing interface parameter to ping -6:
>> $ ping -6 ::11:141:84:9 -I eth2
>> Results in:
>> PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
>> ping: sendmsg: Invalid argument
>> ping: sendmsg: Invalid argument
>>
>> Initialize the fl6's outgoing interface (OIF) before triggering
>> ip6_datagram_send_ctl. Don't wipe fl6 after ip6_datagram_send_ctl() as
>> changes in fl6 that may happen in the function are overwritten explicitly.
>> Update comment accordingly.
>>
>> Fixes: 13651224c00b ("net: ping6: support setting basic SOL_IPV6 options via cmsg")
>> Signed-off-by: Aya Levin <ayal@nvidia.com>
>> Reviewed-by: Gal Pressman <gal@nvidia.com>
>> Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
>> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
>> ---
>> net/ipv6/ping.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> V3:
>> Per David Ahern's comment, moved fl6.flowi6_oif init to the
>> shared flow right after the memset.
>>
>> V2:
>> Per David Ahern's comment, moved memset before if (msg->msg_controllen),
>> and updated the code comment accordingly.
>>
>
> Reviewed-by: David Ahern <dsahern@kernel.org>
Thanks for the review.
>
> The patch set with the Fixes tag added selftests using cmsg_sender.c.
> You can extend it to support IPV6_PKTINFO and submit a selftest for this
> case to -next when it opens.
I'll submit the selftest extension in the coming window
Aya
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net V3] net: ping6: Fix ping -6 with interface name
2022-05-31 8:45 [PATCH net V3] net: ping6: Fix ping -6 with interface name Tariq Toukan
2022-05-31 14:31 ` David Ahern
@ 2022-06-01 11:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-01 11:30 UTC (permalink / raw)
To: Tariq Toukan
Cc: davem, kuba, edumazet, dsahern, netdev, yoshfuji, pabeni, ayal,
gal, saeedm
Hello:
This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 31 May 2022 11:45:44 +0300 you wrote:
> From: Aya Levin <ayal@nvidia.com>
>
> When passing interface parameter to ping -6:
> $ ping -6 ::11:141:84:9 -I eth2
> Results in:
> PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
> ping: sendmsg: Invalid argument
> ping: sendmsg: Invalid argument
>
> [...]
Here is the summary with links:
- [net,V3] net: ping6: Fix ping -6 with interface name
https://git.kernel.org/netdev/net/c/e6652a8ef3e6
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] 4+ messages in thread
end of thread, other threads:[~2022-06-01 11:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 8:45 [PATCH net V3] net: ping6: Fix ping -6 with interface name Tariq Toukan
2022-05-31 14:31 ` David Ahern
2022-06-01 9:40 ` Aya Levin
2022-06-01 11:30 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.