From patchwork Wed Jan 27 09:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Cox X-Patchwork-Id: 1582 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id sCQNKLHLEWCpXgAAIUCqbw (envelope-from ) for ; Wed, 27 Jan 2021 15:23:13 -0500 Received: from proxy15.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id SJ3ZJ7HLEWBcDQAA91zNiA (envelope-from ) for ; Wed, 27 Jan 2021 15:23:13 -0500 Received: from smtp21.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy15.mail.ord1d.rsapps.net with LMTPS id YN2kJ7HLEWCqeQAAAY1PeQ (envelope-from ) for ; Wed, 27 Jan 2021 15:23:13 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp21.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=mozilla.com X-Suspicious-Flag: YES X-Classification-ID: 7a3b3e72-60dd-11eb-afa9-525400a98691-1-1 Received: from [216.105.38.7] ([216.105.38.7:33946] helo=lists.sourceforge.net) by smtp21.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id EB/35-25869-0BBC1106; Wed, 27 Jan 2021 15:23:12 -0500 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.90_1) (envelope-from ) id 1l4rKP-0000Be-Ur; Wed, 27 Jan 2021 20:22:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4rKO-0000BW-HM for openvpn-devel@lists.sourceforge.net; Wed, 27 Jan 2021 20:22:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=23VkI0esfBmvQKjDoNyHmb6j+acM5dWboic8dinNIms=; b=fkRG8C4u8WodGQvhtczUaMDqho I64HnpNaj1E2I12QMNeB1Ox18PTj+8s8nM7bbyEwvOtMfnZQgWE+F4SDq3RaLKtiuo5SVwqE49lTd 2+h5iTeKJUUXFz2n2oJLh+eknG+lj3j1aBryysCEDcgliXRtP6sGwycyvguu+H23eow8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=23VkI0esfBmvQKjDoNyHmb6j+acM5dWboic8dinNIms=; b=HSfq4CBhxZGwt57Mr7IQayv0cr 8Xl7mfVqHoSxHHxMZvgYvEqGEKqnfB3Y7/KCGwwSMTXOela++tfUt+qTN7VDtRdYPKgkL4SCnz54r JVTmyiw3IH0dtR91KomvDS+kXmeh3H7wcpF+9dXKT/s6nFLWwKB0Yj+p5HTv/gmgi6iw=; Received: from smtp1.mdc1.mozilla.com ([63.245.208.103] helo=smtp.mozilla.org) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1l4rKH-00BlTj-U0 for openvpn-devel@lists.sourceforge.net; Wed, 27 Jan 2021 20:22:12 +0000 Received: from localhost (localhost4.localdomain [127.0.0.1]) by smtp1.mail.mdc1.mozilla.com (Postfix) with ESMTP id E79AC9A333; Wed, 27 Jan 2021 20:21:59 +0000 (UTC) Received: from smtp.mozilla.org ([127.0.0.1]) by localhost (smtp1.mail.mdc1.mozilla.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1zYuA6Sf3vPW; Wed, 27 Jan 2021 20:21:59 +0000 (UTC) Received: from centos7-rpmbuild1.private.mdc1.mozilla.com (centos7-rpmbuild1.private.mdc1.mozilla.com [10.48.75.35]) by smtp1.mail.mdc1.mozilla.com (Postfix) with ESMTPS id C6DDC9A2EE; Wed, 27 Jan 2021 20:21:59 +0000 (UTC) From: Greg Cox To: openvpn-devel@lists.sourceforge.net Date: Wed, 27 Jan 2021 20:21:48 +0000 Message-Id: <1611778909-20630-1-git-send-email-gcox@mozilla.com> X-Mailer: git-send-email 2.7.6 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1l4rKH-00BlTj-U0 Subject: [Openvpn-devel] [PATCH 1/2] Update openvpn_plugin_func_v2 to _v3 in sample-plugins/defer/simple.c 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This isn't strictly required, but it modernizes the functions used. This change makes _open the same parameter form as _func (for better parallelism in function writing) and includes a check for the correct struct version, as recommended by openvpn-plugin.h Acked-By: David Sommerseth --- sample/sample-plugins/defer/simple.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sample/sample-plugins/defer/simple.c b/sample/sample-plugins/defer/simple.c index 22bc22765d6773d3ea2344a328faf5008b0c5d89..a2e47cfc3953ae188a5a2588a3d21e12404c75f1 100644 --- a/sample/sample-plugins/defer/simple.c +++ b/sample/sample-plugins/defer/simple.c @@ -423,16 +423,21 @@ tls_final(struct plugin_context *context, struct plugin_per_client_context *pcc, } OPENVPN_EXPORT int -openvpn_plugin_func_v2(openvpn_plugin_handle_t handle, - const int type, - const char *argv[], - const char *envp[], - void *per_client_context, - struct openvpn_plugin_string_list **return_list) +openvpn_plugin_func_v3(const int v3structver, + struct openvpn_plugin_args_func_in const *args, + struct openvpn_plugin_args_func_return *ret) { - struct plugin_context *context = (struct plugin_context *) handle; - struct plugin_per_client_context *pcc = (struct plugin_per_client_context *) per_client_context; - switch (type) + /* Check API compatibility -- struct version 5 or higher needed */ + if (v3structver < 5) + { + fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE); + return OPENVPN_PLUGIN_FUNC_ERROR; + } + const char **argv = args->argv; + const char **envp = args->envp; + struct plugin_context *context = (struct plugin_context *) args->handle; + struct plugin_per_client_context *pcc = (struct plugin_per_client_context *) args->per_client_context; + switch (args->type) { case OPENVPN_PLUGIN_UP: plugin_log(PLOG_NOTE, MODULE, "OPENVPN_PLUGIN_UP"); From patchwork Wed Jan 27 09:21:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Cox X-Patchwork-Id: 1583 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id wPWRMMfLEWDHIgAAIUCqbw (envelope-from ) for ; Wed, 27 Jan 2021 15:23:35 -0500 Received: from proxy4.mail.ord1d.rsapps.net ([172.30.191.6]) by director11.mail.ord1d.rsapps.net with LMTP id +CKCMMfLEWCYMgAAvGGmqA (envelope-from ) for ; Wed, 27 Jan 2021 15:23:35 -0500 Received: from smtp19.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy4.mail.ord1d.rsapps.net with LMTPS id aP98L8fLEWAhSQAAiYrejw (envelope-from ) for ; Wed, 27 Jan 2021 15:23:35 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp19.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=fail (p=none; dis=none) header.from=mozilla.com X-Suspicious-Flag: YES X-Classification-ID: 87912046-60dd-11eb-bff9-525400d67fa8-1-1 Received: from [216.105.38.7] ([216.105.38.7:42346] helo=lists.sourceforge.net) by smtp19.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 65/3C-04193-6CBC1106; Wed, 27 Jan 2021 15:23:34 -0500 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1l4rL3-0004i6-N3; Wed, 27 Jan 2021 20:22:53 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4rL2-0004i0-Nr for openvpn-devel@lists.sourceforge.net; Wed, 27 Jan 2021 20:22:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=mMoMxxGE41Js9ron/0B5bR/5aNX5WJZXw4VzfApwUAE=; b=BjhlE2I2u4FJ1VnGP8xZabYone MjQ5qNsW80G3jhm3k9I5jpAOTde+XZjZZoaD9pvdXKTgx5rrgI5JPvZfkomi0iGpW7nNZMJx+3G0D c3KEppsfsR1f4JVbDrRd1CRhcPJDQo+TgNKS0DAUmJI+oJ52Rx+P4hiawmIM26KavdyE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=mMoMxxGE41Js9ron/0B5bR/5aNX5WJZXw4VzfApwUAE=; b=kLorQkZbO3C6QjE4NN09WzRaZM O6k6ouQfI+gS+lfCEtzf7+TRNwrNPzsALkVsvFucN4oh2sitxmrwrK7TjphrPYHqZY38Ftgp9Fib/ deI33iArQWVpSMFcZ5Oc6+MXWKztBDXJu0aq0laAemNtbdeP5aEGP2RRCQPh/QBcYKWA=; Received: from smtp1.mdc1.mozilla.com ([63.245.208.103] helo=smtp.mozilla.org) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1l4rKu-00Bljs-LG for openvpn-devel@lists.sourceforge.net; Wed, 27 Jan 2021 20:22:52 +0000 Received: from localhost (localhost4.localdomain [127.0.0.1]) by smtp1.mail.mdc1.mozilla.com (Postfix) with ESMTP id 7DA7A9A334; Wed, 27 Jan 2021 20:22:39 +0000 (UTC) Received: from smtp.mozilla.org ([127.0.0.1]) by localhost (smtp1.mail.mdc1.mozilla.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f9bC4V13DUMx; Wed, 27 Jan 2021 20:22:39 +0000 (UTC) Received: from centos7-rpmbuild1.private.mdc1.mozilla.com (centos7-rpmbuild1.private.mdc1.mozilla.com [10.48.75.35]) by smtp1.mail.mdc1.mozilla.com (Postfix) with ESMTPS id 5A64B9A333; Wed, 27 Jan 2021 20:22:39 +0000 (UTC) From: Greg Cox To: openvpn-devel@lists.sourceforge.net Date: Wed, 27 Jan 2021 20:21:49 +0000 Message-Id: <1611778909-20630-2-git-send-email-gcox@mozilla.com> X-Mailer: git-send-email 2.7.6 In-Reply-To: <1611778909-20630-1-git-send-email-gcox@mozilla.com> References: <1611778909-20630-1-git-send-email-gcox@mozilla.com> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1l4rKu-00Bljs-LG Subject: [Openvpn-devel] [PATCH 2/2] More explicit versioning compatibility in sample-plugins/defer/simple.c 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox While not required, adding openvpn_plugin_min_version_required_v1 helps by making an example for others to copy, and helps to explicitly call attention to the difference between the API version number and the struct version number in v3 calls. Acked-By: David Sommerseth --- sample/sample-plugins/defer/simple.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sample/sample-plugins/defer/simple.c b/sample/sample-plugins/defer/simple.c index a2e47cfc3953ae188a5a2588a3d21e12404c75f1..05bfc4efa6d85bb1696b6811428260f4cc5e9914 100644 --- a/sample/sample-plugins/defer/simple.c +++ b/sample/sample-plugins/defer/simple.c @@ -66,7 +66,15 @@ static plugin_log_t plugin_log = NULL; /* - * Our context, where we keep our state. + * Constants indicating minimum API and struct versions by the functions + * in this plugin. Consult openvpn-plugin.h, look for: + * OPENVPN_PLUGIN_VERSION and OPENVPN_PLUGINv3_STRUCTVER + */ +#define OPENVPN_PLUGIN_VERSION_MIN 3 +#define OPENVPN_PLUGIN_STRUCTVER_MIN 5 + +/* +* Our context, where we keep our state. */ struct plugin_context { @@ -136,6 +144,13 @@ atoi_null0(const char *str) } } +/* Require a minimum OpenVPN Plugin API */ +OPENVPN_EXPORT int +openvpn_plugin_min_version_required_v1() +{ + return OPENVPN_PLUGIN_VERSION_MIN; +} + /* use v3 functions so we can use openvpn's logging and base64 etc. */ OPENVPN_EXPORT int openvpn_plugin_open_v3(const int v3structver, @@ -146,7 +161,7 @@ openvpn_plugin_open_v3(const int v3structver, struct plugin_context *context; /* Check API compatibility -- struct version 5 or higher needed */ - if (v3structver < 5) + if (v3structver < OPENVPN_PLUGIN_STRUCTVER_MIN) { fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE); return OPENVPN_PLUGIN_FUNC_ERROR; @@ -428,7 +443,7 @@ openvpn_plugin_func_v3(const int v3structver, struct openvpn_plugin_args_func_return *ret) { /* Check API compatibility -- struct version 5 or higher needed */ - if (v3structver < 5) + if (v3structver < OPENVPN_PLUGIN_STRUCTVER_MIN) { fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE); return OPENVPN_PLUGIN_FUNC_ERROR;