child_process_create_ns has a race when it's called in parallel.
This can be observed when creating two non-conflicting namespaces at the same time e.g. in two concurrently running tests.
The error is rtnetlink::ns: mkdir error: EEXIST: File exists.
There are two races
- When creating the directory here
- When the mount is set up here
Expected behavior
Creating multiple namespaces concurrently should succeed.
Only the mount initialization needs serialization; namespace file creation is already safe.
Suggested fix
- Ignore EEXIST errors when creating the directory
/run/netns/
- Take an exclusive file lock on
/run/netns/ before configuring the mount
This is actually the behavior of iproute2.
Would you accept a PR? I can open one implementing this if desired.