Skip to content

[BUG] vnoded can be very slow to close all fds #961

@steve-pexip

Description

@steve-pexip

netns/vnode_server.c:vnoded() includes the following code:

  /* try to close any open files */
  if ((openmax = sysconf(_SC_OPEN_MAX)) < 0)
    openmax = 1024;
  assert(openmax >= _POSIX_OPEN_MAX);
  for (i = 3; i < openmax; i++)
    if (i != ctrlfd)
      close(i);

On systems running containers of Debian 13 trixie or Ubuntu 24.04, the default maximum number of open files is a very large number:

lump:~$ docker run -it ubuntu:latest bash -c "ulimit -n"
1073741816
lump:~$ docker run -it debian:trixie bash -c "ulimit -n"
1073741816

and not a more typical value (1024) that one might expect. Whether these values make any sense is a matter for debate elsewhere, but it has noticeable effects on some software, core included.

We use core to set up emulated networks for QA on our product, and we've observed that the close() loop above can take several minutes to iterate over a billion possible file descriptors trying to close them all. This is causing issues for us.

We're using version 8.2.0, but the same code is still present in git HEAD as of today. We have a patch that helps, PR coming shortly...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions