From patchwork Thu Mar 9 12:37:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 3117 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:2310:b0:9f:bfa4:120f with SMTP id r16csp327637dye; Thu, 9 Mar 2023 04:38:25 -0800 (PST) X-Google-Smtp-Source: AK7set/P7YIHQAh1fhY33k2JHt4VnF5EbMEQWWp86sk4BxzzmIoanaKvPCcLTnhGFqRCK76iUcV2 X-Received: by 2002:a05:6a20:3954:b0:cb:af96:ace7 with SMTP id r20-20020a056a20395400b000cbaf96ace7mr26942804pzg.46.1678365505720; Thu, 09 Mar 2023 04:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678365505; cv=none; d=google.com; s=arc-20160816; b=N/H/CYS4nGhD4nr30RQPx9iWK83Wdx4grlMFoH8++DOJpJehNz9kTXrDtQqw5RodgN g59fbElTcuMWa66u1q9jpEGfVG+MDIazyDeZjobj5ngta6n+SdfAB+s7jhHWiaIz5r1V O5zYVyDAUlP+VH+xLzq6Lcunuba7dSkmHlDzDG9z3BLv3HYKtQT1oJBy2tXN/rv1W7Rf BxG0iE05oB5Yzcau3QGJCvZPoMAPa+pp+Dne0RvYXWRtLk2HVut9ysTgtq9Tm046VOfl kBkdQ32vhXUtgj915xlkrfLVLjmAgYgIdb8pjyhgAnxBooNDGioHicA9PyLDaAXT4qdL jvqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc: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:dkim-signature; bh=Hq1WUgVVLH6XFWPJjcoiiHlGuFWP91c20hUU9YBnzuI=; b=P0PES4v+4r8gflBstflCghgtFEyK2Eg/N57H8wQbhViyg3SJmizIi9tXVTDPmBuPwy QP1U982qzVqO8l7ivTecNbVCfU8OlmEfv2yePEuLTue9OorU1bSswrTtZE1KoBF6oWb/ Jd/8jg45vrF0d0g3TruUfS/HkDX84KUueAKMNHlwnX3zAdT/3S+XTITb2rOXTZavR+/i ZglfdVpw6YXdHsnXDxh2AcNYmlWCJAxLAsKHvjia8+l2sck8Mq954dXqKWIddimOer14 93Y7DXTPSDmsUCzCYeREXamIcCVJ0l9re92g0BRK9S/qyMKBett+CLdSZ4t0ER3FFcSu O6LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GYCW7wki; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Ojj6mxGk; dkim=fail header.i=@unstable.cc header.s=20220809-q8oc header.b=ow5TPSep; 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 z3-20020a63e103000000b004fbd2528bbesi16450952pgh.769.2023.03.09.04.38.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2023 04:38:25 -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=GYCW7wki; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Ojj6mxGk; dkim=fail header.i=@unstable.cc header.s=20220809-q8oc header.b=ow5TPSep; 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 1paFX3-0006MY-SW; Thu, 09 Mar 2023 12:38:06 +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 1paFX2-0006MR-My for openvpn-devel@lists.sourceforge.net; Thu, 09 Mar 2023 12:38:05 +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:Cc:To:From:Sender:Reply-To: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=y9509twxtGPwH5rln34Mlur/34h9CsMn+VR/Xk2lrQI=; b=GYCW7wki8SQOEhEbvrrY2jF4gb eoGR0dKiWL5kaCmEibsvDr8rhnP5vrZ/IOIS6P+wDaZqtAS8hr0obo4fHO7GbaVxE/TZ1p2V81kIk XGvn99ReeFVZSBd2/GImO98K3Wpmm2+VyEHHRkU9cjbydgJu3fPn7Hs4uFzMuNJ5dfZ4=; 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:Cc:To:From:Sender:Reply-To: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=y9509twxtGPwH5rln34Mlur/34h9CsMn+VR/Xk2lrQI=; b=Ojj6mxGkMzFVdDAIYPpeRgWafC erl6WL1C6OygRSoqovxDWSIPiuZsHjDg3LCpj9Qe7jVUP3JWG7z3QOQEQVkeh5+vm8JvO6dFOX/DH mUcN3S45MUQV0NbyH1ncmHD3kPdMWksW9NgieN8YMbxfA9UJyUTwWr260bKsZH4dB3AM=; Received: from wilbur.contactoffice.com ([212.3.242.68]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1paFX2-0006ng-6o for openvpn-devel@lists.sourceforge.net; Thu, 09 Mar 2023 12:38:04 +0000 Received: from smtpauth2.co-bxl (smtpauth2.co-bxl [10.2.0.24]) by wilbur.contactoffice.com (Postfix) with ESMTP id 48F53C5C; Thu, 9 Mar 2023 13:37:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1678365476; s=20220809-q8oc; d=unstable.cc; i=a@unstable.cc; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; l=5202; bh=y9509twxtGPwH5rln34Mlur/34h9CsMn+VR/Xk2lrQI=; b=ow5TPSep9/APHywV10fz1yai6QcjyW5kPsHNnpU9XDsMUAkw21UDS/iiOUKSVGWz foIjDhgUwdZWj75HSfGoLnXfSEDgAaJOK59tE9/ofeCCjEnGtWxs7rOZnQae6C/ilNT ensHFX8OiXc/J5WuY13DjkVvZ4azK5gqwfiE8Z2lnTBU2XYUHQOGDY2kL2A8QtITw1c XAMejqCrs17vdaSuLk4xBKvZv3QaLXhLDY3MxVoXJuLoxxFgDZXpPSfwqBHvIhmfDNi nrSsYR77b20O6z/jNAB0Hy9Wd3bcE30Rkk2Cy6U7pKtm2nWjSL7LUaWGnYXnBPw4JxV gxcG2aCO1A== Received: by smtp.mailfence.com with ESMTPSA ; Thu, 9 Mar 2023 13:37:53 +0100 (CET) From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Thu, 9 Mar 2023 13:37:37 +0100 Message-Id: <20230309123737.12358-1-a@unstable.cc> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309005208.29704-1-a@unstable.cc> References: MIME-Version: 1.0 X-Spam-Flag: NO X-Spam-Status: No, hits=-2.9 required=4.7 symbols=ALL_TRUSTED, BAYES_00 device=10.2.0.20 X-ContactOffice-Account: com:375058688 X-Spam-Score: -0.9 (/) 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: In order to provide better support in case of troubleshooting issues, it's important to know what exact DCO version is loaded on the user system. Therefore print the DCO version during bootup. For Windows and FreeBSD we currently implement a placeholder printing 'v0'. This should be improved with a follow-up patch. Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.3.242.68 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -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_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 X-Headers-End: 1paFX2-0006ng-6o Subject: [Openvpn-devel] [PATCH v2] dco: print version to log if available 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1759849413457537591?= X-GMAIL-MSGID: =?utf-8?q?1759893788540788660?= In order to provide better support in case of troubleshooting issues, it's important to know what exact DCO version is loaded on the user system. Therefore print the DCO version during bootup. For Windows and FreeBSD we currently implement a placeholder printing 'v0'. This should be improved with a follow-up patch. For Linux we directly fetch the module version from /sys and print something like: DCO version: 0.1.20230206-15-g580608ec7c59 Change-Id: Ie1f6fa5d12a473d353d84fd119c2430b638e8bcd Signed-off-by: Antonio Quartulli --- Changes from v1: * beautify usage of buf with some helpers * don't apply -1 to buffer capacity as fgets will already read one byte less than provided length and will add a null terminator there --- src/openvpn/dco.h | 15 +++++++++++++++ src/openvpn/dco_freebsd.c | 6 ++++++ src/openvpn/dco_linux.c | 27 +++++++++++++++++++++++++++ src/openvpn/dco_win.c | 6 ++++++ src/openvpn/openvpn.c | 2 ++ src/openvpn/options.c | 11 +++++++++++ src/openvpn/options.h | 2 ++ 7 files changed, 69 insertions(+) diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index 2fe671bf..96d95c21 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -58,6 +58,15 @@ struct tuntap; */ bool dco_available(int msglevel); + +/** + * Return a human readable string representing the DCO version + * + * @param gc the garbage collector to use for any dynamic allocation + * @return a pointer to the string (allocated via gc) containing the string + */ +const char *dco_version_string(struct gc_arena *gc); + /** * Check whether the options struct has any option that is not supported by * our current dco implementation. If so print a warning at warning level @@ -250,6 +259,12 @@ dco_available(int msglevel) return false; } +static inline const char * +dco_version_string(struct gc_arena *gc) +{ + return "not-compiled"; +} + static inline bool dco_check_option(int msglevel, const struct options *o) { diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 92de5f04..cbd2ce20 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -614,6 +614,12 @@ out: return available; } +const char * +dco_version_string(struct gc_arena *gc) +{ + return "v0"; +} + void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg) { diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 308abfc4..00d32d05 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -841,9 +841,36 @@ dco_available(int msglevel) "Note: Kernel support for ovpn-dco missing, disabling data channel offload."); return false; } + return true; } +const char +*dco_version_string(struct gc_arena *gc) +{ + struct buffer out = alloc_buf_gc(256, gc); + FILE *fp = fopen("/sys/module/ovpn_dco_v2/version", "r"); + if (!fp) + { + return "N/A"; + } + + if (!fgets(BSTR(&out), BCAP(&out), fp)) + { + return "ERR"; + } + + /* remove potential newline at the end of the string */ + char *str = BSTR(&out); + char *nl = strchr(str, '\n'); + if (nl) + { + *nl = '\0'; + } + + return BSTR(&out); +} + void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg) { diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index a805c2a0..26463b38 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -385,6 +385,12 @@ dco_available(int msglevel) return false; } +const char * +dco_version_string(struct gc_arena *gc) +{ + return "v0"; +} + int dco_do_read(dco_context_t *dco) { diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index cba58276..1aaddcdf 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -262,6 +262,8 @@ openvpn_main(int argc, char *argv[]) #endif show_library_versions(M_INFO); + show_dco_version(M_INFO); + /* misc stuff */ pre_setup(&c.options); diff --git a/src/openvpn/options.c b/src/openvpn/options.c index ce7bd0a7..8f0e2194 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -4816,6 +4816,16 @@ show_windows_version(const unsigned int flags) } #endif +void +show_dco_version(const unsigned int flags) +{ +#ifdef ENABLE_DCO + struct gc_arena gc = gc_new(); + msg(flags, "DCO version: %s", dco_version_string(&gc)); + gc_free(&gc); +#endif +} + void show_library_versions(const unsigned int flags) { @@ -4839,6 +4849,7 @@ usage_version(void) #ifdef _WIN32 show_windows_version( M_INFO|M_NOPREFIX ); #endif + show_dco_version(M_INFO | M_NOPREFIX); msg(M_INFO|M_NOPREFIX, "Originally developed by James Yonan"); msg(M_INFO|M_NOPREFIX, "Copyright (C) 2002-2023 OpenVPN Inc "); #ifndef ENABLE_SMALL diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 7df717f7..2f25f5d0 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -796,6 +796,8 @@ void show_windows_version(const unsigned int flags); #endif +void show_dco_version(const unsigned int flags); + void init_options(struct options *o, const bool init_gc); void uninit_options(struct options *o);