From patchwork Mon Oct 14 12:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3892 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1757:b0:5b9:581e:f939 with SMTP id c23csp1878404maw; Mon, 14 Oct 2024 05:28:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWf4QW/AzMNpXn2M36V09wQOXvowMb2MC/sjtCtRsClE5znbDQqA5RJ4n4ndr7eFgz3ECl0P7XZq88=@openvpn.net X-Google-Smtp-Source: AGHT+IGvNEQRp9WUD0hK8+pikGb+r6rxCubWUrSNRE85lKphIKHynr3IoEuoBHqbK6iXlfzEBrm4 X-Received: by 2002:a05:6e02:13a8:b0:39f:558a:e404 with SMTP id e9e14a558f8ab-3a3b5f7a880mr89455245ab.4.1728908905798; Mon, 14 Oct 2024 05:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728908905; cv=none; d=google.com; s=arc-20240605; b=JuLFgq/YrHrcqd/lXHeXzQKHrE21lewjLq6TP+OPPyQTOKzCHD2ek/97m4QdUP8ULO m8PrRwN3QFns4JyX8fqhcYwG3A+poDbrfYd1ZFbaBc3xqJWleyXo7v8akqwxgqt7f8yY fkxKUxNJnI0XQIK6cf5IpiAyJntQLPz3QY92VXNdpcN6c3btiVejWLrn4qFLDVV4FWyG VtiRWOIEE+uAtXNEQshWVMLpVkawnQK5U5vt5WGY9T7sYRhspnT3p+xpDq1YHZ/gR56Z dxJaAGlRQiwCa8+mdNYKh6pmJ1V4YY4jTjq4nEFaFCg7luepP/lowXBcjq1iT32nfxcZ nsEA== 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=aGheE54uSVW3PWIIZec1vpZz1RQcCkfbWoS+rcFwuoU=; fh=yXAbqwSLX4AZy2IfjuXV6xw9sEGAlDO35mmlrsbkSnM=; b=B8ghTKSlu9MiDCQfgZD0FYJAHAD6qzmwR0mLrNm3iBD83uKCbWsA6zAgsOqhekx50a byFVZy+qaO1x46FSClWkCa9I5D3BA1V26Ph7EKDjKSEBq+ESs51wQRVadtay5BHZ+d9K /B0PWE4e+q8Q/KpqzWCtf3eWdfG4/QoqpUmQ2Qz+AwefGa0tq/vZ4ZR+kwJ++wcHpJrI 1Cqv2pHBaTScAKUTPaLqDYGTAqOH7fF/gR8Qyv09vUZTB9dSX9sxrSuOVLOSjj1He/EO Vb0d0Elbe5jsrlcvNvtyF42sDskCAVvWU4GalgUC5P6vOG6R95WS1Fj3TEZiSKkkqqTO sNGA==; 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=QZ7x+PSa; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=DcwFynxr; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=dCumXCBr; 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 8926c6da1cb9f-4dbada836d0si4522323173.95.2024.10.14.05.28.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2024 05:28:25 -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=QZ7x+PSa; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=DcwFynxr; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=dCumXCBr; 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t0KBO-0001Hc-5O; Mon, 14 Oct 2024 12:28:18 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t0KBL-0001HS-JP for openvpn-devel@lists.sourceforge.net; Mon, 14 Oct 2024 12:28:16 +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=X6jud/L6rqY+ZdkM7qNnWzYoffanfFzzaxeyLE+tycw=; b=QZ7x+PSa3inhqBft+uD5zWJlpc Hta1nBetg3fGEi1LyLeJjp5QWKvjyEBiS5G6OODfBx7b+CdplIZFzYqH1amj4ufJQK857nj8u/0aU 6iVV8p32Q3coyyRc6RU4CRBT9Qhk0BAA3xOyROYVoNaW3kct6+UMdjRlIBcgJld7ZojI=; 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=X6jud/L6rqY+ZdkM7qNnWzYoffanfFzzaxeyLE+tycw=; b=DcwFynxrAZ73U9nxHlu3TVSw13 IVy4k2z8QjXb0GcE/DLv17k3BaVHNn0D93mTlwdjeMsKhYo0/QOIIsfgxoS5cZTiIQy9Tce0301I/ rWSVoMF6ekCEmhQ4EHRdmWZEzOvOBUOQcNcMqqsVQGA7HnXkDYdUqpPYbUvchf0FOWH8=; Received: from mout-p-101.mailbox.org ([80.241.56.151]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t0KBK-0005YX-KM for openvpn-devel@lists.sourceforge.net; Mon, 14 Oct 2024 12:28:15 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.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-101.mailbox.org (Postfix) with ESMTPS id 4XRxMj1rXrz9snN; Mon, 14 Oct 2024 14:28:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1728908881; 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=X6jud/L6rqY+ZdkM7qNnWzYoffanfFzzaxeyLE+tycw=; b=dCumXCBr1yVpAvRNdv+W8VjAKE+kFL5i+oyZ2KMe9BzU/6wW4boBEPgLlnugco/8mS0A1w a8IC5nAqpahoISyEi91Nj4zUVWnz6MCW10oFllR4pJEze0Sa10O4m/SF2TZj+QFFTwtrr8 zXFBHfOTrA6GB9mQy8grXn1EmcyHftK+KRhPkI/LnplOdOx5xJkqO1A9W4CWlbJQISL+bF bdxtfwn4+vSI+NraB2KZvtjMKRkVKhMuDY48zPpYLp63th+3up4r2AXTzbcGmx7izyjoBz YULpP+0Y9Y7Epsxx4MZr//JD83XA8PcirMBSgD4VgYsdSnrdU9XOlSz7IIkUGg== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Mon, 14 Oct 2024 14:27:59 +0200 Message-Id: <20241014122759.38094-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 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.151 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_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 X-Headers-End: 1t0KBK-0005YX-KM Subject: [Openvpn-devel] [PATCH v4] 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?1812892384499059189?= 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 Signed-off-by: Gianmarco De Gregori Acked-by: Frank Lichtenheld --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Same as v3 but I added Signed-off-by for Giaan. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/759 This mail reflects revision 4 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)