diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-08-26 14:58:37 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-08-30 19:43:31 +0200 |
commit | 9e0dbc8948138053a8cc8e5a98632fafdead921f (patch) | |
tree | b6f84ebf0b061e6219509cf8febdbfbb7eed8552 /pasta.c | |
parent | 70389d364089f7e9f132f712f6b2d6ab2b129453 (diff) | |
download | passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar.gz passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar.bz2 passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar.lz passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar.xz passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.tar.zst passt-9e0dbc8948138053a8cc8e5a98632fafdead921f.zip |
More deterministic detection of whether argument is a PID, PATH or NAME
pasta takes as its only non-option argument either a PID to attach to the
namespaces of, a PATH to a network namespace or a NAME of a network
namespace (relative to /run/netns). Currently to determine which it is
we try all 3 in that order, and if anything goes wrong we move onto the
next.
This has the potential to cause very confusing failure modes. e.g. if the
argument is intended to be a network namespace name, but a (non-namespace)
file of the same name exists in the current directory.
Make behaviour more predictable by choosing how to treat the argument based
only on the argument's contents, not anything else on the system:
- If it's a decimal integer treat it as a PID
- Otherwise, if it has no '/' characters, treat it as a netns name
(ip-netns doesn't allow '/' in netns names)
- Otherwise, treat it as a netns path
If you want to open a persistent netns in the current directory, you can
use './netns'.
This also allows us to split the parsing of the PID|PATH|NAME option from
the actual opening of the namespaces. In turn that allows us to put the
opening of existing namespaces next to the opening of new namespaces in
pasta_start_ns. That makes the logical flow easier to follow and will
enable later cleanups.
Caveats:
- The separation of functions mean we will always generate the basename
and dirname for the netns_quit system, even when using PID namespaces.
This is pointless, since the netns_quit system doesn't work for non
persistent namespaces, but is harmless.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pasta.c')
0 files changed, 0 insertions, 0 deletions