From patchwork Wed Oct 23 08:42:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3905 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6bd6:b0:5b9:581e:f939 with SMTP id c22csp241304max; Wed, 23 Oct 2024 01:42:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUnnSaQyRaIDDur6clkw6+HodvxiTIirj4ued6EdY6OLLfIWqfNRisK+Hg9T6DH5eBtrXNN0WXcdck=@openvpn.net X-Google-Smtp-Source: AGHT+IFPTy/mgWjGz5XP66Qhw0cM56tV5WFdmcxk8j6ZQIJFumwFSu3lL3c/Fm7iSoGQmClWicPJ X-Received: by 2002:a05:6e02:1a67:b0:3a3:778e:45cd with SMTP id e9e14a558f8ab-3a4d59ce5dfmr16447535ab.21.1729672947090; Wed, 23 Oct 2024 01:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729672947; cv=none; d=google.com; s=arc-20240605; b=gxJYayEsm3DIMH/Ye9AILjtqpRKntYEM3zx/eNcrhSduqQWLuGMCv+u5wfut8BGYnB k1s/X7ptucp7hZqDRpMkb1GWESXzXu2hC18Z83WiMPjVzcr5EDVnYPff1TNwtquafd9Y QOmw8WiAMsoo86eLG+zSVmOrOX5XRhbAug9M6LEQhUWg0eWfcezLaddG59mveGfBfiJq tg1Kh08Z0P4QxkeecXe6j2yzIh/XgF3lmm1yRjOT64d9onJwtCODTD8KFS0AStELMbOk RAxbFLxptpveW36dJ6mECKUmEu84P4sJZUcYJOHjFrrBYdR6LcdgkXvKROtaZtlQy6os Ewlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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; bh=MoapmzbN+qewx+KJiGecvylaegJGbRMo5ZPWbkbWn08=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=C3d/ZznJH0gY8cTWTP8dcsp0OyIU9LePBwuAejPl5jN+gwa/LG1nODZdVHkLB2HrBT 6CjVk/XL6zUvCDc2UQXcGXulkiFoLv1YMlABytrLXsLkOvnuHbO878+P3YPMUmnyydVh XrOqnTHXsDH/S6l6M05afdxX5kao42ojVr/h7RnZwo4SnbryPaOJ4QNXwD9bvoihfuA0 GHBUU3pZP9QiHxWTpEXJiCVWPDlPGLJdNzFnhtyiKDXAK2FzKBCVRJL9qkGOrmepngh6 wp4Sykt1yTkk9HWN1VLQFPkuqSf0CyEXLgnsz8G/i0rskQIABJJiQwImBJFr5ltIoqWA I/FA==; 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=GahqbMN5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Za97/1P8"; 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=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e9e14a558f8ab-3a400b72ae1si34891655ab.148.2024.10.23.01.42.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2024 01:42:27 -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=GahqbMN5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Za97/1P8"; 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=muc.de 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 1t3Wwe-0006Kc-5P; Wed, 23 Oct 2024 08:42:19 +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 1t3Wwc-0006KU-GG for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 08:42:17 +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-Subscribe:List-Post:List-Owner:List-Archive; bh=w8iGkY6DeaWGp05tmCBWRQw4WTvAeMDTYJGOTeNtF0U=; b=GahqbMN5ljwxZgv27IjNBGjfJg 5Fj81mwNa7AvWtiT9DQBKPGGaur1sz92UB4VzG4IrC4jAHBoZ39twF46ReSwu4FKg0/TbwgnuuW1+ 6kFLJecZWuvBlXt5udzNXj+iWJQElIyy359b0kze1h83dJKUODrpBel/e4Xx0W4AzIAc=; 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-Subscribe: List-Post:List-Owner:List-Archive; bh=w8iGkY6DeaWGp05tmCBWRQw4WTvAeMDTYJGOTeNtF0U=; b=Za97/1P8m97bXma+gpF4jiGg9U PIkK8UxiW85HZfZG81qjJaz/t63oQ9zfCmBWDpW8INlC35V8rceEg0UIzNCpR4WMeSH0lpC9VlWXC 27ks00X7VdLVq+I5N7AMs2XK+2o1TQXikxlLzXAcWyygWlXhdYAcKR/oFnvPL944DNHk=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t3Wwa-0007Ge-DJ for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 08:42:17 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 49N8g9gR012327 for ; Wed, 23 Oct 2024 10:42:09 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 49N8g9Rs012326 for openvpn-devel@lists.sourceforge.net; Wed, 23 Oct 2024 10:42:09 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 23 Oct 2024 10:42:08 +0200 Message-ID: <20241023084208.12317-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1t3Wwa-0007Ge-DJ Subject: [Openvpn-devel] [PATCH v5] 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: , 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?1813693539839608893?= 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. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/759 This mail reflects revision 5 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)