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]
Message-ID: <20191125222958.aaplyw7ebtqs6yyl@kafai-mbp>
Date:   Mon, 25 Nov 2019 22:30:01 +0000
From:   Martin Lau <kafai@...com>
To:     Jakub Sitnicki <jakub@...udflare.com>
CC:     "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "kernel-team@...udflare.com" <kernel-team@...udflare.com>,
        John Fastabend <john.fastabend@...il.com>
Subject: Re: [PATCH bpf-next 7/8] selftests/bpf: Extend SK_REUSEPORT tests to
 cover SOCKMAP

On Sat, Nov 23, 2019 at 12:07:50PM +0100, Jakub Sitnicki wrote:
> Parametrize the SK_REUSEPORT tests so that the map type for storing sockets
> can be selected at run-time. Also allow choosing which L4 protocols get
> tested.
If new cmdline args are added to select different subtests,
I would prefer to move it to the test_progs framework and reuse the subtests
support in test_progs commit 3a516a0a3a7b ("selftests/bpf: add sub-tests support for test_progs").
Its default is to run all instead of having a separate bash script to
do that.

> 
> Run the extended reuseport program test two times, once for
> REUSEPORT_ARRAY, and once for SOCKMAP but just with TCP to cover the newly
> enabled map type.
> 
> Signed-off-by: Jakub Sitnicki <jakub@...udflare.com>

[ ... ]
> +static const char *family_to_str(int family)
> +{
> +	switch (family) {
> +	case AF_INET:
> +		return "IPv4";
> +	case AF_INET6:
> +		return "IPv6";
> +	default:
> +		return "unknown";
> +	}
> +}
> +
> +static const char *type_to_str(int type)
> +{
> +	switch (type) {
> +	case SOCK_STREAM:
> +		return "TCP";
> +	case SOCK_DGRAM:
> +		return "UDP";
> +	default:
> +		return "unknown";
> +	}
> +}
+1

[ ... ]
> +static void parse_opts(int argc, char **argv)
> +{
> +	unsigned int sock_types = 0;
> +	int c;
> +
> +	while ((c = getopt(argc, argv, "hm:tu")) != -1) {
> +		switch (c) {
> +		case 'h':
> +			usage();
> +			break;
> +		case 'm':
> +			cfg_map_type = parse_map_type(optarg);
> +			break;
> +		case 't':
> +			sock_types |= 1 << SOCK_STREAM;
> +			break;
> +		case 'u':
> +			sock_types |= 1 << SOCK_DGRAM;
> +			break;
>  		}
>  	}
> +
> +	if (cfg_map_type == BPF_MAP_TYPE_UNSPEC)
> +		usage();
> +	if (sock_types != 0)
> +		cfg_sock_types = sock_types;
>  }
>  
> -int main(int argc, const char **argv)
> +int main(int argc, char **argv)
>  {
> +	parse_opts(argc, argv);
>  	create_maps();
>  	prepare_bpf_obj();
>  	saved_tcp_fo = read_int_sysctl(TCP_FO_SYSCTL);
> diff --git a/tools/testing/selftests/bpf/test_select_reuseport.sh b/tools/testing/selftests/bpf/test_select_reuseport.sh
> new file mode 100755
> index 000000000000..1951b4886021
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/test_select_reuseport.sh
> @@ -0,0 +1,14 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +set -eu
> +
> +DIR=$(dirname $0)
> +
> +echo "Testing reuseport with REUSEPORT_SOCKARRAY..."
> +$DIR/test_select_reuseport -m reuseport_sockarray
> +
> +echo "Testing reuseport with SOCKMAP (TCP only)..."
> +$DIR/test_select_reuseport -m sockmap -t
> +
> +exit 0
> -- 
> 2.20.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ