From patchwork Thu Nov 26 14:45:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5798 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp7290293lad; Thu, 26 Nov 2026 06:45:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErE4o2FntRew8kUPxnjpxq0KAEipWWrCL3vrQ9r2F6RKLYj+oVrH6NX0Ws1MToHiYZ4519NNVA7GgYY=@openvpn.net X-Received: by 2002:a05:693c:87d6:20b0:386:bc19:6a30 with SMTP id 5a478bee46e88-386bc196d10mr10492508eec.20.1795704340070; Thu, 26 Nov 2026 06:45:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795704340; cv=none; d=google.com; s=arc-20260327; b=gJpePJ3t0JCnavtblDfVdhl9WEc84fENv3zYsQSsMYD9HfddEg3qVbZKSUmu05UUgZ 7m/aCx7wiJ6FDviCrUIlEEB19qIeNwbAKCJtpwDVjNB9X3GwWa6Vo2OGAsPa63IScrCc P9iEGS682SJ1+x/vBprhJTs8Zxz4s9f9S5WN4wOvoGy/Nxh5+Ls9Jwv8kumqFEwASV+D rc3w+T4YSv0lrIDX3W+kkQ4UzJH8UJu9TlR8UDHBYyVTu9PijqVGywXu+kzCV27JQQk1 PzDUbdq/ypCYYXXUjmvuwvkHr7Q3HeauyqRLJumJDKxVS+dtNF4XNuhCz/n86sGLiard ADnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=9sxKb5/6kWVbYGCn4VcHHXnFWSRJ3wWLxGxtA055vrk=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Mf+xqcu+4pyl2PLVHMCzALU4X4Q8EbG8fCki2dhcRp38FuNPPFVXzpBvPKEM98sxmW 3JyeGqzLgfERYQguQ/I8OAJMLtbzBA3yHVp+tJpgBIWB7bRoVUlJwyZjGCTlO6DnAFuz 9ou8I1ce8icLXhmpl/wDXlhMFq3DP4j6H3glZy/cLtL0FDwvj0TPAJgXKBlGvp7fV/tV VhVXCZGDGJpeiIuTiChKHI8PGpyOPewvfMcGfzNYlXI36rFeU52RzDtD4kqfXUOJ6hG7 gI4JtZg1XWomUbn0iieu9W1SPRsqXmMzc3RkDV0rCfjTXSx6CA8oNt7r5n87W+DDKAaf fwKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=FwMNtuYL; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cvTaahzu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=F8NENXUU; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=BKmaDFdc; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-386e563f90asi2509970eec.29.2026.11.26.06.45.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2026 06:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=FwMNtuYL; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cvTaahzu; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=F8NENXUU; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=BKmaDFdc; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=9sxKb5/6kWVbYGCn4VcHHXnFWSRJ3wWLxGxtA055vrk=; b=FwMNtuYLkbwTaq 4QLe0fAiqgJxv22WTL4CMd+zw0VryjYbv+cTO1izup/hA5AOZpKVtg77a7Ft8SIQxcDcyR1xH3TLR YTHZHrtRlcyRsqvW2qF9JJSn2aJlFGh15jC/TjmDfvnEXnJtq5ECZMQ9aYyxCGhx9nEXqUjyRd9Zw TIo=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xWajA-0000000026I-1QPj; Thu, 26 Nov 2026 14:45:36 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xWaj8-0000000026A-3MAK for openvpn-devel@lists.sourceforge.net; Thu, 26 Nov 2026 14:45:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dvjJMThrQgVrj8I/heGGh11qur/Laj/reaj7pGoI8tQ=; b=cvTaahzuAcTnfZqfLGTcxr2fbb GhCK95a1k1Ybf/YQGHJOw0jU9dDPTTAelPHKOZr7iKXFZTOHzK3NQqNkRrHC2VLkcU0tPtk6Ild4i acJwnodiqpEmgYTrl5OIJ/c5hQ5hgF38aFtOwkH1BNhHcCaSIufw08LD3UIr3carsO68=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dvjJMThrQgVrj8I/heGGh11qur/Laj/reaj7pGoI8tQ=; b=F8NENXUUeZ9YJKgdSrRYq72O3r 1ZWY8CSGJvCiZutBuGuerwOD2KTrRMeyL0THxDIPSiTxSn03zxZ/LKCgDNjGqIdQaoTVH4ZGl+VjO fZepEWXqJJ33XWjeEhuT/K0m5tdeUAonZ3aFLRrA7ytBbzf7oGOed8YXk5VfHLbJJP7k=; Received: from mout-b-110.mailbox.org ([195.10.208.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xWaj6-000000005s0-25pX for openvpn-devel@lists.sourceforge.net; Thu, 26 Nov 2026 14:45:34 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-110.mailbox.org (Postfix) with ESMTPS id 4jZzqR6hMgzNlc8 for ; Thu, 26 Nov 2026 15:45:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1795704324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dvjJMThrQgVrj8I/heGGh11qur/Laj/reaj7pGoI8tQ=; b=BKmaDFdcIWEZDvGgxeNuJmOHphES8W2k1znoyK2xfd9FSEQPZzx95P/qF9Wqce3xI0hE4v VFQ74OD3VjT/lI+5gCHwYzTsWMZG8+hJMmGqfxeYERBZBI3V1jToj3+Y9TBkDM+6OCZtdP nobHuaUzFDdpSGq21HbgKN5dBpHFQDDU8Br5R6f3o/JGi+T+XecQPJDnO5JHqnBdUIU1Ji /rmeG5oKYFwXNWFdq2tGrd7iZoDuHNxbsCXoIA3umLYOL8Jr8vVcNOO83bn8vlhFXhyZj5 t8Fu/wOxbCyRSDkJndaLkAi+KriEM9pFruqzrGqEkuVPRjFYUaNjE38Z6wQKGw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Thu, 26 Nov 2026 15:45:11 +0100 Message-ID: <4941179e211663717b4a91a7462238d6d7cbce95.1795703343.git.ralf@mandelbit.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jZzqR6hMgzNlc8 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The duplicate VPN address checks only verify that the command fails, so they also pass if it fails for an unrelated reason. The creation checks use OVPN_NUM_PEERS + 1 as the new peer ID, but the UDP server loads the whole peers file regardless of OVPN_NUM_PEERS. When the variable is overridden with a smaller value the ID i [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1xWaj6-000000005s0-25pX Subject: [Openvpn-devel] [PATCH ovpn net 3/3] selftests: ovpn: check the error of duplicate VPN address tests X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1882932473632523984 X-GMAIL-MSGID: 1882932473632523984 The duplicate VPN address checks only verify that the command fails, so they also pass if it fails for an unrelated reason. The creation checks use OVPN_NUM_PEERS + 1 as the new peer ID, but the UDP server loads the whole peers file regardless of OVPN_NUM_PEERS. When the variable is overridden with a smaller value the ID is already in use, and ovpn_peer_add_mp fails with -EEXIST before looking at the VPN address. The update checks use peer 2, which does not exist in TCP mode with OVPN_NUM_PEERS=1, and would fail with -ENOENT. Use a fixed ID that never clashes with the peers files, skip the update checks when peer 2 is not configured, and make all of them require "Address already in use" in the command output so that they only pass on a real address conflict. Fixes: 006208026819 ("selftests: ovpn: validate peer VPN addresses") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260921102215.3599702-1-antonio%40openvpn.net?part=11 Signed-off-by: Ralf Lici --- tools/testing/selftests/net/ovpn/common.sh | 21 +++++++++++++++++ tools/testing/selftests/net/ovpn/test.sh | 26 ++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/ovpn/common.sh b/tools/testing/selftests/net/ovpn/common.sh index da732c64ffea..7c8bf260a588 100644 --- a/tools/testing/selftests/net/ovpn/common.sh +++ b/tools/testing/selftests/net/ovpn/common.sh @@ -65,6 +65,19 @@ ovpn_cmd_run() { fi case "${mode}" in + fail:*) + # The mode is "fail:", as set by ovpn_cmd_fail_msg. Strip + # the "fail:" prefix with ${mode#fail:} to get the expected + # error message and look for it in the command output. + if [[ "${rc}" -eq 0 ]]; then + ret=1 + elif ! grep -qF "${mode#fail:}" "${output_file}"; then + cat "${output_file}" + printf '%s\n' \ + "${label}: expected error \"${mode#fail:}\": $*" + ret=1 + fi + ;; ok) if [[ "${rc}" -ne 0 ]]; then cat "${output_file}" @@ -100,6 +113,14 @@ ovpn_cmd_fail() { ovpn_cmd_run fail "$@" } +# like ovpn_cmd_fail, but the command must also print the given error message +ovpn_cmd_fail_msg() { + local msg="$1" + + shift + ovpn_cmd_run "fail:${msg}" "$@" +} + ovpn_run_bg() { local pid_var="$1" diff --git a/tools/testing/selftests/net/ovpn/test.sh b/tools/testing/selftests/net/ovpn/test.sh index 0762fa83e4b5..5bfa3c8a5fc2 100755 --- a/tools/testing/selftests/net/ovpn/test.sh +++ b/tools/testing/selftests/net/ovpn/test.sh @@ -74,7 +74,10 @@ ovpn_set_peer_vpn_addr() { ovpn_run_vpn_addr_validation() { local addr local peer1_addr4 - local test_peer_id=$((OVPN_NUM_PEERS + 1)) + # must not match any peer ID in the peers files, regardless of + # OVPN_NUM_PEERS, as peer ID conflicts are checked before VPN addresses + local test_peer_id=100 + local eaddrinuse="Address already in use" local test_peer_addr6="2001:db8::2" # Do not include 0.0.0.0 or :: here. They are invalid on creation, but # clear one address family on update and are valid if the other remains. @@ -98,7 +101,8 @@ ovpn_run_vpn_addr_validation() { ovpn_new_test_peer "${test_peer_id}" "${addr}" done - ovpn_cmd_fail "reject duplicate IPv4 address on peer creation" \ + ovpn_cmd_fail_msg "${eaddrinuse}" \ + "reject duplicate IPv4 address on peer creation" \ ovpn_new_test_peer "${test_peer_id}" "${peer1_addr4}" ovpn_cmd_fail "reject clearing the last peer VPN address" \ ovpn_set_peer_vpn_addr 1 0.0.0.0 @@ -108,15 +112,23 @@ ovpn_run_vpn_addr_validation() { ovpn_set_peer_vpn_addr 1 "${addr}" done - ovpn_cmd_fail "reject duplicate IPv4 address on peer update" \ - ovpn_set_peer_vpn_addr 2 "${peer1_addr4}" + # peer 2 only exists when at least two peers are configured + if [ "${OVPN_NUM_PEERS}" -ge 2 ]; then + ovpn_cmd_fail_msg "${eaddrinuse}" \ + "reject duplicate IPv4 address on peer update" \ + ovpn_set_peer_vpn_addr 2 "${peer1_addr4}" + fi ovpn_cmd_ok "add peer IPv6 address" \ ovpn_set_peer_vpn_addr 1 "${test_peer_addr6}" - ovpn_cmd_fail "reject duplicate IPv6 address on peer creation" \ + ovpn_cmd_fail_msg "${eaddrinuse}" \ + "reject duplicate IPv6 address on peer creation" \ ovpn_new_test_peer "${test_peer_id}" "${test_peer_addr6}" - ovpn_cmd_fail "reject duplicate IPv6 address on peer update" \ - ovpn_set_peer_vpn_addr 2 "${test_peer_addr6}" + if [ "${OVPN_NUM_PEERS}" -ge 2 ]; then + ovpn_cmd_fail_msg "${eaddrinuse}" \ + "reject duplicate IPv6 address on peer update" \ + ovpn_set_peer_vpn_addr 2 "${test_peer_addr6}" + fi ovpn_cmd_ok "clear peer IPv4 address" \ ovpn_set_peer_vpn_addr 1 0.0.0.0