From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 11E335A005E for ; Tue, 11 Oct 2022 07:40:32 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Mml450Tgxz4xGp; Tue, 11 Oct 2022 16:40:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1665466821; bh=lZVgtZZ7ooQBr1EpYyacQ3OLJ4iZh7WIlNJdBVhSkMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Px6uOKFwH9SJtv70LrD5ACKHPLxJPz/5RPxMUXWtl4ufnOJDTkgqFWl2TspWv8cVI f/k+JILiHzZTEOLVUM2U4KNB/qHgpG22iH1ZU2P+ZM2H93pApKUjchK3Ld43G3SZE3 dlu4MFe3K5egsJUOEp8ca+PDIB0fEmqd07LHCwqc= From: David Gibson To: Stefano Brivio Subject: [PATCH 10/10] Rename pasta_setup_ns() to pasta_spawn_cmd() Date: Tue, 11 Oct 2022 16:40:18 +1100 Message-Id: <20221011054018.1449506-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011054018.1449506-1-david@gibson.dropbear.id.au> References: <20221011054018.1449506-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: MBUFF7WYZRY2XEPWO5TQPCC65J7AL4MC X-Message-ID-Hash: MBUFF7WYZRY2XEPWO5TQPCC65J7AL4MC X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, David Gibson X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: <> Archived-At: List-Archive: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: pasta_setup_ns() no longer has much to do with setting up a namespace. Instead it's really about starting the shell or other command we want to run with pasta connectivity. Rename it and its argument structure to be less misleading. Signed-off-by: David Gibson --- pasta.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pasta.c b/pasta.c index 9666fed..23dc6d6 100644 --- a/pasta.c +++ b/pasta.c @@ -147,25 +147,26 @@ void pasta_open_ns(struct ctx *c, const char *netns) } /** - * struct pasta_setup_ns_arg - Argument for pasta_setup_ns() + * struct pasta_spawn_cmd_arg - Argument for pasta_spawn_cmd() * @exe: Executable to run * @argv: Command and arguments to run */ -struct pasta_setup_ns_arg { +struct pasta_spawn_cmd_arg { const char *exe; char *const *argv; }; /** - * pasta_setup_ns() - Map credentials, enable access to ping sockets, run shell - * @arg: See @pasta_setup_ns_arg + * pasta_spawn_cmd() - Prepare new netns, start command or shell + * @arg: See @pasta_spawn_cmd_arg * * Return: this function never returns */ -static int pasta_setup_ns(void *arg) +static int pasta_spawn_cmd(void *arg) { - const struct pasta_setup_ns_arg *a - = (const struct pasta_setup_ns_arg *)arg; + const struct pasta_spawn_cmd_arg *a + = (const struct pasta_spawn_cmd_arg *)arg; + if (write_file("/proc/sys/net/ipv4/ping_group_range", "0 0")) warn("Cannot set ping_group_range, ICMP requests might fail"); @@ -186,7 +187,7 @@ static int pasta_setup_ns(void *arg) void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, int argc, char *argv[]) { - struct pasta_setup_ns_arg arg = { + struct pasta_spawn_cmd_arg arg = { .exe = argv[0], .argv = argv, }; @@ -224,7 +225,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, arg.argv = sh_argv; } - pasta_child_pid = clone(pasta_setup_ns, + pasta_child_pid = clone(pasta_spawn_cmd, ns_fn_stack + sizeof(ns_fn_stack) / 2, CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWUTS, -- 2.37.3