From patchwork Mon Nov 20 13:02:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "its_Giaan (Code Review)" X-Patchwork-Id: 3460 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:50e4:b0:f2:62eb:61c1 with SMTP id r4csp2253137dyd; Mon, 20 Nov 2023 05:03:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5gwN/8BEdQyrHUJZqoA6nHjUiHKoK46LnahTru1DErbkTw6n3mJHIL7ome2ijy1hItGJQ X-Received: by 2002:a4a:e74e:0:b0:58a:7c36:9f7b with SMTP id n14-20020a4ae74e000000b0058a7c369f7bmr6580935oov.1.1700485385837; Mon, 20 Nov 2023 05:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700485385; cv=none; d=google.com; s=arc-20160816; b=znyD/cslg5YnhOPXwpgskrdio9+Mu5Uj4I7elL/ZPv07YTl1MT4BYwggBGWMWgMoYK g6A8KbWA7LPxeFOX/HvzWgD0GCq7Aidkg2GlPB5XfWFCrDSjJuOrXC8Rm71emoSiM+Wk n+4S8zfOSauHydoK5N3r/3EI5lhFxB448DYsSu6sZGiBG4WZnbP4X18rRKl2UBa9mgpv dMMfWVHtEeufoCHo1NACqVi22e2jjQo8vI17efFXh8Ml0pkJzah0LbGCASITDKG+nyI/ s935w0KhyFZsFiHjBeLWnfhSTw2GwhO2Ja07rKbNd0z/XcJUSH9PsUH6n/kinVmiCMka TgLA== 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=DUOwwtCXcaju38gunvdwGfFDNfYIlcIeJ/wKZnuBmVs=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=Uhv2GQZZ6bavoh+YCRgHfwo12aEbJZQtcrjyolvTy3Cjnlcp2wX9L0CTI99112PA2N 2/H7XvMRjqbWjGvh+XR4I7Yl91Qfdq8/Uchu7SbR1R0/CDiUwl9agEb0BA1SuFoQ9Tk6 R79K2ek0nihrDDe3+CWnlK0PcRpFcP3X3qRDr+Jwtm4RW4PUu2pZGKdBysGgbRW0D8g+ kUxTO8sRfDuTp6dzz61MuwjgjZaRxkmRDuetoezwxTnuuR0JP+8HwTCuCr8TBnb4i5/5 gDRKOkT2a/fBTZIR43FpSfXJA3iYx71aLOEePxiQjF6+jOQGfnZadYiP02LNBjQPsYlN ybAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Vl+R5yCB; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QJcB6XEB; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=TgambO7E; 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 cb9-20020a0568201b8900b005840e54e2besi3065500oob.60.2023.11.20.05.03.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 05:03:05 -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=Vl+R5yCB; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QJcB6XEB; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=TgambO7E; 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r53vL-0001lw-No; Mon, 20 Nov 2023 13:02:48 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r53vI-0001lj-Vz for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 13:02:45 +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=CHNagI70YQifUmj/ATGXGlhDFANTrZDHKm0NkjThwMs=; b=Vl+R5yCBvX4tPA8qM7nwLEkHfa 2B+LHXQ/zVrCBZoc/Ka9OttBajtdwr8md0G3PUP51GTLKnPW1hpCpZ0xnwcevPpGPPtj4qtexPzgJ 7OYA2KM3LaKxVJwSmOmCypePb9OcfoNzGd4XQTk7XgK+vAErw0uSH5LkjsomsQXzwgGY=; 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=CHNagI70YQifUmj/ATGXGlhDFANTrZDHKm0NkjThwMs=; b=Q JcB6XEBwo0yekL2NNStktmVjEHqEtFuwF2W9cxE770P/Nm1SbKdGLdaqNEQ+/BU89x+KsMVNhUdA/ 4Z3+COuvS/+jJ1rnRjQ0S95571xx4STLLRfouNFwnmZqoK+T6xulQQ+oVy3mN0dGYEIabk+xWi0Fm UTVNjeprgShhfLXA=; Received: from mail-wr1-f45.google.com ([209.85.221.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r53vI-0005fV-5h for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 13:02:45 +0000 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3316d09c645so1794838f8f.0 for ; Mon, 20 Nov 2023 05:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1700485357; x=1701090157; 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=CHNagI70YQifUmj/ATGXGlhDFANTrZDHKm0NkjThwMs=; b=TgambO7Ec+jQJnlKnFi5+dexJpA5sm7LdLYZ62Lqz4wvO4hIA5UwNfq2ZH5v9suy+v 1goPVd6oW1PMjMlc3Ed9f946J7K/S5jtS0Sksc3fYD7Svg/yoVVNECulRxuCBTpa9IkK PLdFhqKgECTR7Hmjabr+iOP5jdXHNYUonEIm6eVuwqSgiNkSdDYWbnCCGYX9W5nDlcPT wkZsoVxlQXbkwuEmE1+1cp+oBxoT+7Ym285MiUanAyY5PM9+7kCEf7KhcQCsKs0OrW53 YpKNaDDSAFOQska5xutO67P+KSiSSU67u3SsnXIDnrY1C7TiR6s1fHeAu8qHvMbhCBsC mUYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700485357; x=1701090157; 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=CHNagI70YQifUmj/ATGXGlhDFANTrZDHKm0NkjThwMs=; b=OnEeeb8p2NTzR1l/nsmzzWhOVhSliIRoZiLEbASIr32Si3BOn6856eZeuTpaPH/Xf6 tw5N23jHWwcIZEoecdT1HRkcr3tqJL0L25pagbkyM12vNfSbY2ocFQPfh6Pv7eKEn6MH KQ1N8Br1x/zec59RsTKvrOa06y3/YmGQl81Dco/SmqXZyp1fRoCypLS9yaVFQfyPcuAS cNSFcLum09g4kQeHpqjzNcSz5+3376taGTixL35rGKWvVo4O5PsWbu0WbInTtt1ztSQz vAC9Bj8PePmp12/CAjbahaCj/8LuwSaGO8k6Cg2Xb0LoDe4bzoXj8epxv95r9FmjE6Cn A/ow== X-Gm-Message-State: AOJu0YwLqDZF1g9eRtj0jk7c92A+Q/wHfBk/zEAecqftULT5Ddkpxi3e lNwgbN3/8Udd8NW4A+Lb9LFriJM8aOoxvAsMpUE= X-Received: by 2002:a5d:6486:0:b0:32d:a2d6:4058 with SMTP id o6-20020a5d6486000000b0032da2d64058mr5567167wri.62.1700485357396; Mon, 20 Nov 2023 05:02:37 -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 bf14-20020a0560001cce00b0032dde679398sm11270383wrb.8.2023.11.20.05.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:02:36 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 20 Nov 2023 13:02:36 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585 X-Gerrit-Change-Number: 452 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 0867c42f4975e317e7f33e7931c3a0ae0da1e675 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-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: Attention is currently required from: flichtenheld. Hello 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.221.45 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.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.45 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_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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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: 1r53vI-0005fV-5h Subject: [Openvpn-devel] [S] Change in openvpn[master]: Rename state_change to continue_tls_process 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: 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?1783088163628503636?= X-GMAIL-MSGID: =?utf-8?q?1783088163628503636?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/452?usp=email to review the following change. Change subject: Rename state_change to continue_tls_process ...................................................................... Rename state_change to continue_tls_process The name state_change is more confusing than helpful as it not really indicates if there was a state change but rather if processing should be continued. There even some states that are definitively state changes (setting to_link buffer) that require continue_tls_process to be set to false. Change-Id: Ib6d713f2eb08a4c39d97de3e1a4a832cedc09585 --- M src/openvpn/ssl.c 1 file changed, 21 insertions(+), 15 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/452/1 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index b4cd8f5..f46b661 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2848,13 +2848,19 @@ struct link_socket_info *to_link_socket_info, interval_t *wakeup) { - bool state_change = false; + /* This variable indicates if we should call this method + * again to process more incoming/outgoing TLS state/data + * We want to repeat this until we either determined that there + * is nothing more to process or that further processing + * should only be done after the outer loop (sending packets etc.) + * has run once more */ + bool continue_tls_process = false; struct key_state *ks = &session->key[KS_PRIMARY]; /* primary key */ /* Initial handshake */ if (ks->state == S_INITIAL) { - state_change = session_move_pre_start(session, ks, false); + continue_tls_process = session_move_pre_start(session, ks, false); } /* Are we timed out on receive? */ @@ -2872,7 +2878,7 @@ if (ks->state == S_PRE_START && reliable_empty(ks->send_reliable)) { ks->state = S_START; - state_change = true; + continue_tls_process = true; /* New connection, remove any old X509 env variables */ tls_x509_clear_env(session->opt->es); @@ -2885,7 +2891,7 @@ && reliable_empty(ks->send_reliable)) { session_move_active(multi, session, to_link_socket_info, ks); - state_change = true; + continue_tls_process = true; } /* Reliable buffer to outgoing TCP/UDP (send up to CONTROL_SEND_ACK_MAX ACKs @@ -2927,7 +2933,7 @@ } else { - if (!read_incoming_tls_ciphertext(&entry->buf, ks, &state_change)) + if (!read_incoming_tls_ciphertext(&entry->buf, ks, &continue_tls_process)) { goto error; } @@ -2938,7 +2944,7 @@ struct buffer *buf = &ks->plaintext_read_buf; if (!buf->len) { - if (!read_incoming_tls_plaintext(ks, buf, wakeup, &state_change)) + if (!read_incoming_tls_plaintext(ks, buf, wakeup, &continue_tls_process)) { goto error; } @@ -2954,7 +2960,7 @@ goto error; } - state_change = true; + continue_tls_process = true; dmsg(D_TLS_DEBUG_MED, "STATE S_SENT_KEY"); ks->state = S_SENT_KEY; } @@ -2970,7 +2976,7 @@ goto error; } - state_change = true; + continue_tls_process = true; dmsg(D_TLS_DEBUG_MED, "STATE S_GOT_KEY"); ks->state = S_GOT_KEY; } @@ -2988,7 +2994,7 @@ } if (status == 1) { - state_change = true; + continue_tls_process = true; dmsg(D_TLS_DEBUG, "Outgoing Plaintext -> TLS"); } } @@ -3006,7 +3012,7 @@ } } - return state_change; + return continue_tls_process; error: tls_clear_error(); ks->state = S_ERROR; @@ -3065,19 +3071,19 @@ msg(D_TLS_DEBUG_LOW, "TLS: tls_process: killed expiring key"); } - bool state_change = true; - while (state_change) + bool continue_tls_process = true; + while (continue_tls_process) { update_time(); dmsg(D_TLS_DEBUG, "TLS: tls_process: chg=%d ks=%s lame=%s to_link->len=%d wakeup=%d", - state_change, + continue_tls_process, state_name(ks->state), state_name(ks_lame->state), to_link->len, *wakeup); - state_change = tls_process_state(multi, session, to_link, to_link_addr, - to_link_socket_info, wakeup); + continue_tls_process = tls_process_state(multi, session, to_link, to_link_addr, + to_link_socket_info, wakeup); if (ks->state == S_ERROR) {