Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jingjing Xu
Tue, 10 Nov 2026 03:39
[PATCH net] selftests: net: cmsg_sender: retain the resolved address family
Author: Jingjing Xu
Date: Tue, 10 Nov 2026 03:39
Date: Tue, 10 Nov 2026 03:39
40 lines
10064 bytes
10064 bytes
When neither -4 nor -6 is supplied, getaddrinfo() selects the socket
family but opt.sock.family remains AF_UNSPEC. The cmsg and socket option
helpers then take the IPv6 branch even for an IPv4 socket.
For example, an IPv4 loopback packet sent with -l 11 arrived with the
default TTL of 64 on the test host. Using -L 11 instead failed with
ENOPROTOOPT because the tool tried IPV6_UNICAST_HOPS on an IPv4 socket.
Explicit -4 works in both cases.
Record the selected ai_family after successful address resolution so the
helpers use the same family as the socket.
Discovered by Codex-assisted code inspection and tested with real
loopback UDP traffic, without kernel instrumentation. Covered IPv4 and
IPv6, automatic and explicit family selection, and cmsg and setsockopt
hop limits. All eight cases receive the requested value after the fix.
Built through the net selftest Makefile and with GCC -Wall -Werror.
Fixes: 2e5584e0f913 ("selftests/net: expand cmsg_ipv6.sh with ipv4")
Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
---
tools/testing/selftests/net/cmsg_sender.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c
index 67a72b1a2f3d..01617a021338 100644
--- a/tools/testing/selftests/net/cmsg_sender.c
+++ b/tools/testing/selftests/net/cmsg_sender.c
@@ -495,6 +495,7 @@ int main(int argc, char *argv[])
goto err_free_buff;
}
+ opt.sock.family = ai->ai_family;
if (ai->ai_family == AF_INET6 && opt.sock.proto == IPPROTO_ICMP)
opt.sock.proto = IPPROTO_ICMPV6;
base-commit: 1d5e2c57e9ffc134e14b3f837c8d7c53b508bd22
--
2.53.0
Re: [PATCH net] selftests: net: cmsg_sender: retain the resolved address family
Author: Hangbin Liu
Date: Tue, 10 Nov 2026 06:33
Date: Tue, 10 Nov 2026 06:33
43 lines
10070 bytes
10070 bytes
On Tue, Nov 10, 2026 at 03:39:18AM +0000, Jingjing Xu wrote:
> When neither -4 nor -6 is supplied, getaddrinfo() selects the socket
> family but opt.sock.family remains AF_UNSPEC. The cmsg and socket option
> helpers then take the IPv6 branch even for an IPv4 socket.
>
> For example, an IPv4 loopback packet sent with -l 11 arrived with the
> default TTL of 64 on the test host. Using -L 11 instead failed with
> ENOPROTOOPT because the tool tried IPV6_UNICAST_HOPS on an IPv4 socket.
> Explicit -4 works in both cases.
>
> Record the selected ai_family after successful address resolution so the
> helpers use the same family as the socket.
>
> Discovered by Codex-assisted code inspection and tested with real
> loopback UDP traffic, without kernel instrumentation. Covered IPv4 and
> IPv6, automatic and explicit family selection, and cmsg and setsockopt
> hop limits. All eight cases receive the requested value after the fix.
> Built through the net selftest Makefile and with GCC -Wall -Werror.
>
> Fixes: 2e5584e0f913 ("selftests/net: expand cmsg_ipv6.sh with ipv4")
> Signed-off-by: Jingjing Xu <xujingjing@cmss.chinamobile.com>
> ---
> tools/testing/selftests/net/cmsg_sender.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c
> index 67a72b1a2f3d..01617a021338 100644
> --- a/tools/testing/selftests/net/cmsg_sender.c
> +++ b/tools/testing/selftests/net/cmsg_sender.c
> @@ -495,6 +495,7 @@ int main(int argc, char *argv[])
> goto err_free_buff;
> }
>
> + opt.sock.family = ai->ai_family;
> if (ai->ai_family == AF_INET6 && opt.sock.proto == IPPROTO_ICMP)
> opt.sock.proto = IPPROTO_ICMPV6;
>
> base-commit: 1d5e2c57e9ffc134e14b3f837c8d7c53b508bd22
> --
> 2.53.0
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Re: [PATCH net] selftests: net: cmsg_sender: retain the resolved address family
Author: patchwork-bot+netdevbpf
Date: Thu, 12 Nov 2026 17:20
Date: Thu, 12 Nov 2026 17:20
26 lines
8831 bytes
8831 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 10 Nov 2026 03:39:18 +0000 you wrote:
> When neither -4 nor -6 is supplied, getaddrinfo() selects the socket
> family but opt.sock.family remains AF_UNSPEC. The cmsg and socket option
> helpers then take the IPv6 branch even for an IPv4 socket.
>
> For example, an IPv4 loopback packet sent with -l 11 arrived with the
> default TTL of 64 on the test host. Using -L 11 instead failed with
> ENOPROTOOPT because the tool tried IPV6_UNICAST_HOPS on an IPv4 socket.
> Explicit -4 works in both cases.
>
> [...]
Here is the summary with links:
- [net] selftests: net: cmsg_sender: retain the resolved address family
https://git.kernel.org/netdev/net-next/c/3e9089d1499a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads