From 9a175cc2cea75b98fc3c20381f58dcabf24ef529 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 29 Sep 2021 16:11:06 +0200 Subject: pasta: Allow specifying paths and names of namespaces Based on a patch from Giuseppe Scrivano, this adds the ability to: - specify paths and names of target namespaces to join, instead of a PID, also for user namespaces, with --userns - request to join or create a network namespace only, without entering or creating a user namespace, with --netns-only - specify the base directory for netns mountpoints, with --nsrun-dir Signed-off-by: Giuseppe Scrivano [sbrivio: reworked logic to actually join the given namespaces when they're not created, implemented --netns-only and --nsrun-dir, updated pasta demo script and man page] Signed-off-by: Stefano Brivio --- tcp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tcp.c') diff --git a/tcp.c b/tcp.c index 43e3ea3..c862632 100644 --- a/tcp.c +++ b/tcp.c @@ -2828,7 +2828,7 @@ static int tcp_splice_connect_ns(void *arg) struct tcp_splice_connect_ns_arg *a; a = (struct tcp_splice_connect_ns_arg *)arg; - ns_enter(a->c->pasta_pid); + ns_enter(a->c); a->ret = tcp_splice_connect(a->c, a->conn, -1, a->v6, a->port); return 0; } @@ -3431,7 +3431,7 @@ static int tcp_sock_init_ns(void *arg) struct ctx *c = (struct ctx *)arg; in_port_t port; - ns_enter(c->pasta_pid); + ns_enter(c); for (port = 0; port < USHRT_MAX; port++) { if (!bitmap_isset(c->tcp.port_to_init, port)) @@ -3491,7 +3491,7 @@ static int tcp_sock_refill(void *arg) int i, *p4, *p6; if (a->ns) { - if (ns_enter(a->c->pasta_pid)) + if (ns_enter(a->c)) return 0; p4 = ns_sock_pool4; p6 = ns_sock_pool6; @@ -3676,7 +3676,7 @@ static int tcp_port_detect(void *arg) struct tcp_port_detect_arg *a = (struct tcp_port_detect_arg *)arg; if (a->detect_in_ns) { - ns_enter(a->c->pasta_pid); + ns_enter(a->c); get_bound_ports(a->c, 1, IPPROTO_TCP); } else { @@ -3708,7 +3708,7 @@ static int tcp_port_rebind(void *arg) in_port_t port; if (a->bind_in_ns) { - ns_enter(a->c->pasta_pid); + ns_enter(a->c); for (port = 0; port < USHRT_MAX; port++) { if (!bitmap_isset(a->c->tcp.port_to_init, port)) { -- cgit v1.2.3