From patchwork Wed Nov 15 13:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3437 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:3c06:b0:f2:62eb:61c1 with SMTP id e6csp2925999dys; Wed, 15 Nov 2023 05:45:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDhZxbUjojw0wQQo2Cp6/UewGAk+qb9nX/8li4GCH+bqHBcjpPKvUf/B8XjX3iSmhB2/Gq X-Received: by 2002:a17:90b:d96:b0:280:a26f:5860 with SMTP id bg22-20020a17090b0d9600b00280a26f5860mr5320700pjb.1.1700055947399; Wed, 15 Nov 2023 05:45:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700055947; cv=none; d=google.com; s=arc-20160816; b=rfy+PWjan1xVGiY+BoxciR0IlvtgPyO/qK64uuEAFvZx2dysQ77mB1/nAy4igI2sMG DR0wfrLlfeYUnZ2nyHShE3eUIe0HEOlefZj0HIkI+qTpQ2NI3aGcaS5ydK+lyXpiYN+o mj93Fswz8/A1PiHqCS8sAYQgucg98E9QLPHyrbXmsCjZ0JFJHnmAnuxpxKk9l7BUg9Oi e+oIufCzXm+VY5MTQEZU1jd+DuRzVAzsjcqIJtOkripgVTUQwIgwOV2v/fBIVriv5vK7 UMX05oLOZughFsu0pzlo+4MusC3dsSTG6BlZGeHgnj6v441fSlUe1lnh8C2axSiNQ2Uo CtRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=YzEz49XPh8PDQb4H/N7pVh8ka/W3qlnQVA2QkCGKK/E=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=fIcV/BT8zXSvKjrTAiezhJydnjAhbgOUGKZ4kIWe4Kx7sRIkon4O0Lam8Ji/oieLzB rUu3viEDvtVu2pJv/JVIa4GY/0CwF6yOFiwxDVJHSHTPMfRBfFp5KVYkPgq3CsIUw5Q7 /WBPZaAaOpiOZxCxmqvZ5BVso3VBfIuqRllLgBXTcKym5vGcoR3ZFr5ZaTe59YWTL2fi HPwxLCduk/lRTp/TFPirDC+TGLZbbJN+Dh/nnpRJ+l6FZ2N2pr6B9yda6j3qd4qtouoH ri/49/lJ42oab4bHq/xO5l8+7VfgzjgWTsUCzlLeWAOnvX71PczWFM+74Vh+xaXnfzj7 E/ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ETZsHF/j"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=lCTw+YdI; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=OEkc04vz; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id r6-20020a17090a560600b0028076ad83e0si14610115pjf.40.2023.11.15.05.45.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2023 05:45:47 -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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ETZsHF/j"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=lCTw+YdI; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=OEkc04vz; 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 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 1r3GCp-0001Qg-KN; Wed, 15 Nov 2023 13:45:23 +0000 Received: from [172.30.20.202] (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 1r3GCl-0001QS-Ci for openvpn-devel@lists.sourceforge.net; Wed, 15 Nov 2023 13:45:19 +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=BaCqfXi2do8DICSnmYdFzo+GW+AZ3rZLClmRHRqLGmg=; b=ETZsHF/j9mYGiZZycYZuRUy7Cd fRla+tbxa1ykkFm4EV2gU375UHdAr4lYF5LufSzB75O1As5Ydca0mpd5IjWRKF1YLqmk52qaPvT6w aW6lknwwcVRq31vg+fRM9HNVjB65qw9PFYq3vDx9SOdGJHE9D1l2d+KQBCq5IO1fkQOk=; 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=BaCqfXi2do8DICSnmYdFzo+GW+AZ3rZLClmRHRqLGmg=; b=l CTw+YdIcpulCY63YS7tylvgB4w7f9y6fFjJ2bEyuGYn+g4SCtywHz+cvpvuFFJW+MyebWtwtKKuT1 3axYsJcDl9et1lPVhMwMd4rMW4VNZe/IwsQcGoehm9AOCZ7Tr0ApkHLelzxANWbGT9qKElZ84wvKe xOrR3wgQhnuM9Et4=; Received: from mail-wm1-f45.google.com ([209.85.128.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r3GCi-0000Nh-Pg for openvpn-devel@lists.sourceforge.net; Wed, 15 Nov 2023 13:45:19 +0000 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40853c639abso53326455e9.0 for ; Wed, 15 Nov 2023 05:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1700055910; x=1700660710; 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=BaCqfXi2do8DICSnmYdFzo+GW+AZ3rZLClmRHRqLGmg=; b=OEkc04vz0MeZSS2FC+unSJTuD7DdH7cOsOA0/ie9WBlVE34M7gM0oTSXLL/SOtqc6l U4y3WTIXqrvdLH11YSWc9MxY6qnVI4RXGfTaGTg6tYf9H4b94FjX9HmnTnIxFOi66nae 2VqP/6TmO2UJmoLjVu7qxLPCw+caYRuv+eb/YS40IbBlS1rBF3FFg1drN99ToR+LysDP haT+OggTYrt3dkySx1ux9XsfVjHmZMl1i46QbicGq8VE8BVFafpK6WetrS3CMjMfsRkL /ee35BJa/ycY+D4oAtO7/MQowmBzDnR/ElAJklynUToi4zStEFJU3nveUorgdxaSYXPA dOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700055910; x=1700660710; 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=BaCqfXi2do8DICSnmYdFzo+GW+AZ3rZLClmRHRqLGmg=; b=DG1SSNcLHwfKLE5qhWdcV+slzb+7K7RLKGWubVHLlj9YPZI4vk00s+ORoApYuf8B2i IAfBfAwTUVryIYWDlf7nbBJJT6Mc8xnWQ4w+UEdmF1LHiE30ZyN+DhpkNL2bIdfjZhcU +nmwXbrkI+toIUR5cI6Z/8vsY92V8mF/CCArLOzocjrOD9ehzuzL53fohcYxxpYYLyk4 LUI2UTiYyXVRdcjaBYRX70WRwQUI+c+AYJvcCVluU2btVCy0b5LE0cD44gbKKVJDiRR6 veM1lY7YG1LSwQIBtD6wN5pWR9V6TFkRh/mOo6hh54lHOV7HigtB2HBzmWXsqt0TbdmY sIgg== X-Gm-Message-State: AOJu0Yy0ka5d7oNNBdjJrjNWpZM540WUIojXaX2Ua1HDsW3splKnbj5B Hy1mmU+KmOegW8vObGHXPgBbmQ== X-Received: by 2002:a05:600c:602a:b0:40a:20f3:d127 with SMTP id az42-20020a05600c602a00b0040a20f3d127mr9222475wmb.35.1700055910273; Wed, 15 Nov 2023 05:45:10 -0800 (PST) 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 s19-20020a7bc393000000b00405391f485fsm14875132wmj.41.2023.11.15.05.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:45:09 -0800 (PST) From: "ordex (Code Review)" X-Google-Original-From: "ordex (Code Review)" X-Gerrit-PatchSet: 1 Date: Wed, 15 Nov 2023 13:45:09 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I5899081c69bf1aa654d20e607fcdbd589140d474 X-Gerrit-Change-Number: 433 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 644109e34c3bcb0127692428ead1ed110dc65ee0 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.45 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.45 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_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_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1r3GCi-0000Nh-Pg Subject: [Openvpn-devel] [S] Change in openvpn[master]: io_work: pass event_arg object to event handler in case of socket event 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: a@unstable.cc, 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?1782637865422855122?= X-GMAIL-MSGID: =?utf-8?q?1782637865422855122?= 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/+/433?usp=email to review the following change. Change subject: io_work: pass event_arg object to event handler in case of socket event ...................................................................... io_work: pass event_arg object to event handler in case of socket event In order to allow the code to work with multiple listening sockets it is essential to allow the generic multi_io event handler to distinguish between the various socket objects. This can be achieved by passing an event_arg object that contains a pointer to the link_socket. This code path is used on clients as well as UDP servers. Change-Id: I5899081c69bf1aa654d20e607fcdbd589140d474 Signed-off-by: Antonio Quartulli --- M src/openvpn/event.h M src/openvpn/forward.c M src/openvpn/mtcp.c 3 files changed, 30 insertions(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/433/1 diff --git a/src/openvpn/event.h b/src/openvpn/event.h index 0b1f63d..f04318f 100644 --- a/src/openvpn/event.h +++ b/src/openvpn/event.h @@ -82,6 +82,12 @@ #define EVENT_METHOD_US_TIMEOUT (1<<0) #define EVENT_METHOD_FAST (1<<1) +/* + * The following constant is used as boundary between integer value + * and real addresses when passing arguments to event handlers as (void *) + */ +#define MULTI_N ((void *)16) /* upper bound on MTCP_x */ + #ifdef _WIN32 typedef const struct rw_handle *event_t; diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 9cc5c6b..9700c6c 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2164,7 +2164,8 @@ /* * Configure event wait based on socket, tuntap flags. */ - socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)&socket_shift, NULL); + socket_set(c->c2.link_socket, c->c2.event_set, socket, + &c->c2.link_socket->ev_arg, 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) @@ -2227,7 +2228,27 @@ for (i = 0; i < status; ++i) { const struct event_set_return *e = &esr[i]; - c->c2.event_set_status |= ((e->rwflags & 3) << (uintptr_t)e->arg); + uintptr_t shift; + + if (e->arg >= MULTI_N) + { + struct event_arg *ev_arg = (struct event_arg *)e->arg; + if (ev_arg->type != EVENT_ARG_LINK_SOCKET) + { + c->c2.event_set_status = ES_ERROR; + msg(D_LINK_ERRORS, + "io_work: non socket event delivered"); + return; + } + + shift = socket_shift; + } + else + { + shift = (uintptr_t)e->arg; + } + + c->c2.event_set_status |= ((e->rwflags & 3) << shift); } } else if (status == 0) diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index de1d24f..3772acf 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -61,8 +61,6 @@ #define MTCP_FILE_CLOSE_WRITE ((void *)5) #define MTCP_DCO ((void *)6) -#define MTCP_N ((void *)16) /* upper bound on MTCP_x */ - struct ta_iow_flags { unsigned int flags; @@ -696,7 +694,7 @@ struct event_arg *ev_arg = (struct event_arg *)e->arg; /* incoming data for instance or listening socket? */ - if (e->arg >= MTCP_N) + if (e->arg >= MULTI_N) { switch (ev_arg->type) {