Re: [PATCH v2 7/7] checks/integration: Adapt networking test for ipv6

Alyssa Ross
2025-11-29T13:26:12Z

[-- Attachment #1: Type: text/plain, Size: 2659 bytes --]

Yureka Lilian <yureka@cyberchaos.dev> writes:

> Signed-off-by: Yureka Lilian <yureka@cyberchaos.dev>
> ---
> release/checks/integration/default.nix | 2 +-
> release/checks/integration/networking.c | 32 +++++++++++++++++++------
> 2 files changed, 26 insertions(+), 8 deletions(-)

Reviewed-by: Alyssa Ross <hi@alyssa.is>

Presumably the IPv4 networking test stopped working at some point in
this series though, so we should disable it there at re-enable it here
so that we don't have commits that don't build.

> diff --git a/release/checks/integration/networking.c b/release/checks/integration/networking.c
> index 97d7895..6600385 100644
> --- a/release/checks/integration/networking.c
> +++ b/release/checks/integration/networking.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: EUPL-1.2+
> // SPDX-FileCopyrightText: 2025 Alyssa Ross <hi@alyssa.is>
> +// SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>
>
> #include "lib.h"
>
> @@ -12,21 +13,23 @@
> #include <net/if.h>
>
> #include <sys/ioctl.h>
> +#include <linux/ipv6.h>
>
> static int setup_server(void)
> {
> int fd;
> struct ifreq ifr;
> + struct in6_ifreq ifr6;
>
> - struct sockaddr_in addr = {
> - .sin_family = AF_INET,
> - .sin_port = htons(1234),
> - .sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) },
> + struct sockaddr_in6 addr = {
> + .sin6_family = AF_INET6,
> + .sin6_port = htons(1234),
> + .sin6_addr = { .s6_addr = { 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 } },
> };

Just a thought: could we declare and fill in ifr6 here, rather than
filling it in later?

> sprintf(ifr.ifr_name, "lo");
>
> - if ((fd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0)) == -1) {
> + if ((fd = socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, 0)) == -1) {
> perror("socket");
> exit(EXIT_FAILURE);
> }
> @@ -42,11 +45,26 @@ static int setup_server(void)
> exit(EXIT_FAILURE);
> }
>
> - if (bind(fd, &addr, sizeof addr) == -1) {
> - perror("bind");
> + ifr6.ifr6_ifindex = 1;
> + ifr6.ifr6_addr = addr.sin6_addr;
> + ifr6.ifr6_prefixlen = 128;
> + if (ioctl(fd, SIOCSIFADDR, &ifr6) == -1) {
> + perror("SIOCSIFADDR");
> + exit(EXIT_FAILURE);
> + }
> +
> + if ((fd = socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, 0)) == -1) {
> + perror("socket");
> exit(EXIT_FAILURE);
> }
>
> + int tries = 0;
> + while (bind(fd, &addr, sizeof addr) == -1) {
> + perror("bind");
> + if (tries++ >= 5)
> + exit(EXIT_FAILURE);
> + }
> +

I really want to figure out why this happens, but not a blocker.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]