From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 356C05A004F for ; Tue, 30 Jul 2024 19:10:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722359417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k6xO6/MkVKH1JGxJiGsHuaCy5QIMpIoQLCDT4TsyYPY=; b=NXeubsvomGHUdHcgNv9oubyQKSqX5T0UxY2ADHG5BMQLY1rRe74ZXvW8cbJ3ZKHiLBg/Mz itiDy63EFINIFVTQeTBBLo/+2QsKecJZPEeTY3h+bBx88zXVcqPBRLg/0rIKd0lpxZTwGT gghy21+ObLVRAWh7HsRM/7gj64gEar0= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-258-waugYVtMP0-2i3CjDKvexA-1; Tue, 30 Jul 2024 13:10:14 -0400 X-MC-Unique: waugYVtMP0-2i3CjDKvexA-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3db128edf75so4715470b6e.0 for ; Tue, 30 Jul 2024 10:10:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722359413; x=1722964213; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=k6xO6/MkVKH1JGxJiGsHuaCy5QIMpIoQLCDT4TsyYPY=; b=Yr+gatBtF0lN8t8iLmCCdrWz42FWbTpZztRLVm/cNuFOl9n/fPZm60Gjx5/HO1yH6z h6wFOsFAHhc1lPrH4P+3Mi76TLaqtBIIhCN1VENmBqn8y8HyfcAec1zpp/KWrX21McEN BYS30mblBrusIIcxp+TyM4gfJcPgGcPqlRhKF3thkxgXPc3lglZs5QC3ut4Di5XjrqHD K+Z+/vFRJ6vHMSUJ+h0c36neW9lUQcP/4QfJGqsAePI8aNVNW65aLthf5zEiPdC8xJ9D 4WrAAKfz27ypTxrniVkMmfq1b20eoGY+Dii1RZEnbvcmySoRro+2Cooz1j9nnVoOvd15 nl7g== X-Gm-Message-State: AOJu0YykR3SIEnb53KZ+JYa2uo4No/sRa07Xc4YeFmutXw/jOS/aYfZ+ UIWPvQWtbN5EgEn4smhXV3OSLqPYHH1QHV5yBlh+Dgr5QUBCXP2y1W5eg9rDkArEOyIkNaPjRyR y1LcalwaltN1XwQCzMeRkeXykMadxGfnYPjyV++55geCL4TCuPE2Uzg0hn47n X-Received: by 2002:a05:6808:bd5:b0:3d9:3b17:f752 with SMTP id 5614622812f47-3db23ac334amr16934097b6e.26.1722359413508; Tue, 30 Jul 2024 10:10:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoOdaXxeRHH0au1o6lPJr2TAVRsBPg2NZQ8mq5ygGVR6TAuMETn+Xau9wfKTk2V5HPXbxOPw== X-Received: by 2002:a05:6808:bd5:b0:3d9:3b17:f752 with SMTP id 5614622812f47-3db23ac334amr16934071b6e.26.1722359413113; Tue, 30 Jul 2024 10:10:13 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3fa94b44sm65281306d6.75.2024.07.30.10.10.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jul 2024 10:10:12 -0700 (PDT) Date: Tue, 30 Jul 2024 19:09:36 +0200 From: Stefano Brivio To: Danish Prakash Subject: Re: [PATCH v2] pasta.c: modify hostname when detaching new namespace Message-ID: <20240730190936.4cf2e1bb@elisabeth> In-Reply-To: <20240730060132.5522-1-contact@danishpraka.sh> References: <20240520083343.10973-1-contact@danishpraka.sh> <20240730060132.5522-1-contact@danishpraka.sh> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: IYL6L56WGORC5XECHDYRODTGX7R7JDX7 X-Message-ID-Hash: IYL6L56WGORC5XECHDYRODTGX7R7JDX7 X-MailFrom: sbrivio@redhat.com 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 X-Mailman-Version: 3.3.8 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 Tue, 30 Jul 2024 11:31:23 +0530 Danish Prakash wrote: > When invoking pasta without any arguments, it's difficult > to tell whether we are in the new namespace or not leaving > users a bit confused. This change modifies the host namespace > to add a prefix "pasta-" to make it a bit more obvious. > > Signed-off-by: Danish Prakash Thanks for following up with this! I just applied it with some coding style fixes: > --- > pasta.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/pasta.c b/pasta.c > index 31e1e000ee1b..7ce502d3f299 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -50,6 +50,8 @@ > #include "netlink.h" > #include "log.h" > > +#define HOSTNAME_PREFIX "pasta-" > + > /* PID of child, in case we created a namespace */ > int pasta_child_pid; > > @@ -178,6 +180,7 @@ struct pasta_spawn_cmd_arg { > */ > static int pasta_spawn_cmd(void *arg) > { > + char hostname[HOST_NAME_MAX + 1] = HOSTNAME_PREFIX; > const struct pasta_spawn_cmd_arg *a; > sigset_t set; > > @@ -188,6 +191,13 @@ static int pasta_spawn_cmd(void *arg) > if (write_file("/proc/sys/net/ipv4/ping_group_range", "0 0")) > warn("Cannot set ping_group_range, ICMP requests might fail"); > > + if (!gethostname(hostname + sizeof(HOSTNAME_PREFIX) - 1, HOST_NAME_MAX + 1 - This exceeds 80 columns. > + sizeof(HOSTNAME_PREFIX)) || errno == ENAMETOOLONG) { This is indented with spaces instead of tabs, and "errno == ENAMETOOLONG" is not aligned with !gethostname(), despite logically being at the same level. See also my previous emails about this: https://archives.passt.top/passt-dev/20240523162347.44e6faf3@elisabeth/ https://archives.passt.top/passt-dev/20240524193918.151fd2fc@elisabeth/ > + hostname[HOST_NAME_MAX] = '\0'; And this should be aligned with the rest of the clause body, that is, indented one level on top of the conditional. With (two) tabs, not spaces. > + if (sethostname(hostname, strlen(hostname))) > + warn("Unable to set pasta-prefixed hostname"); > + } > + > /* Wait for the parent to be ready: see main() */ > sigemptyset(&set); > sigaddset(&set, SIGUSR1); -- Stefano