lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 14 May 2021 19:05:15 -0700
From:   Martin KaFai Lau <kafai@...com>
To:     Kuniyuki Iwashima <kuniyu@...zon.co.jp>
CC:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Benjamin Herrenschmidt <benh@...zon.com>,
        Kuniyuki Iwashima <kuni1840@...il.com>, <bpf@...r.kernel.org>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 bpf-next 11/11] bpf: Test
 BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

On Mon, May 10, 2021 at 12:44:33PM +0900, Kuniyuki Iwashima wrote:
> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> index 12ee40284da0..2060bc122c53 100644
[ ... ]

> +static int setup_fastopen(char *buf, int size, int *saved_len, bool restore)
> +{
> +	int err = 0, fd, len;
> +
> +	fd = open("/proc/sys/net/ipv4/tcp_fastopen", O_RDWR);
> +	if (!ASSERT_NEQ(fd, -1, "open"))
> +		return -1;
> +
> +	if (restore) {
> +		len = write(fd, buf, *saved_len);
> +		if (!ASSERT_EQ(len, *saved_len, "write - restore"))
> +			err = -1;
> +	} else {
> +		*saved_len = read(fd, buf, size);
> +		if (!ASSERT_GE(*saved_len, 1, "read")) {
> +			err = -1;
> +			goto close;
> +		}
> +
> +		err = lseek(fd, 0, SEEK_SET);
> +		if (!ASSERT_OK(err, "lseek"))
> +			goto close;
> +
> +		/* (TFO_CLIENT_ENABLE | TFO_SERVER_ENABLE) */
> +		len = write(fd, "3", 1);
> +		if (!ASSERT_EQ(len, 1, "write - setup"))
Is it to trigger the tcp_try_fastopen() case?
I am not sure it is enough.  At least, I think not for the
very first connection before the cookie is saved.
The second run of the test may be able to trigger it.

setsockopt(TCP_FASTOPEN_NO_COOKIE) or another value in the
"/proc/sys/net/ipv4/tcp_fastopen" (ip-sysctl.rst) may be
needed.

> +			err = -1;
> +	}
> +
> +close:
> +	close(fd);
> +
> +	return err;
> +}
> +
[ ... ]

> diff --git a/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c b/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c
> new file mode 100644
> index 000000000000..72978b5d1fcb
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c
> @@ -0,0 +1,67 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Check if we can migrate child sockets.
> + *
> + *   1. If reuse_md->migrating_sk is NULL (SYN packet),
> + *        return SK_PASS without selecting a listener.
> + *   2. If reuse_md->migrating_sk is not NULL (socket migration),
> + *        select a listener (reuseport_map[migrate_map[cookie]])
> + *
> + * Author: Kuniyuki Iwashima <kuniyu@...zon.co.jp>
> + */
> +
> +#include <stddef.h>
> +#include <linux/bpf.h>
> +#include <bpf/bpf_helpers.h>
> +
> +struct {
> +	__uint(type, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY);
> +	__uint(max_entries, 256);
> +	__type(key, int);
> +	__type(value, __u64);
> +} reuseport_map SEC(".maps");
> +
> +struct {
> +	__uint(type, BPF_MAP_TYPE_HASH);
> +	__uint(max_entries, 256);
> +	__type(key, __u64);
> +	__type(value, int);
> +} migrate_map SEC(".maps");
> +
> +int migrated_at_close SEC(".data");
> +int migrated_at_send_synack SEC(".data");
> +int migrated_at_recv_ack SEC(".data");
int migrated_at_close = 0;
int migrated_at_send_synack = 0;
int migrated_at_recv_ack = 0;

and then use skel->bss->migrated_at_* in migrate_reuseport.c.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ