From patchwork Fri Sep 6 11:27:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3800 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6bd4:b0:5b9:581e:f939 with SMTP id c20csp78888max; Fri, 6 Sep 2024 04:27:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3zeJ9tk7wrzcf8mRJb2pI60OSZLd0j9tC85Zp10uzwkeOfhP1Y1K5WLDzzMoM89l8kQttaHcoBKc=@openvpn.net X-Google-Smtp-Source: AGHT+IHDHGTJ7CqcnhhPlksb8Um4Y7sGTJADbRwt5V2HL8sm8gwqSUtEA83+u+vK46CMTkj0CvvH X-Received: by 2002:a05:6359:4c83:b0:1b5:a037:f238 with SMTP id e5c5f4694b2df-1b603a23841mr3147921255d.0.1725622077161; Fri, 06 Sep 2024 04:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725622077; cv=none; d=google.com; s=arc-20240605; b=aE3ED/OSrsRu2t3czHRXCewqGv2bILHp3j1Jm/w4cHb8hPXNi7Ve3VohNJKzdsMrCp 0+6YpmPImhuBJAMs8WRgpuSGKXNXKvf9MFTp5tVhC+UYX0cPpEvDclcyt5UOWzEpjpRx FCGwo7PMELcAuikrMIXfCNSIZWh7RMRIv6D88Uizd5rg9UhCKJrN3NCZTzewTBUXic8K ce070zUJmurkhCgMUSYxdcBIxtCTMi1Dg79hD9q4ds3aHpH3zkJmCK2d48+qjBdIopt/ cdahR+BWueO9OL/xvaD27YaAhM4FoIyY1gf0luLc/h8PikA+I7818nrGHoPnp/Sd8igC B81A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=7bOQwYzE7sPwEijhYmvP7fTi6ht2vQs4w90IhU3dx7Q=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=W10L4IOClVL+V03rvdnaSLpAzzz3sm9exNg+mkcksnyAqUC15wIFQtY4Zr9b1rPidY leGml8+Do8NN+V5IObbWWrLz864LdXHOn/2wbYClQnsjEiuEPJijNgFMWYAGaMsQ7CnV 3X+dzJkBAYZ700PX9IcDQQv0xDVgVqMYzX68YUsGGBNPyCHjWssZfdd1NIcQrkb+Q9ml RsC6/aN0JPGzETy8S0gHvtTdP6YJPRtJX58qD9/lmC9XBR2pzb9313Mb86yw9h911TTs 1jTPwJ/Q6UgaTpqDoc3k9Rklfvf+kYoqdOlEI7y3r3ZJHefFozoyC+7z53fHcHYlHK3b AyDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HMGdL0I7; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eQLKymJ2; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=ENhSpLAv; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id d2e1a72fcca58-71797628fe4si2664073b3a.33.2024.09.06.04.27.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2024 04:27:57 -0700 (PDT) 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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=HMGdL0I7; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eQLKymJ2; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=ENhSpLAv; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net; dara=fail header.i=@openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1smX7f-0002gp-8H; Fri, 06 Sep 2024 11:27:27 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1smX7b-0002gP-Cg for openvpn-devel@lists.sourceforge.net; Fri, 06 Sep 2024 11:27:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=w5xTRaqT1y5A3lOtOhW6g/pV5B5E+dhr+TVhwc7DYxQ=; b=HMGdL0I7nqtWMO/6kPJ8Yv9ev0 mVfpIeucOtr3MckxKxty+EDDtno7kOG+vjozY0Ii7/ezMD4W4xTaT1AeYas+FvSF72vJOASwENDz3 r2Vgf4C4nYU5xE5lmoaYbcx/WGlRRXxOVUtWwAiIiMmv8ozShY2grCdCeKQzZyOq00oo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=w5xTRaqT1y5A3lOtOhW6g/pV5B5E+dhr+TVhwc7DYxQ=; b=e QLKymJ2JgRLos88FnxighnUZYB8e6cVrFsIOsJewlYqafcjfpTw1NHP9aGvGwSZUYOoH4T2tDz8zG IEcl3LpigmrtzImPtztiruUzFLswCcgD1VDxx0fCYHNq5+4B/dPmqWR23TKz2TzAGx+knw0yke8zx NFp3TUFmJpC5VCIY=; Received: from mail-wm1-f46.google.com ([209.85.128.46]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1smX7Y-0006nD-28 for openvpn-devel@lists.sourceforge.net; Fri, 06 Sep 2024 11:27:21 +0000 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42c7b5b2d01so19862285e9.3 for ; Fri, 06 Sep 2024 04:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1725622033; x=1726226833; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=w5xTRaqT1y5A3lOtOhW6g/pV5B5E+dhr+TVhwc7DYxQ=; b=ENhSpLAvy8z4MzygPaISWck+PbnMXfaY2zYKIhDB2GTiw0rZjVW0iEtx77NIZlcfRL LlcMkNhml3aTYyQNGGLwKhFWX5/43xE7/SnCMslxlMsuF2hiGJp3dNXI2sTq2FX7knDB 4WYwQtFTn7wTYpfWoks7x4KR8/N6REfVMe+BBc96FQhRTgZazHFOevmetzCdpIuE+S/r Z743K1npqmeP7Mui9diLuVwi67BBFGcPeoV6yvCHOulI5X/2SPZOpxtvy0rV+lZ/0A0D QUr6DoABjdHvbFfsVRrR1QqyvdenG5xoNI226dpTWVMNi9YQ8v5awTt+1mbjN2bqs2vo iX9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725622033; x=1726226833; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w5xTRaqT1y5A3lOtOhW6g/pV5B5E+dhr+TVhwc7DYxQ=; b=aioTOBou32PJ+NAy+D7i0dVrNqua/rwHqk7wlNi1vL4W4XD5KiGJSbMYbvgBTZ4lGB rf3ocsunyu519EYdekyXUluS8JVFsPhwVAr/lU8nOpicO4uwADci3baTwOLZ+M41oxHe yjtbTk/Lh10MiHYe48Bb5D1O6uqoXw77dZPJTtjKEnACKZMQxY3moCtZjOsZ6WKF2BOk t5yQk8U8UBVc1agyThpoDUf4Tlfd0S7TVh3GYsnERnlKPWJTdtVjZ3E5j//bRgC3aP+A KR/pzxRI0gNRTCFlPQcp7CAMRMqMUQQ5H9bkdqdYcfrJLevlYUVl5pUdHwkUhRZaGU3K FOXw== X-Gm-Message-State: AOJu0YwORA9iC5qhaZJcWR2remoX1DiTN/VklSQg05OxNfJ+te3tw8T7 56Adto7HnguyZ38ydwypLLd32mTWi7KTaYxn3b4+9ASexdlgWsYjF7dU8uhxBcM= X-Received: by 2002:a05:600c:22cf:b0:42c:a8cb:6a5a with SMTP id 5b1f17b1804b1-42ca8cb6b54mr1029305e9.15.1725622033056; Fri, 06 Sep 2024 04:27:13 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ca05d351bsm17602325e9.30.2024.09.06.04.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 04:27:12 -0700 (PDT) From: "stipa (Code Review)" X-Google-Original-From: "stipa (Code Review)" X-Gerrit-PatchSet: 1 Date: Fri, 6 Sep 2024 11:27:11 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ifec08fea26ff6fd9e22f18cab0ac71c1dda8fe8e X-Gerrit-Change-Number: 734 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 9a5638fc5d39d04cb8dd14161922e498627fdeea References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", 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: Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.46 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.46 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1smX7Y-0006nD-28 Subject: [Openvpn-devel] [M] Change in openvpn[master]: dco-win: add SET_MODE ioctl call 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: , Reply-To: lstipakov@gmail.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1809445895163739909?= X-GMAIL-MSGID: =?utf-8?q?1809445895163739909?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/734?usp=email to review the following change. Change subject: dco-win: add SET_MODE ioctl call ...................................................................... dco-win: add SET_MODE ioctl call This is used to set client (OVPN_MODE_P2P, default) or server (OVPN_MODE_MP) mode. Requires dco driver version >= 2. Change-Id: Ifec08fea26ff6fd9e22f18cab0ac71c1dda8fe8e Signed-off-by: Lev Stipakov --- M src/openvpn/dco_win.c M src/openvpn/ovpn_dco_win.h 2 files changed, 56 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/34/734/1 diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index cf825b3..592cc71 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -93,15 +93,59 @@ return (version->Major > 1) || (version->Minor >= 4); } +static inline +bool +dco_version_supports_mp(OVPN_VERSION *version) +{ + return version->Major >= 2; +} + +bool +dco_set_mode(dco_context_t *dco, int mode) +{ + msg(D_DCO_DEBUG, "%s: mode %d", __func__, mode); + + OVPN_MODE ovpn_mode; + switch (mode) + { + case CM_TOP: + ovpn_mode = OVPN_MODE_MP; + break; + + case CM_P2P: + ovpn_mode = OVPN_MODE_P2P; + break; + + default: + ASSERT(false); + } + + DWORD bytes_returned = 0; + if (!DeviceIoControl(dco->tt->hand, OVPN_IOCTL_SET_MODE, &ovpn_mode, + sizeof(ovpn_mode), NULL, 0, &bytes_returned, NULL)) + { + msg(M_WARN | M_ERRNO, "DeviceIoControl(OVPN_IOCTL_SET_MODE) failed"); + return -1; + } + return 0; +} + bool ovpn_dco_init(int mode, dco_context_t *dco) { + int res = true; + dco_get_version(&dco->version); + dco->supports_data_v3 = dco_version_supports_data_v3(&dco->version); + if (dco_version_supports_mp(&dco->version)) + { + res = dco_set_mode(dco, mode); + } - msg(D_DCO_DEBUG, "dco data_v3: %d", dco->supports_data_v3); + msg(D_DCO_DEBUG, "dco mode: %d, data_v3: %d", mode, dco->supports_data_v3); - return true; + return res; } int diff --git a/src/openvpn/ovpn_dco_win.h b/src/openvpn/ovpn_dco_win.h index 9e437f0..8163b8b 100644 --- a/src/openvpn/ovpn_dco_win.h +++ b/src/openvpn/ovpn_dco_win.h @@ -114,6 +114,15 @@ LONG Patch; } OVPN_VERSION, * POVPN_VERSION; +typedef enum { + OVPN_MODE_P2P, + OVPN_MODE_MP +} OVPN_MODE; + +typedef struct _OVPN_SET_MODE { + OVPN_MODE Mode; +} OVPN_SET_MODE, * POVPN_SET_MODE; + #define OVPN_IOCTL_NEW_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_GET_STATS CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_NEW_KEY CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_ANY_ACCESS) @@ -123,3 +132,4 @@ #define OVPN_IOCTL_DEL_PEER CTL_CODE(FILE_DEVICE_UNKNOWN, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) #define OVPN_IOCTL_NEW_KEY_V2 CTL_CODE(FILE_DEVICE_UNKNOWN, 9, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define OVPN_IOCTL_SET_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)