aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-02 13:15:40 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-04 01:18:02 +0200
commit6920adda0dce8cc9fb585da658dd983833c2a928 (patch)
tree3edc7bf9b3ca068da5276249a93e6d0a9a3a70ea /conf.c
parentb15ce5b6ceb0ba0cbb91d460c5a745a14c2050df (diff)
downloadpasst-6920adda0dce8cc9fb585da658dd983833c2a928.tar
passt-6920adda0dce8cc9fb585da658dd983833c2a928.tar.gz
passt-6920adda0dce8cc9fb585da658dd983833c2a928.tar.bz2
passt-6920adda0dce8cc9fb585da658dd983833c2a928.tar.lz
passt-6920adda0dce8cc9fb585da658dd983833c2a928.tar.xz
passt-6920adda0dce8cc9fb585da658dd983833c2a928.tar.zst
passt-6920adda0dce8cc9fb585da658dd983833c2a928.zip
util: Make ns_enter() a void function and report setns() errors
ns_enter() returns an integer... but it's always zero. If we actually fail the function doesn't return. Therefore it makes more sense for this to be a function returning void, and we can remove the cases where we pointlessly checked its return value. In addition ns_enter() is usually called from an ephemeral thread created by NS_CALL(). That means that the exit(EXIT_FAILURE) there usually won't be reported (since NS_CALL() doesn't wait() for the thread). So, use die() instead to print out some information in the unlikely event that our setns() here does fail. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/conf.c b/conf.c
index 78eaf2d..a0622d2 100644
--- a/conf.c
+++ b/conf.c
@@ -101,9 +101,10 @@ static int get_bound_ports_ns(void *arg)
struct get_bound_ports_ns_arg *a = (struct get_bound_ports_ns_arg *)arg;
struct ctx *c = a->c;
- if (!c->pasta_netns_fd || ns_enter(c))
+ if (!c->pasta_netns_fd)
return 0;
+ ns_enter(c);
get_bound_ports(c, 1, a->proto);
return 0;