]> git.ipfire.org Git - thirdparty/iproute2.git/commit
ip: Exit exec in child process if setup fails
authorYedaya Katsman <yedaya.ka@gmail.com>
Tue, 23 Apr 2024 18:38:20 +0000 (21:38 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 25 Apr 2024 19:00:25 +0000 (12:00 -0700)
commit70ba338cd8314410380b8bdae9e5f302e8e98039
tree2dddad3fcf1657d832f750d611cf1127d96ff336
parent911c62bf9de61da7aa03e1cd5e5db26322d12aa9
ip: Exit exec in child process if setup fails

If we forked, returning from the function will make the calling code to
continue in both the child and parent process. Make cmd_exec exit if
setup failed and it forked already.

An example of issues this causes, where a failure in setup causes
multiple unnecessary tries:

```
$ ip netns
ef
ab
$ ip -all netns exec ls

netns: ef
setting the network namespace "ef" failed: Operation not permitted

netns: ab
setting the network namespace "ab" failed: Operation not permitted

netns: ab
setting the network namespace "ab" failed: Operation not permitted
```

Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
lib/exec.c