From patchwork Fri Oct 11 12:31:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3888 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1757:b0:5b9:581e:f939 with SMTP id c23csp479380maw; Fri, 11 Oct 2024 05:32:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU5v6ZikVPW8WPo5AM2NETx3MeeLJ3SwuDVlqBsNf0wyEcUWK3kbvildER+cP/LiF/loT3cMtMQL7s=@openvpn.net X-Google-Smtp-Source: AGHT+IFRgQhcdS7wXEvQS6EUmqQghhto8JX+kYvcmD6ZpOqc7ygdl9csO8C6JZkCLjoiH5Ugq/ro X-Received: by 2002:a05:6830:2682:b0:717:d012:a513 with SMTP id 46e09a7af769-717d643bdb5mr2032075a34.19.1728649936085; Fri, 11 Oct 2024 05:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728649936; cv=none; d=google.com; s=arc-20240605; b=NzNiGBaEk8ASjQrIQAAOkaa/OugZN5vQ8SjbYXMRteeceFI6baf1DT3TETr33JvALl 41iR1mICHJBK9Sb39dRGl4vIcN8ERgIkkgT9oHE+0I6vVUnwZhJMXxu89x7ReGvb4ZdL u3vPQ18OPcTn1LlJ0Y+Zr04B+c7aRHYzxFYvqXSFuHidQBHBlqiPnIbpdrhlf1RHFJT/ WqRxmyoVStKFH3QupdHFyOWkYWbRMtlDbcUZcbIOdWO78wl6W8jc3vSTF2CYzyjEUQUQ 8wKZ6kEQmysqy51llgCf1kXRyZ12SxfgEU6cLMQA/NuZTMz1SZ+CUR3F6E7LqYbvqa2i rP6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:cc: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; bh=64A0f+oRzJ3dlRlazeyR24SB4uL9llC19bzd9MfPyRI=; fh=yXAbqwSLX4AZy2IfjuXV6xw9sEGAlDO35mmlrsbkSnM=; b=Q4ku9shsOPiEAWFj5Hq2jnB8dAHE/atjz9OzZeu3DpszTaE5dgeB0w/u446iFVzzCD rTqR+m/mq1XhRlTK+lovI09WQ122cqzdpcbDJEE5u2RUO63WEVI13YecxcTcyWuGFYFB 0FArvKX0Lf18nIv7kFfJTp+IFy10lHnZ8yPlwRipO/mEgQiTM/frTdgmryPdbJsRNIKE Wmeoi/QceHMbl9ysEHeaO3f6F/euyiXUJ88hSvXGG4Bk3pcWFqOvn9/9Shb1Lgt9L48a 84zbFp7Y+j00txMIcnt0Vtjyq6oNsJMKpF7TLnxHNas/A3uPfbDPRa8viKoxxchhyoT4 yQSg==; 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=gpkJlhOj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="FvQsfU/x"; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=JzpKJw4h; 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 46e09a7af769-717d0040fcfsi1737918a34.135.2024.10.11.05.32.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2024 05:32:16 -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=gpkJlhOj; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="FvQsfU/x"; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=JzpKJw4h; 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 [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1szEoQ-0002mu-Os; Fri, 11 Oct 2024 12:32:06 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1szEoP-0002mn-1s for openvpn-devel@lists.sourceforge.net; Fri, 11 Oct 2024 12:32:05 +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:Cc:To:From:Sender:Reply-To: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-Subscribe:List-Post:List-Owner:List-Archive; bh=7c91F3mxPcoEgn5tQ4C2hl74wqY4aaJzFqa9lCzHtGs=; b=gpkJlhOjbUZKvQ/ULgii7dbYtf G16jM5YlQX/GQ9NxWjIjxfxgktTKRR8fdppvMypLw+SSxglRfEl7Wmln9HKQ66iUh+BiwhChyNJTW O5HvC6Rdc0b8meea6RBmBffPfCYbn37gTeRmQOkUYpZflvLT5ddfPN/txOMDjyt0I5lk=; 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:Cc:To:From:Sender:Reply-To: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-Subscribe: List-Post:List-Owner:List-Archive; bh=7c91F3mxPcoEgn5tQ4C2hl74wqY4aaJzFqa9lCzHtGs=; b=FvQsfU/xedfA0v+4F4+PrzioMe te1mKwQQVfdT9DjPRwF18pFjwAUxdVBYHCooPLTH8u7FJ5nRT3t6cVuRjspsz9NdnoF7QAwMWIBm9 lGlSngLFjwHPaklCzP2NrEfSpoLTjJRX9+rFE6Xy/PPfBCFTnEbsV+G1YyLyioPgJcTU=; Received: from mout-p-102.mailbox.org ([80.241.56.152]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1szEoM-0005Ob-O2 for openvpn-devel@lists.sourceforge.net; Fri, 11 Oct 2024 12:32:04 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4XQ5bT0BSNz9sn0; Fri, 11 Oct 2024 14:31:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1728649909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7c91F3mxPcoEgn5tQ4C2hl74wqY4aaJzFqa9lCzHtGs=; b=JzpKJw4himDuALEg1SFzNF5B9mCM/JrYid6JYeAmQ/bf9KCsH9jbyBoT7crxVfOuqYd1cY z/M+GKonBnUO7z4qPvz8LcBGP3IUxiFjN01tfl5ylB3U3uL/sLcP+p9fGytceCDwWyGC+h 9ZkjQh5qiu0aZ03KKoBesapuwZ44JatUz6noLM2ZrsCD6I49HdXkZSXZpHoGiXoCH0fO9D oHCsM+uk7Szro0MDhTWmybxU7Fegrf8AdmY2V8ZZ/VTJRK0gcXCPREPcqaevupC4sXnVuj rvFRmvcDlyQyPMltsMrutsX4zFFauedynfZE7qDfvAp87RoR9pdLk5+KYr3uOA== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Fri, 11 Oct 2024 14:31:47 +0200 Message-Id: <20241011123147.351208-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4XQ5bT0BSNz9sn0 X-Spam-Score: -0.9 (/) 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: From: Antonio Quartulli Instead of passing the shift argument as pointer, pass directly its integer value. This will allow the code to distinguish a shift value from a real object pointer, like we already do in multi_tcp_pro [...] Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.152 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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: 1szEoM-0005Ob-O2 Subject: [Openvpn-devel] [PATCH v3] io_work: convert shift argument to uintptr_t 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1812620835493497882?= X-GMAIL-MSGID: =?utf-8?q?1812620835493497882?= From: Antonio Quartulli Instead of passing the shift argument as pointer, pass directly its integer value. This will allow the code to distinguish a shift value from a real object pointer, like we already do in multi_tcp_process_io(). This change will allow us later to pass an event_arg object as event handler argument instead of a simple integer value. Change-Id: Ib583bf17e35b14aed78fd8217b6e71e8c2b78089 Signed-off-by: Antonio Quartulli Acked-by: Frank Lichtenheld --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Note that while this is not the first patch in the "multisocket" series, it does not depend on the previous ones and can be merged independently. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/759 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 6f279ec..66e5be1 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2065,20 +2065,18 @@ unsigned int tuntap = 0; struct event_set_return esr[4]; - /* These shifts all depend on EVENT_READ (=1) and EVENT_WRITE (=2) - * and are added to the shift. Check openvpn.h for more details. - */ - static int socket_shift = SOCKET_SHIFT; - static int tun_shift = TUN_SHIFT; - static int err_shift = ERR_SHIFT; + /* These shifts all depend on EVENT_READ and EVENT_WRITE */ + static uintptr_t socket_shift = SOCKET_SHIFT; /* depends on SOCKET_READ and SOCKET_WRITE */ + static uintptr_t tun_shift = TUN_SHIFT; /* depends on TUN_READ and TUN_WRITE */ + static uintptr_t err_shift = ERR_SHIFT; /* depends on ES_ERROR */ #ifdef ENABLE_MANAGEMENT - static int management_shift = MANAGEMENT_SHIFT; + static uintptr_t management_shift = MANAGEMENT_SHIFT; /* depends on MANAGEMENT_READ and MANAGEMENT_WRITE */ #endif #ifdef ENABLE_ASYNC_PUSH - static int file_shift = FILE_SHIFT; + static uintptr_t file_shift = FILE_SHIFT; #endif #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) - static int dco_shift = DCO_SHIFT; /* Event from DCO linux kernel module */ + static uintptr_t dco_shift = DCO_SHIFT; /* Event from DCO linux kernel module */ #endif /* @@ -2092,7 +2090,7 @@ */ if (flags & IOW_WAIT_SIGNAL) { - wait_signal(c->c2.event_set, (void *)&err_shift); + wait_signal(c->c2.event_set, (void *)err_shift); } /* @@ -2185,19 +2183,19 @@ /* * Configure event wait based on socket, tuntap flags. */ - socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)&socket_shift, NULL); - tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)&tun_shift, NULL); + socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift, NULL); + tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift, NULL); #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (socket & EVENT_READ && c->c2.did_open_tun) { - dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (void *)&dco_shift); + dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (void *)dco_shift); } #endif #ifdef ENABLE_MANAGEMENT if (management) { - management_socket_set(management, c->c2.event_set, (void *)&management_shift, NULL); + management_socket_set(management, c->c2.event_set, (void *)management_shift, NULL); } #endif @@ -2205,7 +2203,7 @@ /* arm inotify watcher */ if (c->options.mode == MODE_SERVER) { - event_ctl(c->c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)&file_shift); + event_ctl(c->c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)file_shift); } #endif @@ -2248,7 +2246,7 @@ for (i = 0; i < status; ++i) { const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags & 3) << *((int *)e->arg)); + c->c2.event_set_status |= ((e->rwflags & 3) << (uintptr_t)e->arg); } } else if (status == 0)