From patchwork Wed Sep 18 17:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3844 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6794:b0:5b9:581e:f939 with SMTP id c20csp886274mao; Wed, 18 Sep 2024 10:36:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWU+IAe97k8wpC6t2gXQYA7/k9rferDusRe90buGc6W0W1lKkKGwodDennUzbYzK+Xfvoa3457uvY4=@openvpn.net X-Google-Smtp-Source: AGHT+IHKgGSzA23U8XiyexJTJ4PmN8Q9U4FnlsRLzcWkwvL2nWAE4TryDpUUXVYa3UjkkKFxYFsy X-Received: by 2002:a92:c548:0:b0:3a0:8dcb:b033 with SMTP id e9e14a558f8ab-3a08dcbb224mr153546535ab.24.1726680977808; Wed, 18 Sep 2024 10:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726680977; cv=none; d=google.com; s=arc-20240605; b=H8Fef8ttk4ulxDSh8tV8MBOJNwRsFAka7ykPz+mxdtbHoZyiI5whNtlAATVJg4jiqq eYIijRBXky6T6/d/pai6WtdUalBMvfLZHmq+08hQgPIejMrEqsfe69xsusVo1QhsmZ8q WgxE8oNLkDzaSVRZHajzkitqpjJgaO19C1+PdmqAfVhZ2gJEzMU27WWmNluzFJxY3vi+ NJLcLY5F+bA6jDKAadvKrgp0z9gx2kKSyFiBC9Tv32zUU0fJYuWX0YTc3b9bq8SZs7Cg WyqlGilALSmTQtORle84152YDFiMDlD3gin7XGz1tjSnKrh4V93RodEaQYBWtliWcMpf Zy0w== 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=rVfW4bxHqNPk0/ZCYPoUWZ1g1r43YedCNQF93ijSwRM=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=SpV4SzpqpRr/9oS0XxsbsyYNAC9HGMLxw3EobSO0BvYac8oPIQ+vN/BUtal3iH20r4 3IMAUwJXaaksvpcDc6H62vVH7RDV1yxjTr1/t3N2NRD4lsl9IxK4Aowuw+TShqcgtcoR Hi82KrVMQ/ZPgn/s1gP/UcYe7dMoZWUQtY+35f6Bb1VP9RD5aYGJXqHXgJYY0/KHqBEi IeuHh3gbrYu0K9d67Oj/MGyNO7POqwND7DErBt+nQrdujnbTLbXh0vcruMWEgzGBG7xH cweR2XByy3b1+nc+ewjRSNoUzuPRDe4mQqiBWiTuKg5M416ta7MeFi0pY7MlLGgeNYlX GE9Q==; 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="A+Wo4/GW"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=dDW98Vnv; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=AInUWNS+; 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-3a092e8f3a4si44826145ab.150.2024.09.18.10.36.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Sep 2024 10:36:17 -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="A+Wo4/GW"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=dDW98Vnv; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=AInUWNS+; 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sqyb0-0000Zc-1X; Wed, 18 Sep 2024 17:36:06 +0000 Received: from [172.30.29.66] (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 1sqyar-0000Yo-Mp for openvpn-devel@lists.sourceforge.net; Wed, 18 Sep 2024 17:35:58 +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=2V7n7SGNK0lo5DC1Pj4JE9ai6B5gP/U+tnSKgW4LSMc=; b=A+Wo4/GW9KeBTXcM1p9xlJ+N+m gi9YLc0+JAok4y6Xh8bTjf7sW8lBMWbg21lxHoIYnPuxR6xF5EwMAngKzdk4Gn5IlQZ21qg90/QqN iKIpF2gqecT1ykwsqPfzmTyK6NA811MULe2p+AhhJ99uDZ/jNNBe3WtJPASiSeEk+fpc=; 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=2V7n7SGNK0lo5DC1Pj4JE9ai6B5gP/U+tnSKgW4LSMc=; b=d DW98VnvOkoOLTyR5LjbGzzM7396bHdQ2PjS7JHUtRHlHUjW6IQulYX975vX666muuWTxKoPQj4Qbm d9+G5iuLZuIp5mJig4ykNU69y/2urmplxDgT412ggOzfiXjlncS78hbgEFRSKcLQq6HM/eNarRF+H qDUAUHkN6rnzQSgY=; Received: from mail-wr1-f46.google.com ([209.85.221.46]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1sqyar-0000Fz-BZ for openvpn-devel@lists.sourceforge.net; Wed, 18 Sep 2024 17:35:58 +0000 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-374ca65cafdso3838360f8f.2 for ; Wed, 18 Sep 2024 10:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1726680945; x=1727285745; 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=2V7n7SGNK0lo5DC1Pj4JE9ai6B5gP/U+tnSKgW4LSMc=; b=AInUWNS+f0X4q9jDvlJJYRcydJbSJCjz3YMwPbqulotfJKHjOB//pf62ZWjtA/ud+n WxOZzoRTUvuitwBKmgYcFYYUcCtAx4CuuQq/FcUUKNj6TZukELHv9cOGZhSDL72EP0Dv UQPtaiM7tY0As0ZB7mt0RDLV9cIrWLB3wMnGnGIlszFT3UkrrC6r+BqvuoO05UMTuHeG 5+7Y/0MPIiO2Jiq78IXzKW8n8KIdInFGmfX4/0qJyM73JxZFu4RzFxrNbS4Of6JV03rQ YgIgDfBFh4cblSl+TMQV8lm1gsuwt8IoNvLhINbK398p0V4e3Wk5JhrkeBFyeo+B54n8 ACvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726680946; x=1727285746; 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=2V7n7SGNK0lo5DC1Pj4JE9ai6B5gP/U+tnSKgW4LSMc=; b=dFGV7NiGEd8T3hPwDZ3Jthco1OROa/zrKuomF33Ry2+eXnxgeDAhrd6KeWM5NuFYEo EsqajaYFXHG1C+Q6kNyPGvkT6oW0EZcjSZyMuJBZGPOl2BoW1zMUH+UrnE5BRVDsEZ9p 5o7aOx1tPslE+ATCFicoYMQXcE+xL+nIn0MEnnWZPBqM7bD0rrrjjv4ScJdQEVy504su 7wv/eKQzMT/fmBWl2LqRCx3SJNzvB7Dek5E6qohJZGtAYd0ee/dQYTDS74uPrhWk0x6b p7jXRq1M+vTnvBlqhOZasJOwLVWNXdHNo3z9ZBAetClTdLEgep3/aa0IREJBO+CM0Zcv OhsA== X-Gm-Message-State: AOJu0Yz5MTQ8pLdb2aMrytJc4mjiqNpuV6pjpaPFV3GLhFQwSpTK6S6K BCSK1vkvb50LLJiMxHwC+aI8WN9QBaUmcUcEFT2zDT2KNdBM1GI/HDfZ21xKHROfHRwlwhjpuxP V X-Received: by 2002:a05:6000:1bca:b0:374:c847:85c with SMTP id ffacd0b85a97d-378d61e2c1fmr9494443f8f.24.1726680945564; Wed, 18 Sep 2024 10:35:45 -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 ffacd0b85a97d-378e780defdsm12711394f8f.115.2024.09.18.10.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 10:35:45 -0700 (PDT) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Wed, 18 Sep 2024 17:35:44 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c X-Gerrit-Change-Number: 753 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 6c73058837fc4bde99bb13ffe0d8eae5055e207c References: Message-ID: <6c122f07c357a8877ba5259f3f6f01df7199b788-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -1.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: (-1.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.46 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 -1.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.46 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 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_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.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1sqyar-0000Fz-BZ Subject: [Openvpn-devel] [S] Change in openvpn[master]: Refactor methods to use the actual state of tun rather the options st... 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?1810556232876236926?= X-GMAIL-MSGID: =?utf-8?q?1810556232876236926?= 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/+/753?usp=email to review the following change. Change subject: Refactor methods to use the actual state of tun rather the options struct ...................................................................... Refactor methods to use the actual state of tun rather the options struct Change-Id: Ib8ba2b63ea9fd1944ff07f69c545a880e464680c Signed-off-by: Arne Schwabe --- M src/openvpn/dco.c M src/openvpn/forward.c M src/openvpn/tun.c M src/openvpn/tun.h 4 files changed, 13 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/53/753/1 diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 2f33973..384ffe6 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -476,7 +476,7 @@ int dco_p2p_add_new_peer(struct context *c) { - if (!dco_enabled(&c->options)) + if (!tun_dco_enabled(c->c1.tuntap)) { return 0; } @@ -511,7 +511,7 @@ void dco_remove_peer(struct context *c) { - if (!dco_enabled(&c->options)) + if (!tun_dco_enabled(c->c1.tuntap)) { return; } @@ -631,7 +631,7 @@ struct mroute_addr *addr) { #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) - if (!dco_enabled(&m->top.options)) + if (tun_dco_enabled(m->top.c1.tuntap)) { return; } @@ -668,7 +668,7 @@ dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi) { #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) - if (!dco_enabled(&m->top.options)) + if (!tun_dco_enabled(m->top.c1.tuntap)) { return; } diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 9c78adf..4b620ea 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -145,7 +145,7 @@ check_dco_key_status(struct context *c) { /* DCO context is not yet initialised or enabled */ - if (!dco_enabled(&c->options)) + if (!tun_dco_enabled(c->c1.tuntap)) { return; } @@ -483,7 +483,7 @@ static void check_inactivity_timeout(struct context *c) { - if (dco_enabled(&c->options) && dco_get_peer_stats(c) == 0) + if (tun_dco_enabled(c->c1.tuntap) && dco_get_peer_stats(c) == 0) { int64_t tot_bytes = c->c2.tun_read_bytes + c->c2.tun_write_bytes; int64_t new_bytes = tot_bytes - c->c2.inactivity_bytes; @@ -623,7 +623,7 @@ const uint8_t *orig_buf = c->c2.buf.data; struct crypto_options *co = NULL; - if (dco_enabled(&c->options)) + if (tun_dco_enabled(c->c1.tuntap)) { msg(M_WARN, "Attempting to send data packet while data channel offload is in use. " "Dropping packet"); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index ec63bff..e44f2f0 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1872,15 +1872,6 @@ return has_digit(dev); } -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) -static bool -tun_dco_enabled(struct tuntap *tt) -{ - return tt->backend_driver == DRIVER_DCO; -} -#endif - - #if !(defined(_WIN32) || defined(TARGET_LINUX) || defined(TARGET_SOLARIS)) static void open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index db0b5d7..7e4cb59 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -261,6 +261,12 @@ #endif } +inline static bool +tun_dco_enabled(struct tuntap *tt) +{ + return tt && tt->backend_driver == DRIVER_DCO; +} + #ifdef _WIN32 static inline bool tuntap_is_wintun(struct tuntap *tt)