Re: [PATCH v2 8/8] selftests/nfsd: add a per-netns rpcbind stub and the listener round-trips

"Chuck Lever" <[email protected]>
Newsgroups gmane.linux.nfs,gmane.linux.kernel,gmane.linux.network
Message-ID <[email protected]>

On Tue, Aug 11, 2026, at 8:03 AM, Jeff Layton wrote:
> Creating a listener registers with rpcbind: svc_xprt_create_from_sa() passes
> flags of 0, so pmap_register is true in svc_setup_socket(), and
> nfsd_version3 is enabled by default and does not set vs_rpcb_optnl, so a
> registration failure aborts listener creation. A fresh netns has no rpcbind,
> and reaching the host's is not an option -- svc_rpcb_setup() opens by
> calling svc_unregister(), which would clear the host's nfsd entries.

>  /* --------------------------- fixture --------------------------- */
> 
>  FIXTURE(nfsd_listener) {
> -	int placeholder;
> +	pid_t rpcbd;
>  };
> 
>  FIXTURE_SETUP(nfsd_listener)
> @@ -369,14 +665,35 @@ FIXTURE_SETUP(nfsd_listener)
>  	nfsd_family = genl_resolve_nfsd();
>  	if (nfsd_family < 0)
>  		SKIP(return, "nfsd genl family not found (modprobe nfsd?)");
> +
> +	if (rpcb_stats_alloc() < 0)
> +		SKIP(return, "mmap(rpcbind stub counters): %s", strerror(errno));
> +
> +	self->rpcbd = rpcb_stub_start(RPCB_STUB_ACCEPT);
> +	if (self->rpcbd < 0)
> +		SKIP(return, "cannot start the rpcbind stub: %s",
> +		     strerror(errno));
>  }
> 
>  FIXTURE_TEARDOWN(nfsd_listener)
>  {
> +	if (self->rpcbd > 0) {
> +		kill(self->rpcbd, SIGKILL);
> +		waitpid(self->rpcbd, NULL, 0);
> +	}
> +	if (rpcb_stats) {
> +		munmap((void *)rpcb_stats, sizeof(*rpcb_stats));
> +		rpcb_stats = NULL;
> +	}
>  }

The fixture appears to leak the network namespace for the tests that
finish with a listener still up. Would something along these lines in
FIXTURE_TEARDOWN() cover it?

	/* A live listener pins the netns; drop any serv the test made. */
	if (listener_set(NULL, 0) == -EBUSY)
		threads_set(0);


-- 
Chuck Lever
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.