bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Lau <kafai@fb.com>
To: Jakub Sitnicki <jakub@cloudflare.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"kernel-team@cloudflare.com" <kernel-team@cloudflare.com>,
	John Fastabend <john.fastabend@gmail.com>
Subject: Re: [PATCH bpf-next 7/8] selftests/bpf: Extend SK_REUSEPORT tests to cover SOCKMAP
Date: Mon, 25 Nov 2019 22:30:01 +0000	[thread overview]
Message-ID: <20191125222958.aaplyw7ebtqs6yyl@kafai-mbp> (raw)
In-Reply-To: <20191123110751.6729-8-jakub@cloudflare.com>

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@cloudflare.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
> 

  parent reply	other threads:[~2019-11-25 22:30 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 11:07 [PATCH bpf-next 0/8] Extend SOCKMAP to store listening sockets Jakub Sitnicki
2019-11-23 11:07 ` [PATCH bpf-next 1/8] bpf, sockmap: Return socket cookie on lookup from syscall Jakub Sitnicki
2019-11-24  5:32   ` John Fastabend
2019-11-23 11:07 ` [PATCH bpf-next 2/8] bpf, sockmap: Let all kernel-land lookup values in SOCKMAP Jakub Sitnicki
2019-11-24  5:35   ` John Fastabend
2019-11-23 11:07 ` [PATCH bpf-next 3/8] bpf, sockmap: Allow inserting listening TCP sockets into SOCKMAP Jakub Sitnicki
2019-11-24  5:38   ` John Fastabend
2019-11-23 11:07 ` [PATCH bpf-next 4/8] bpf, sockmap: Don't let child socket inherit psock or its ops on copy Jakub Sitnicki
2019-11-24  5:56   ` John Fastabend
2019-11-25 22:38   ` Martin Lau
2019-11-26 15:54     ` Jakub Sitnicki
2019-11-26 17:16       ` Martin Lau
2019-11-26 18:36         ` Jakub Sitnicki
     [not found]           ` <87sglsfdda.fsf@cloudflare.com>
2019-12-11 17:20             ` Martin Lau
2019-12-12 11:27               ` Jakub Sitnicki
2019-12-12 19:23                 ` Martin Lau
2019-12-17 15:06                   ` Jakub Sitnicki
2019-11-26 18:43         ` John Fastabend
2019-11-27 22:18           ` Jakub Sitnicki
2019-11-23 11:07 ` [PATCH bpf-next 5/8] bpf: Allow selecting reuseport socket from a SOCKMAP Jakub Sitnicki
2019-11-24  5:57   ` John Fastabend
2019-11-25  1:24   ` Alexei Starovoitov
2019-11-25  4:17     ` John Fastabend
2019-11-25 10:40       ` Jakub Sitnicki
2019-11-25 22:07         ` Martin Lau
2019-11-26 14:30           ` Jakub Sitnicki
2019-11-26 19:03             ` Martin Lau
2019-11-27 21:34               ` Jakub Sitnicki
2019-11-23 11:07 ` [PATCH bpf-next 6/8] libbpf: Recognize SK_REUSEPORT programs from section name Jakub Sitnicki
2019-11-24  5:57   ` John Fastabend
2019-11-23 11:07 ` [PATCH bpf-next 7/8] selftests/bpf: Extend SK_REUSEPORT tests to cover SOCKMAP Jakub Sitnicki
2019-11-24  6:00   ` John Fastabend
2019-11-25 22:30   ` Martin Lau [this message]
2019-11-26 14:32     ` Jakub Sitnicki
2019-12-12 10:30     ` Jakub Sitnicki
2019-11-23 11:07 ` [PATCH bpf-next 8/8] selftests/bpf: Tests for SOCKMAP holding listening sockets Jakub Sitnicki
2019-11-24  6:04   ` John Fastabend
2019-11-24  6:10 ` [PATCH bpf-next 0/8] Extend SOCKMAP to store " John Fastabend
2019-11-25  9:22   ` Jakub Sitnicki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191125222958.aaplyw7ebtqs6yyl@kafai-mbp \
    --to=kafai@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).