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=I1TxbpZl; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 306DD5A061C for ; Tue, 02 Dec 2025 05:02:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764648138; bh=0G+ulAIiU1lqNoWtdPBOHoSRf7LGwYB9QcXXqfCVM6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I1TxbpZlHdMKyIxad4kKLMfX0r7DH+i0B+5lZk7ZBDKQbmQAh78x4pfb1sd8q45Vx xWf2ak55c0VOaStgR3fJbUzGt/+u5/OC78TR7lz8Nt4J17VJG8QOlY0OI+9gKPvXDM p9xl21RGIS22rfcy9TVWBGq4zTvmxBUE1COy48OZ3UDyih33Wc5esiP+7SLiFlHeHI Sa5Iw+m7+xx9lAJ/IuYMnwxB2kN9cETuGbjifXw+9IZRJ4bzWOD7bBKhcsWetVEvUm LSxpvJvM4QOcLLLXcKks/s0I6+goT3Uvo9oYHyplxWSz8gbb5wfBFlS27+l7rDPeaO Ykl/4ee5E8L0A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dL6Y60WQbz4wQQ; Tue, 02 Dec 2025 15:02:18 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v5 03/15] conf: More useful errors for kernels without SO_BINDTODEVICE Date: Tue, 2 Dec 2025 15:02:03 +1100 Message-ID: <20251202040215.2351792-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251202040215.2351792-1-david@gibson.dropbear.id.au> References: <20251202040215.2351792-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: QNCSTYPJCWXQUFNNC6GMK42UBHIM6PEP X-Message-ID-Hash: QNCSTYPJCWXQUFNNC6GMK42UBHIM6PEP 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.52.0