From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 69EF95A0268; Tue, 15 Nov 2022 02:23:49 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 5/8] util, pasta: Use __clone2() instead of clone() on ia64 Date: Tue, 15 Nov 2022 02:23:46 +0100 Message-Id: <20221115012349.2240096-6-sbrivio@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221115012349.2240096-1-sbrivio@redhat.com> References: <20221115012349.2240096-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WTKT4XFT3O4Y3GJBXUEGYWWNAC74VRYO X-Message-ID-Hash: WTKT4XFT3O4Y3GJBXUEGYWWNAC74VRYO X-MailFrom: sbrivio@passt.top 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 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: On ia64, clone(2) is not available: the glibc wrapper is named __clone2() and it takes, additionally, the size of the stack area passed by the caller. Spotted in Debian's buildd logs. Signed-off-by: Stefano Brivio --- pasta.c | 9 +++++++++ util.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/pasta.c b/pasta.c index db86317..1f3afa1 100644 --- a/pasta.c +++ b/pasta.c @@ -226,11 +226,20 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, arg.argv = sh_argv; } +#ifdef __ia64__ + pasta_child_pid = __clone2(pasta_spawn_cmd, + ns_fn_stack + sizeof(ns_fn_stack) / 2, + sizeof(ns_fn_stack) / 2, + CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | + CLONE_NEWUTS, + (void *)&arg); +#else pasta_child_pid = clone(pasta_spawn_cmd, ns_fn_stack + sizeof(ns_fn_stack) / 2, CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWUTS, (void *)&arg); +#endif if (pasta_child_pid == -1) { perror("clone"); diff --git a/util.h b/util.h index 2d4e1ff..3c48992 100644 --- a/util.h +++ b/util.h @@ -81,6 +81,17 @@ (((struct in_addr *)(a))->s_addr == ((struct in_addr *)b)->s_addr) #define NS_FN_STACK_SIZE (RLIMIT_STACK_VAL * 1024 / 8) +#ifdef __ia64__ +#define NS_CALL(fn, arg) \ + do { \ + char ns_fn_stack[NS_FN_STACK_SIZE]; \ + \ + __clone2((fn), ns_fn_stack + sizeof(ns_fn_stack) / 2, \ + sizeof(ns_fn_stack) / 2, \ + CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD,\ + (void *)(arg)); \ + } while (0) +#else #define NS_CALL(fn, arg) \ do { \ char ns_fn_stack[NS_FN_STACK_SIZE]; \ @@ -89,6 +100,7 @@ CLONE_VM | CLONE_VFORK | CLONE_FILES | SIGCHLD, \ (void *)(arg)); \ } while (0) +#endif #if __BYTE_ORDER == __BIG_ENDIAN #define L2_BUF_ETH_IP4_INIT \ -- 2.35.1