* [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost
@ 2026-01-21 19:44 Fernando Fernandez Mancera
2026-01-21 19:44 ` [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address " Fernando Fernandez Mancera
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Fernando Fernandez Mancera @ 2026-01-21 19:44 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, kuba, pabeni, horms, shuah, linux-kselftest,
haleyb.dev, Fernando Fernandez Mancera
When replying to a ICMPv6 echo request that comes from localhost address
the right output ifindex is 1 (lo) and not rt6i_idev dev index. Use the
skb device ifindex instead. This fixes pinging to a local address from
localhost source address.
$ ping6 -I ::1 2001:1:1::2 -c 3
PING 2001:1:1::2 (2001:1:1::2) from ::1 : 56 data bytes
64 bytes from 2001:1:1::2: icmp_seq=1 ttl=64 time=0.037 ms
64 bytes from 2001:1:1::2: icmp_seq=2 ttl=64 time=0.069 ms
64 bytes from 2001:1:1::2: icmp_seq=3 ttl=64 time=0.122 ms
2001:1:1::2 ping statistics
3 packets transmitted, 3 received, 0% packet loss, time 2032ms
rtt min/avg/max/mdev = 0.037/0.076/0.122/0.035 ms
Fixes: 1b70d792cf67 ("ipv6: Use rt6i_idev index for echo replies to a local address")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
v2: no changes
v3: use ipv6_addr_loopback() as it is more efficient
---
net/ipv6/icmp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index c72270582d9c..1a25ecb92695 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -966,7 +966,9 @@ static enum skb_drop_reason icmpv6_echo_reply(struct sk_buff *skb)
fl6.daddr = ipv6_hdr(skb)->saddr;
if (saddr)
fl6.saddr = *saddr;
- fl6.flowi6_oif = icmp6_iif(skb);
+ fl6.flowi6_oif = ipv6_addr_loopback(&fl6.daddr) ?
+ skb->dev->ifindex :
+ icmp6_iif(skb);
fl6.fl6_icmp_type = type;
fl6.flowi6_mark = mark;
fl6.flowi6_uid = sock_net_uid(net, NULL);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address from localhost
2026-01-21 19:44 [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost Fernando Fernandez Mancera
@ 2026-01-21 19:44 ` Fernando Fernandez Mancera
2026-01-23 18:13 ` David Ahern
2026-01-23 18:13 ` [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 " David Ahern
2026-01-25 21:50 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Fernando Fernandez Mancera @ 2026-01-21 19:44 UTC (permalink / raw)
To: netdev
Cc: davem, dsahern, kuba, pabeni, horms, shuah, linux-kselftest,
haleyb.dev, Fernando Fernandez Mancera
Test ipv6 pinging to local configured address and linklocal address from
localhost with -I ::1.
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
v2: shellcheck fixes, added VRF based tests and simplified linklocal
address parsing
v3: extend existing test in fcnal-test.sh instead of creating a new one,
notice some shellcheck warnings but I prefer to follow the style of the
existing code. It can be fixed if it is a requirement.
---
tools/testing/selftests/net/fcnal-test.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
index 844a580ae74e..890c3f8e51bb 100755
--- a/tools/testing/selftests/net/fcnal-test.sh
+++ b/tools/testing/selftests/net/fcnal-test.sh
@@ -2327,6 +2327,13 @@ ipv6_ping_novrf()
log_test_addr ${a} $? 2 "ping local, device bind"
done
+ for a in ${NSA_LO_IP6} ${NSA_LINKIP6}%${NSA_DEV} ${NSA_IP6}
+ do
+ log_start
+ run_cmd ${ping6} -c1 -w1 -I ::1 ${a}
+ log_test_addr ${a} $? 0 "ping local, from localhost"
+ done
+
#
# ip rule blocks address
#
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address from localhost
2026-01-21 19:44 ` [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address " Fernando Fernandez Mancera
@ 2026-01-23 18:13 ` David Ahern
0 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2026-01-23 18:13 UTC (permalink / raw)
To: Fernando Fernandez Mancera, netdev
Cc: davem, kuba, pabeni, horms, shuah, linux-kselftest, haleyb.dev
On 1/21/26 12:44 PM, Fernando Fernandez Mancera wrote:
> Test ipv6 pinging to local configured address and linklocal address from
> localhost with -I ::1.
>
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> ---
> v2: shellcheck fixes, added VRF based tests and simplified linklocal
> address parsing
> v3: extend existing test in fcnal-test.sh instead of creating a new one,
> notice some shellcheck warnings but I prefer to follow the style of the
> existing code. It can be fixed if it is a requirement.
> ---
> tools/testing/selftests/net/fcnal-test.sh | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/selftests/net/fcnal-test.sh
> index 844a580ae74e..890c3f8e51bb 100755
> --- a/tools/testing/selftests/net/fcnal-test.sh
> +++ b/tools/testing/selftests/net/fcnal-test.sh
> @@ -2327,6 +2327,13 @@ ipv6_ping_novrf()
> log_test_addr ${a} $? 2 "ping local, device bind"
> done
>
> + for a in ${NSA_LO_IP6} ${NSA_LINKIP6}%${NSA_DEV} ${NSA_IP6}
> + do
> + log_start
> + run_cmd ${ping6} -c1 -w1 -I ::1 ${a}
> + log_test_addr ${a} $? 0 "ping local, from localhost"
> + done
> +
> #
> # ip rule blocks address
> #
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost
2026-01-21 19:44 [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost Fernando Fernandez Mancera
2026-01-21 19:44 ` [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address " Fernando Fernandez Mancera
@ 2026-01-23 18:13 ` David Ahern
2026-01-25 21:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2026-01-23 18:13 UTC (permalink / raw)
To: Fernando Fernandez Mancera, netdev
Cc: davem, kuba, pabeni, horms, shuah, linux-kselftest, haleyb.dev
On 1/21/26 12:44 PM, Fernando Fernandez Mancera wrote:
> When replying to a ICMPv6 echo request that comes from localhost address
> the right output ifindex is 1 (lo) and not rt6i_idev dev index. Use the
> skb device ifindex instead. This fixes pinging to a local address from
> localhost source address.
>
> $ ping6 -I ::1 2001:1:1::2 -c 3
> PING 2001:1:1::2 (2001:1:1::2) from ::1 : 56 data bytes
> 64 bytes from 2001:1:1::2: icmp_seq=1 ttl=64 time=0.037 ms
> 64 bytes from 2001:1:1::2: icmp_seq=2 ttl=64 time=0.069 ms
> 64 bytes from 2001:1:1::2: icmp_seq=3 ttl=64 time=0.122 ms
>
> 2001:1:1::2 ping statistics
> 3 packets transmitted, 3 received, 0% packet loss, time 2032ms
> rtt min/avg/max/mdev = 0.037/0.076/0.122/0.035 ms
>
> Fixes: 1b70d792cf67 ("ipv6: Use rt6i_idev index for echo replies to a local address")
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> ---
> v2: no changes
> v3: use ipv6_addr_loopback() as it is more efficient
> ---
> net/ipv6/icmp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost
2026-01-21 19:44 [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost Fernando Fernandez Mancera
2026-01-21 19:44 ` [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address " Fernando Fernandez Mancera
2026-01-23 18:13 ` [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 " David Ahern
@ 2026-01-25 21:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-25 21:50 UTC (permalink / raw)
To: Fernando Fernandez Mancera
Cc: netdev, davem, dsahern, kuba, pabeni, horms, shuah,
linux-kselftest, haleyb.dev
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 21 Jan 2026 20:44:08 +0100 you wrote:
> When replying to a ICMPv6 echo request that comes from localhost address
> the right output ifindex is 1 (lo) and not rt6i_idev dev index. Use the
> skb device ifindex instead. This fixes pinging to a local address from
> localhost source address.
>
> $ ping6 -I ::1 2001:1:1::2 -c 3
> PING 2001:1:1::2 (2001:1:1::2) from ::1 : 56 data bytes
> 64 bytes from 2001:1:1::2: icmp_seq=1 ttl=64 time=0.037 ms
> 64 bytes from 2001:1:1::2: icmp_seq=2 ttl=64 time=0.069 ms
> 64 bytes from 2001:1:1::2: icmp_seq=3 ttl=64 time=0.122 ms
>
> [...]
Here is the summary with links:
- [1/2,net-next,v3] ipv6: use the right ifindex when replying to icmpv6 from localhost
https://git.kernel.org/netdev/net/c/03cbcdf93866
- [2/2,net-next,v3] selftests: net: add ipv6 ping to local address from localhost
https://git.kernel.org/netdev/net/c/1742272bd3fa
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] 5+ messages in thread
end of thread, other threads:[~2026-01-25 21:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 19:44 [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 from localhost Fernando Fernandez Mancera
2026-01-21 19:44 ` [PATCH 2/2 net-next v3] selftests: net: add ipv6 ping to local address " Fernando Fernandez Mancera
2026-01-23 18:13 ` David Ahern
2026-01-23 18:13 ` [PATCH 1/2 net-next v3] ipv6: use the right ifindex when replying to icmpv6 " David Ahern
2026-01-25 21:50 ` 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