From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202510 header.b=ny3Iw+KK; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 002605A0274 for ; Fri, 28 Nov 2025 06:34:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764308040; bh=EXq8X27/MjDpO/DqnSnLY8TgrcMQr829xg2vpcB+Ugc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ny3Iw+KKyvN8tkoT7wPdbbiEOv2lg9/imTuG8T+j9yq8H4rbvTbJ/dQGgNXEjgT0D DAAA8hctfUtuG9Ma7/ua1FWo5K1ghGQFUDSmgdv+ZBVTZeLXnjgIYaKQ8erQQbnA09 YBNx6EnKVEBILB43xJikyIQP8gMsNrSDjTwGWAzCuX3oSUj2oXO4TafFiZwU1BroLr Csh0cxq3fUW3B55ylfsNHqW2QDcxDsUkhc1TbsXCRwZyHCD6Io0+KHFuehYqXnpre/ sIajaLPi/0XYxZB8DHQN/sOz3MEls8cy4RJo1gxvYtBdrg9ew5tMACmfaHTPqo3jj4 qxX+3nkrg0Ryg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dHhmm62GKz4wHF; Fri, 28 Nov 2025 16:34:00 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/3] conf: More useful errors for kernels without SO_BINDTODEVICE Date: Fri, 28 Nov 2025 16:33:58 +1100 Message-ID: <20251128053358.1576513-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251128053358.1576513-1-david@gibson.dropbear.id.au> References: <20251128053358.1576513-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: OHXF4Y7NPLLUFV5I5AIJ7PFZG3QV3ZX2 X-Message-ID-Hash: OHXF4Y7NPLLUFV5I5AIJ7PFZG3QV3ZX2 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: David Gibson 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: Before 5.7, the kernel didn't allow SO_BINDTODEVICE to be called unprivileged. That means for earlier kernels, we can't implement binding listening sockets to a specific interface (e.g. -t %eth0/80). Currently we'll generate an error on this at the point we actually attempt the SO_BINDTODEVICE setsockopt(), at which point the connection to the command line option might not be entirely clear. Use the fact we now probe for SO_BINDTODEVICE support to make a clearer error message at the time we parse the forwarding option. Signed-off-by: David Gibson --- conf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conf.c b/conf.c index 66b9e634..43bcaf31 100644 --- a/conf.c +++ b/conf.c @@ -156,6 +156,12 @@ static void conf_ports_range_except(const struct ctx *c, char optname, optname, optarg); } + if (ifname && c->no_bindtodevice) { + die( +"Device binding for '-%c %s' unsupported (requires kernel 5.7+)", + optname, optarg); + } + for (i = first; i <= last; i++) { if (bitmap_isset(exclude, i)) continue; -- 2.51.1