From patchwork Thu Mar 9 13:14:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 3118 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:2310:b0:9f:bfa4:120f with SMTP id r16csp353249dye; Thu, 9 Mar 2023 05:15:53 -0800 (PST) X-Google-Smtp-Source: AK7set9xmjHL8kVU5Qd8kN6gygqYd7dMD0lu2Qa0FDTGD5f8KE0o7c/VXGWBrkHcKqUYUoxrumMH X-Received: by 2002:a17:90b:1804:b0:233:af77:c075 with SMTP id lw4-20020a17090b180400b00233af77c075mr22739803pjb.36.1678367752918; Thu, 09 Mar 2023 05:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678367752; cv=none; d=google.com; s=arc-20160816; b=A9OPogJXxEjuKuKxfHQxaWZpt+VHZwQeFT+9VQv7AHX+FSry6jURKEB1+u6ATcj4Lu 05gkGTue8dG9QdF+n37zUXfpJ9EYz1pO2iY2SqWoWon4eNh5dWSVLScOBkNXuy701EUX AVnTsTCTxITq3bw6I+cZ0fKX6d3a9MdJxxGmRJxgCOvT+DKRzltCG0Uwc/RZeQS6kJCh Ui9U7qvW8+KPF3zdlvKPSx3cfcpv6iM5kaQHxh2s0uV6/lIOTi753fYJa1pHnOxSPEhs sm2gE6dC8wK1kS1DAXJgx9uAFwyJ81GylaMJCvmnnEQ5JrHSCKWtlcWwKz6RtTycx2FH nIFA== 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=90MYTenPr6X2JVZgsl3+qBaUh8Dg6/alGHhC15GhiS4=; b=zoC/OICgMG0/mDotq8ewVKw8Z1T48Co1vzCkN82IKf91/ur6PXkd6vgfFaTSHApcE+ MMKJnZXge4S1TzR3hJDu0809XP1CtiOI6n/qzDl8Q+jwZIt/BEAiojhRbfvjqVFFz3sc Biwm2xJugbg0BH7GNU89nub3r2aYRN+DXmBgVOgeWi/4BL7wFB9URXdGK17PFxydyC16 02wvILz1/Xs05s+NLIY1bLZ3ei7iO8aWK3DiZtqAcOOmUHwsUU11BNEUDhov7kZkdYNR G+RKeuPute5XI/CxefVjZWTGGST1i2+fqyYwuRQTZoxK02O8/lxlHXCT4PN25fclp2hG TFGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=B+4FuA7p; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="dD53W/DV"; dkim=fail header.i=@unstable.cc header.s=20220809-q8oc header.b="p/kn6ktR"; 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 y6-20020a17090a134600b002340152a657si2120624pjf.176.2023.03.09.05.15.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2023 05:15:52 -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=B+4FuA7p; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="dD53W/DV"; dkim=fail header.i=@unstable.cc header.s=20220809-q8oc header.b="p/kn6ktR"; 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 1paG6e-00076A-Dg; Thu, 09 Mar 2023 13:14:53 +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 1paG6c-00075z-5t for openvpn-devel@lists.sourceforge.net; Thu, 09 Mar 2023 13:14:50 +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=f25PlUphD6PgF3JNfVC6jEE7m1STYPoE/OnzHRPurJM=; b=B+4FuA7piUyXDihT88cudUrSam nOaj2MTxhPdGNeYqCndsIpLRFlcIjuFr0uetIAkO1avZRKETQw9KOZA+5nYXKOkF+nJkexvBVwcG0 GZdn7i8QWwzXbI0DOxUEajT/R6orGtAqX/SxVv4pqcAaMEesD+TrnOg2xblAg23js0+I=; 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=f25PlUphD6PgF3JNfVC6jEE7m1STYPoE/OnzHRPurJM=; b=dD53W/DVg4YOJqqMpZLNUKJ445 TeOWYCxIbh2W3JGJ77TRSH28I0lwrpZc7H65PeT1fTfLx7Ngou96tSewmGjswmOoCQ7pnhz2T9pba 5sqnNhWm9itaKGveAqOks/t1RWExUxGHSjABIyZjegMlayGNXXWFwcN5ljX7mAbJpoPc=; 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 1paG6V-0000E7-JZ for openvpn-devel@lists.sourceforge.net; Thu, 09 Mar 2023 13:14:48 +0000 Received: from smtpauth2.co-bxl (smtpauth2.co-bxl [10.2.0.24]) by wilbur.contactoffice.com (Postfix) with ESMTP id 889102066; Thu, 9 Mar 2023 14:14:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1678367676; 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=5352; bh=f25PlUphD6PgF3JNfVC6jEE7m1STYPoE/OnzHRPurJM=; b=p/kn6ktRF7o1tDNUjGFe9lFtwNXOPKWKV4WfcUpc9ny6SC1nAeORBs0Ln8CYQlBC r1QvMnVL1SN/0t7Uo9e0XGs+2hkjJZMxqLaWk5mchulXnnn/1HYOlW/wEuyWuhv06cK nlI3IeFVuaksTILhU9Ccp1nb8bVtOoMltEHoL3KEepe2FHAKis/Xho5begitRPP9jkQ mf+4HsqfRztx9DkCoCi3MClnz1Pz1r2idMpOfs0xLEvQ5VvZRHQYhBwHK4a8iTGhvnB FFugxVHmP47ng7uG9MT+sU/HaC4IGiTFUmyP1mrGHWpMehD8frBsTvCEJQCshe1MZRi LbW3NDV2SQ== Received: by smtp.mailfence.com with ESMTPSA ; Thu, 9 Mar 2023 14:14:34 +0100 (CET) From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Thu, 9 Mar 2023 14:14:19 +0100 Message-Id: <20230309131419.29157-1-a@unstable.cc> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309123737.12358-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-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: 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_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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 X-Headers-End: 1paG6V-0000E7-JZ Subject: [Openvpn-devel] [PATCH v3] 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?1759896144764513249?= 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 Acked-By: Arne Schwabe --- 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 Changes from v2: * fix style of type returned by dco_version_string() (uncrustify doesn't work anymore on my box..due to incompatibler config) --- 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..9f3531d5 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);