public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 net-next v2] ipv6: use the right ifindex when replying to icmpv6 from localhost
@ 2026-01-07 15:38 Fernando Fernandez Mancera
  2026-01-07 15:38 ` [PATCH 2/2 net-next v2] selftests: ipv6_icmp: add tests for ICMPv6 handling Fernando Fernandez Mancera
  2026-01-07 17:05 ` [PATCH 1/2 net-next v2] ipv6: use the right ifindex when replying to icmpv6 from localhost Brian Haley
  0 siblings, 2 replies; 9+ messages in thread
From: Fernando Fernandez Mancera @ 2026-01-07 15:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, dsahern, kuba, pabeni, horms, shuah, linux-kselftest,
	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
---
 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 5d2f90babaa5..5de254043133 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -965,7 +965,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_type(&fl6.daddr) & IPV6_ADDR_LOOPBACK ?
+			 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] 9+ messages in thread

end of thread, other threads:[~2026-01-20 19:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 15:38 [PATCH 1/2 net-next v2] ipv6: use the right ifindex when replying to icmpv6 from localhost Fernando Fernandez Mancera
2026-01-07 15:38 ` [PATCH 2/2 net-next v2] selftests: ipv6_icmp: add tests for ICMPv6 handling Fernando Fernandez Mancera
2026-01-07 16:41   ` David Ahern
2026-01-08 11:24     ` Fernando Fernandez Mancera
2026-01-08 15:20       ` David Ahern
2026-01-20 19:24         ` Fernando Fernandez Mancera
2026-01-20 19:44           ` Fernando Fernandez Mancera
2026-01-07 17:05 ` [PATCH 1/2 net-next v2] ipv6: use the right ifindex when replying to icmpv6 from localhost Brian Haley
2026-01-08 11:27   ` Fernando Fernandez Mancera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox