From patchwork Mon Sep 23 13:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "ralf_lici (Code Review)" X-Patchwork-Id: 3855 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:10cd:b0:5b9:581e:f939 with SMTP id j13csp2171970mae; Mon, 23 Sep 2024 06:41:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWXGZ9bnTtEKTne+j2dSSK31O7NxD71sOMAeZohSK/k8a5tGqYw0G1aTPj9o2zDKymhHZw+XyPGHO4=@openvpn.net X-Google-Smtp-Source: AGHT+IGiw7hTaBzlWTdIRU6ihZI+BL/X7quWNmQfZ6tbELOF2D5mRwjlJeV/QeVaauaRHOScRjXg X-Received: by 2002:a05:6e02:b44:b0:3a0:abec:da95 with SMTP id e9e14a558f8ab-3a0c9d7e0famr99653395ab.22.1727098900969; Mon, 23 Sep 2024 06:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727098900; cv=none; d=google.com; s=arc-20240605; b=gWpiyNl8Y7wGaeOOmCfx/N/hUbCn/PixbbbTQmRZa2+8CUPwkrS5OoMUXwnTQVK69t u9iBUSzYX+rX0DnFQ2rUdQcCQDsPztgnEUrnU4reiaH9ADYNPr96DXQxcjnWZHAH47Qr LqWCK8GnnsHbvGThfUgKARC9CYzYRSLgvlv66rxWmssIA1l5Z07KInutcF+RapzVYx6O rCYl06+iv+CMBOmz9Ir67BEpCCgaUsY932HLVpRrd18TcmqUCyZMSl/lZKb0YC5xzPTg nyO9ZtIrw5dOIOAr+0iwUd5s7uJjPauDDKeocAtNoMYx61lVZSDjOX6yZSX83KtoBWjC nF5g== 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=g6f57rG0fK2JxjtE3Rin8tgugPt6BR3TL43lqD7mGpQ=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=SX7DdsP8pbcRBGCWp8PLpSiZqo6MIddZVApZyyA00CWf1756WJL5evIDsuEbv5vx6Z aymb6peXAr7zvoop/z511rQkLrqdABO2w0C9YG5nOS/WX3OP4hAoawC451NzH9GCe8O9 UajX3h3FGc45zdQNwIdK6JNnpT14jXfYwuAQ6wY38ytXuHBykjN1wKQxeCxTXmG5ShVe EXYO9WsDmF/nxvALjHOjXLLKTiYiaVXZiu98+0qbtHmgyXZ/KkTKjAGKtyoSX4tf1fSY Mi0MIAY2Agce4KVXFaEwMS2gSTtduBEdSswj5+KoP3ncxJr9OFP3lQciZY8HDMenhYLd yH+A==; 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="WDxlJn3/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KxjSScDL; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="B/sR55UO"; 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 e9e14a558f8ab-3a0c8aad54bsi38515865ab.16.2024.09.23.06.41.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Sep 2024 06:41:40 -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="WDxlJn3/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KxjSScDL; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="B/sR55UO"; 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1ssjJo-0001sw-TK; Mon, 23 Sep 2024 13:41:36 +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 1ssjJn-0001sq-L1 for openvpn-devel@lists.sourceforge.net; Mon, 23 Sep 2024 13:41:35 +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=1nQxTnJz+nOzusBFOA62Q0A60i+JffBIohfYZNU9HUI=; b=WDxlJn3/fG1h9Th+voLNrfDIdh BhRErUyXusd7Sd5ebQluHLqFl5Aymz/NJSNeGjeEBDyK5D+TBTdm+x1AnL/EnryL52K+PS1zfXmps 5b/JoNKJ38DlTja1C0JAqkpZWfAIfgCi9Kk0SKwU1g9rciNcTBYQRCO9w6ikK9VOOQlw=; 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=1nQxTnJz+nOzusBFOA62Q0A60i+JffBIohfYZNU9HUI=; b=K xjSScDLYQHbMds+J830/vcW6nW+NgNk6+eKlkCdKzXuTxvvnIblG/R/B42hjLb7p8knU9eVDAJ0qW rYdfPtN+Bu1DNqQ0vWEYBWIvspIoInATTNjDPf8xlfZJATJTThD98jQdmchHwPNirAIgOdiHrvK1Z qS3aG1q+1DT8lxh8=; Received: from mail-wm1-f49.google.com ([209.85.128.49]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1ssjJm-0006qT-BP for openvpn-devel@lists.sourceforge.net; Mon, 23 Sep 2024 13:41:35 +0000 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cb1758e41so34599005e9.1 for ; Mon, 23 Sep 2024 06:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1727098883; x=1727703683; 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=1nQxTnJz+nOzusBFOA62Q0A60i+JffBIohfYZNU9HUI=; b=B/sR55UOE1H30X0pyB0GHA4GxB+aVwLwhJ842N+PC9lVKL+TboxlbXNyl7C1HnYZXS BEaIWFsm9bWBAsgFfCJzVg6/bQEfNzDbaX1HBDbPxbFLfA2iPIdlmHy9ZG1PwvkB9ZwT gHTnfTVeWeB5hPGAhUwQv5CUYta8yT/FRHnhHoIhCTjFRD8qo4d/UB39lDPan5d5pUT9 qVhvp5nqCTq+8yHF8b7D1y0JfDIzt9Fu7CFtjwWsob0pWLq+M43jP4sTz8TpbmkZT5nb dRYzJAmACHZOn0QcZFCLzaaek30f3cORm51nCE0hqWrB4B3z7UDOYbKogdw6Th9pF8+u Rdsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727098883; x=1727703683; 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=1nQxTnJz+nOzusBFOA62Q0A60i+JffBIohfYZNU9HUI=; b=WVcBTVPAdJs23IAKeoRFTGnxhiNpkb2P8FzuhiSFpr9gjfjptnpvuJxnmvm8AWzTyV l5kBnaNMa2GOUWhXZF7s1QHDwTJo5enb1TolNFb9V2PIW4bL8SdFgC8TLgOT40yfwfJc jSspvheQVExPr4HdywEdNZpsTgn7IXt5WDBm/PqKDpxQsEWWZS2MxEoyBh+I5LPWbfLk a4pe4zQhS8dtc2Sra/Z1LU9lUxwcg+m72dl2ESlQBSqVLCBaREznHGSExaBSTRibIuNx aPXPg+hUgp6sUpoBWRuPsYqVj1/cPPf4IzV6sT8LSjE2WdWhWBewmRdh5mivR4pAyUus 9c2Q== X-Gm-Message-State: AOJu0YwRt7duilAiLrKJ/XbTQJQkGgs6Qir//wtqFhXFvTw45Tf7DHf5 yW1Pz8sHSkIqI+2Im+yO3VEqrRSKcCzdbDalXpLuzmjcB8A62PbV0VGqsiMZTc1sIODu7jj+Trh Z X-Received: by 2002:a05:600c:4f0c:b0:42c:a7cc:cb64 with SMTP id 5b1f17b1804b1-42e7abe4424mr79987955e9.3.1727098882699; Mon, 23 Sep 2024 06:41:22 -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-42e754ce37bsm127393495e9.48.2024.09.23.06.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 06:41:22 -0700 (PDT) From: "its_Giaan (Code Review)" X-Google-Original-From: "its_Giaan (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 23 Sep 2024 13:41:21 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I7ebf0d4fb2a23278e16003b2e35598178155d658 X-Gerrit-Change-Number: 760 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 7630537217aef0fe1a08e99f70a506de9a6a5275 References: Message-ID: <66e639157ee1cdda4640c4c792f50a6a6f39dfb0-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -1.1 (-) 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, ordex, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-1.1 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.49 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.9 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.49 listed in wl.mailspike.net] 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_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1ssjJm-0006qT-BP 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: gianmarco@mandelbit.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com, a@unstable.cc Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1810994457021175573?= X-GMAIL-MSGID: =?utf-8?q?1810994457021175573?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld, ordex, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/760?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: I7ebf0d4fb2a23278e16003b2e35598178155d658 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/60/760/1 diff --git a/src/openvpn/event.h b/src/openvpn/event.h index 57341e0..71e134b 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 1247ba3..70d65d7 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2168,7 +2168,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) @@ -2231,7 +2232,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 c699e6e..c4bddfd 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; @@ -695,7 +693,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) {