From patchwork Fri Feb 10 14:27:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 3075 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp1312971dyk; Fri, 10 Feb 2023 06:28:16 -0800 (PST) X-Google-Smtp-Source: AK7set/pzX20QKKL/+t43P5aB4WtkYknpQibXD+NuZs9xEouMDe/BnVbg4SNUKaO41oBLZfg7omk X-Received: by 2002:a62:7bc8:0:b0:593:c665:f256 with SMTP id w191-20020a627bc8000000b00593c665f256mr5315168pfc.3.1676039295944; Fri, 10 Feb 2023 06:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676039295; cv=none; d=google.com; s=arc-20160816; b=CBrQ0eGYcu08aqFGo88U6n3l7NIPCkjPUFxwWE+Xk6Z9+lM+jNmkD2tDGxXjRy/N5+ urDBiuLmlHZNR4+sTodxGtN3xVSJmAY/bU+QnWfLSR8RG2AFuyRDUShWahLq53rOqn7C Ugt+aFuVmJZC8Aqi9PMC7Wj3E+Tmz+Eaa/VCSo3OqAkZSOHm5KgptnhzUhR+EE+I8jUL qd+IZ3pdYUs3qMFunQSQFzyljLXM10otm/pF5PquVIL2DUvkY4W5xP3kcrlEAOgHIFNo 9w9y0M3tAPn+IJuVyW+2J9cCkyAhKsPicgUZ0jeJ9E/tousKW5XV00+Ya+VmsftkYLkL RclQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=Tgm5PQmv/2xNT6L2JnI6HWos8ApgKfpQd/g54fEuLv8=; b=1DgNma2H/hpsbcBb2Hv1YRKwwcOax/v8fwWeW9mmcMDNNIThBVKUlpwMraKZ7eT0MN ickPNLAjVDRaqLZM2CLKK6O2Ha8orrZFH17XyRq7ovwHYA8TneiavG6KQPuKnKnm1nVX JrZrBUrpcMLxNeLPARndRpapfGgawgmK1xSigwpZBZPfSchzSgWQAzdZOX4XFXliQzhK rXBmaq1KGRIdJnrT/CImOTnDsDB7fzs81Ws519mvbYBCNbmTPVnIoFfcOTFNBz2U+FZF +dLSsLDq9o95V12vhz4kpnni4QzSzrn1yZEhjCsxlFhXdYtfA1zK5S6s2u0Zs0HODdYA XIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=DXbzhNFL; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=K356iBlR; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id h3-20020a056a00000300b00593b8c172d8si4380703pfk.200.2023.02.10.06.28.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2023 06:28:15 -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=DXbzhNFL; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=K356iBlR; 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 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pQUN8-0002my-T4; Fri, 10 Feb 2023 14:27:30 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pQUN6-0002me-Kz for openvpn-devel@lists.sourceforge.net; Fri, 10 Feb 2023 14:27:27 +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=PQyaNORpjG1b8fjDtFJtpo/mnPlV++E523fBzjzka88=; b=DXbzhNFLRn+/tOID2lE9q55xRy 22TEDDfz5nQOcmHkfhJIo/BwU4tOlvIlRzLvVTyQXyqH2ZZLXS+nxiSxu/TcRYW0aE8nt/FLEanAl OweyRtH6WvI/ZiIhU9x1KUQPGHROimxuIH+biXNHjI6E3A9PsPaOSc6XNt4HQpYN5Bok=; 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=PQyaNORpjG1b8fjDtFJtpo/mnPlV++E523fBzjzka88=; b=K356iBlR2k3E3UBC9+qu00Lxnc TTXrHaRj+rPSWnx5WUAj4pJySjWcA91m7fUza7piSgfww3GHlnfp7K7LzaV5m9oNPGgFDK/iwv4xE EyWKekqUZk+GoaZhF25MZvcHDb8WQNIYmSZHzrOZdjMkWo/tmzOgoQdqMJ57VVRCMRug=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pQUN1-0007Ej-91 for openvpn-devel@lists.sourceforge.net; Fri, 10 Feb 2023 14:27:27 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1pQUMq-00051a-6H for openvpn-devel@lists.sourceforge.net; Fri, 10 Feb 2023 15:27:12 +0100 Received: (nullmailer pid 572355 invoked by uid 10006); Fri, 10 Feb 2023 14:27:12 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 10 Feb 2023 15:27:06 +0100 Message-Id: <20230210142712.572303-3-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230210142712.572303-1-arne@rfc2549.org> References: <20230210142712.572303-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Score: 0.3 (/) 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: Instead of passing a value and a bool just pass the value and 0 if the caller does not want the value to be added. This also allows the function to be used by a function without a frame struct. Signed-off-by: Arne Schwabe --- src/openvpn/mss.c | 2 +- src/openvpn/mtu.c | 14 +++++--------- src/openvpn/mtu.h | 6 +++--- src/openvpn/occ.c | 3 +-- 4 files changed, 10 insertions( [...] Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1pQUN1-0007Ej-91 Subject: [Openvpn-devel] [PATCH 1/4] Combine extra_tun/frame parameter of frame_calculate_payload_overhead 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?1757454580552971088?= X-GMAIL-MSGID: =?utf-8?q?1757454580552971088?= Instead of passing a value and a bool just pass the value and 0 if the caller does not want the value to be added. This also allows the function to be used by a function without a frame struct. Signed-off-by: Arne Schwabe Acked-By: Frank Lichtenheld --- src/openvpn/mss.c | 2 +- src/openvpn/mtu.c | 14 +++++--------- src/openvpn/mtu.h | 6 +++--- src/openvpn/occ.c | 3 +-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/openvpn/mss.c b/src/openvpn/mss.c index 429aa1e93..98d540688 100644 --- a/src/openvpn/mss.c +++ b/src/openvpn/mss.c @@ -303,7 +303,7 @@ frame_calculate_mssfix(struct frame *frame, struct key_type *kt, /* Calculate the number of bytes that the payload differs from the payload * MTU. This are fragment/compression/ethernet headers */ - payload_overhead = frame_calculate_payload_overhead(frame, options, kt, true); + payload_overhead = frame_calculate_payload_overhead(frame->extra_tun, options, kt); /* We are in a "liberal" position with respect to MSS, * i.e. we assume that MSS can be calculated from MTU diff --git a/src/openvpn/mtu.c b/src/openvpn/mtu.c index 1d9ebe011..56ea67061 100644 --- a/src/openvpn/mtu.c +++ b/src/openvpn/mtu.c @@ -108,20 +108,16 @@ frame_calculate_protocol_header_size(const struct key_type *kt, size_t -frame_calculate_payload_overhead(const struct frame *frame, +frame_calculate_payload_overhead(size_t extra_tun, const struct options *options, - const struct key_type *kt, - bool extra_tun) + const struct key_type *kt) { size_t overhead = 0; /* This is the overhead of tap device that is not included in the MTU itself * i.e. Ethernet header that we still need to transmit as part of the - * payload */ - if (extra_tun) - { - overhead += frame->extra_tun; - } + * payload, this is set to 0 by caller if not applicable */ + overhead += extra_tun; #if defined(USE_COMP) /* v1 Compression schemes add 1 byte header. V2 only adds a header when it @@ -158,7 +154,7 @@ frame_calculate_payload_size(const struct frame *frame, const struct key_type *kt) { size_t payload_size = options->ce.tun_mtu; - payload_size += frame_calculate_payload_overhead(frame, options, kt, true); + payload_size += frame_calculate_payload_overhead(frame->extra_tun, options, kt); return payload_size; } diff --git a/src/openvpn/mtu.h b/src/openvpn/mtu.h index 0ff4f7bfa..21dbcee7f 100644 --- a/src/openvpn/mtu.h +++ b/src/openvpn/mtu.h @@ -217,10 +217,10 @@ frame_calculate_payload_size(const struct frame *frame, * * [IP][UDP][OPENVPN PROTOCOL HEADER][ **PAYLOAD incl compression header** ] */ size_t -frame_calculate_payload_overhead(const struct frame *frame, +frame_calculate_payload_overhead(size_t extra_tun, const struct options *options, - const struct key_type *kt, - bool extra_tun); + const struct key_type *kt); + /** * Calculates the size of the OpenVPN protocol header. This includes diff --git a/src/openvpn/occ.c b/src/openvpn/occ.c index 0fa803cdb..94b82e0f5 100644 --- a/src/openvpn/occ.c +++ b/src/openvpn/occ.c @@ -305,8 +305,7 @@ check_send_occ_msg_dowork(struct context *c) const struct key_type *kt = &c->c1.ks.key_type; /* OCC message have comp/fragment headers but not ethernet headers */ - payload_hdr = frame_calculate_payload_overhead(&c->c2.frame, &c->options, - kt, false); + payload_hdr = frame_calculate_payload_overhead(0, &c->options, kt); /* Since we do not know the payload size we just pass 0 as size here */ proto_hdr = frame_calculate_protocol_header_size(kt, &c->options, false);