All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Magnus Karlsson <magnus.karlsson@gmail.com>
Cc: <magnus.karlsson@intel.com>, <bjorn@kernel.org>, <ast@kernel.org>,
	<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>, <yhs@fb.com>, <andrii@kernel.org>,
	<martin.lau@linux.dev>, <song@kernel.org>,
	<john.fastabend@gmail.com>, <kpsingh@kernel.org>,
	<sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>,
	<jonathan.lemon@gmail.com>
Subject: Re: [PATCH bpf-next 08/15] selftests/xsk: remove namespaces
Date: Mon, 12 Dec 2022 15:19:36 +0100	[thread overview]
Message-ID: <Y5c4eD2mRT/qHUi4@boxer> (raw)
In-Reply-To: <20221206090826.2957-9-magnus.karlsson@gmail.com>

On Tue, Dec 06, 2022 at 10:08:19AM +0100, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Remove the namespaces used as they fill no function. This will
> simplify the code for speeding up the tests in the following commits.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  tools/testing/selftests/bpf/test_xsk.sh    | 33 +++++++----------
>  tools/testing/selftests/bpf/xsk_prereqs.sh | 12 ++-----
>  tools/testing/selftests/bpf/xskxceiver.c   | 42 +++-------------------
>  tools/testing/selftests/bpf/xskxceiver.h   |  3 --
>  4 files changed, 19 insertions(+), 71 deletions(-)
> 

(...)

> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 72578cebfbf7..0aaf2f0a9d75 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -55,12 +55,11 @@
>   * Flow:
>   * -----
>   * - Single process spawns two threads: Tx and Rx
> - * - Each of these two threads attach to a veth interface within their assigned
> - *   namespaces
> - * - Each thread Creates one AF_XDP socket connected to a unique umem for each
> + * - Each of these two threads attach to a veth interface
> + * - Each thread creates one AF_XDP socket connected to a unique umem for each
>   *   veth interface
> - * - Tx thread Transmits 10k packets from veth<xxxx> to veth<yyyy>
> - * - Rx thread verifies if all 10k packets were received and delivered in-order,
> + * - Tx thread Transmits a number of packets from veth<xxxx> to veth<yyyy>
> + * - Rx thread verifies if all packets were received and delivered in-order,
>   *   and have the right content
>   *
>   * Enable/disable packet dump mode:
> @@ -399,28 +398,6 @@ static void usage(const char *prog)
>  	ksft_print_msg(str, prog);
>  }
>  
> -static int switch_namespace(const char *nsname)
> -{
> -	char fqns[26] = "/var/run/netns/";
> -	int nsfd;
> -
> -	if (!nsname || strlen(nsname) == 0)
> -		return -1;
> -
> -	strncat(fqns, nsname, sizeof(fqns) - strlen(fqns) - 1);
> -	nsfd = open(fqns, O_RDONLY);
> -
> -	if (nsfd == -1)
> -		exit_with_error(errno);
> -
> -	if (setns(nsfd, 0) == -1)
> -		exit_with_error(errno);
> -
> -	print_verbose("NS switched: %s\n", nsname);
> -
> -	return nsfd;
> -}
> -
>  static bool validate_interface(struct ifobject *ifobj)
>  {
>  	if (!strcmp(ifobj->ifname, ""))
> @@ -438,7 +415,7 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
>  	opterr = 0;
>  
>  	for (;;) {
> -		char *sptr, *token;
> +		char *sptr;
>  
>  		c = getopt_long(argc, argv, "i:Dvb", long_options, &option_index);
>  		if (c == -1)
> @@ -455,9 +432,6 @@ static void parse_command_line(struct ifobject *ifobj_tx, struct ifobject *ifobj
>  
>  			sptr = strndupa(optarg, strlen(optarg));

Wasn't this strndupa needed only because of strsep usage?
I feel that now you can just memcpy directly from optarg to ifobj->nsname.

>  			memcpy(ifobj->ifname, strsep(&sptr, ","), MAX_INTERFACE_NAME_CHARS);
> -			token = strsep(&sptr, ",");
> -			if (token)
> -				memcpy(ifobj->nsname, token, MAX_INTERFACES_NAMESPACE_CHARS);
>  			interface_nb++;
>  			break;
>  		case 'D':
> @@ -1283,8 +1257,6 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
>  	int ret, ifindex;
>  	void *bufs;
>  
> -	ifobject->ns_fd = switch_namespace(ifobject->nsname);
> -
>  	if (ifobject->umem->unaligned_mode)
>  		mmap_flags |= MAP_HUGETLB;
>  
> @@ -1843,8 +1815,6 @@ static struct ifobject *ifobject_create(void)
>  	if (!ifobj->umem)
>  		goto out_umem;
>  
> -	ifobj->ns_fd = -1;
> -
>  	return ifobj;
>  
>  out_umem:
> @@ -1856,8 +1826,6 @@ static struct ifobject *ifobject_create(void)
>  
>  static void ifobject_delete(struct ifobject *ifobj)
>  {
> -	if (ifobj->ns_fd != -1)
> -		close(ifobj->ns_fd);
>  	free(ifobj->umem);
>  	free(ifobj->xsk_arr);
>  	free(ifobj);

(...)

  reply	other threads:[~2022-12-12 14:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06  9:08 [PATCH bpf-next 00/15] selftests/xsk: speed-ups, fixes, and new XDP programs Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 01/15] selftests/xsk: print correct payload for packet dump Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 02/15] selftests/xsk: do not close unused file descriptors Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 03/15] selftests/xsk: submit correct number of frames in populate_fill_ring Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 04/15] selftests/xsk: print correct error codes when exiting Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 05/15] selftests/xsk: remove unused variable outstanding_tx Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 06/15] selftests/xsk: add debug option for creating netdevs Magnus Karlsson
2022-12-07 13:39   ` Björn Töpel
2022-12-06  9:08 ` [PATCH bpf-next 07/15] selftests/xsk: get rid of asm store/release implementations Magnus Karlsson
2022-12-06 23:48   ` Daniel Borkmann
2022-12-07  8:23     ` Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 08/15] selftests/xsk: remove namespaces Magnus Karlsson
2022-12-12 14:19   ` Maciej Fijalkowski [this message]
2022-12-14 10:44     ` Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 09/15] selftests/xsk: load and attach XDP program only once per mode Magnus Karlsson
2022-12-12 15:01   ` Maciej Fijalkowski
2022-12-14 10:50     ` Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 10/15] selftests/xsk: remove unnecessary code in control path Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 11/15] selftests/xsk: get rid of built-in XDP program Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 12/15] selftests/xsk: add test when some packets are XDP_DROPed Magnus Karlsson
2022-12-12 15:13   ` Maciej Fijalkowski
2022-12-14 10:53     ` Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 13/15] selftests/xsk: merge dual and single thread dispatchers Magnus Karlsson
2022-12-12 16:10   ` Maciej Fijalkowski
2022-12-14 10:53     ` Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 14/15] selftests/xsk: automatically restore packet stream Magnus Karlsson
2022-12-06  9:08 ` [PATCH bpf-next 15/15] selftests/xsk: automatically switch XDP programs Magnus Karlsson
2022-12-13 13:33   ` Maciej Fijalkowski

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=Y5c4eD2mRT/qHUi4@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.