From patchwork Thu Jun 27 11:39:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 55499 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18AA91B9CD; Thu, 27 Jun 2019 13:39:49 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 62C391B99A for ; Thu, 27 Jun 2019 13:39:39 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 04:39:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,423,1557212400"; d="scan'208";a="245785866" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.125]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2019 04:39:37 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Bruce Richardson , david.marchand@redhat.com, thomas@monjalon.net, stephen@networkplumber.org Date: Thu, 27 Jun 2019 12:39:09 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 14/14] eal: prevent different primary/secondary process versions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, nothing stops DPDK to attempt to run primary and secondary processes while having different versions. This can lead to all sorts of weird behavior and makes it harder to maintain compatibility without breaking ABI every once in a while. Fix it by explicitly disallowing running different DPDK versions as primary and secondary processes. Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_mcfg.c | 15 +++++++++++++++ lib/librte_eal/common/eal_memcfg.h | 6 ++++++ lib/librte_eal/freebsd/eal/eal.c | 5 ++++- lib/librte_eal/linux/eal/eal.c | 5 ++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c index fe8d2b726..1825d9083 100644 --- a/lib/librte_eal/common/eal_common_mcfg.c +++ b/lib/librte_eal/common/eal_common_mcfg.c @@ -4,6 +4,7 @@ #include #include +#include #include "eal_internal_cfg.h" #include "eal_memcfg.h" @@ -31,6 +32,18 @@ eal_mcfg_wait_complete(void) rte_pause(); } +int +eal_mcfg_check_version(void) +{ + struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; + + /* check if version from memconfig matches compiled in macro */ + if (mcfg->version != RTE_VERSION) + return -1; + + return 0; +} + void eal_mcfg_update_internal(void) { @@ -47,6 +60,8 @@ eal_mcfg_update_from_internal(void) mcfg->legacy_mem = internal_config.legacy_mem; mcfg->single_file_segments = internal_config.single_file_segments; + /* record current DPDK version */ + mcfg->version = RTE_VERSION; } void diff --git a/lib/librte_eal/common/eal_memcfg.h b/lib/librte_eal/common/eal_memcfg.h index d02ac1621..a3d4b7fd1 100644 --- a/lib/librte_eal/common/eal_memcfg.h +++ b/lib/librte_eal/common/eal_memcfg.h @@ -21,6 +21,8 @@ */ struct rte_mem_config { volatile uint32_t magic; /**< Magic number - Sanity check. */ + uint32_t version; + /**< Prevent secondary processes using different DPDK versions. */ /* memory topology */ uint32_t nchannel; /**< Number of channels (0 if unknown). */ @@ -80,6 +82,10 @@ eal_mcfg_update_from_internal(void); void eal_mcfg_wait_complete(void); +/* check if DPDK version of current process matches one stored in the config */ +int +eal_mcfg_check_version(void); + /* set mem config as complete */ void eal_mcfg_complete(void); diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c index 6bfe203fd..e2039927c 100644 --- a/lib/librte_eal/freebsd/eal/eal.c +++ b/lib/librte_eal/freebsd/eal/eal.c @@ -385,6 +385,10 @@ rte_config_init(void) if (rte_eal_config_attach() < 0) return -1; eal_mcfg_wait_complete(); + if (eal_mcfg_check_version() < 0) { + RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n"); + return -1; + } if (rte_eal_config_reattach() < 0) return -1; eal_mcfg_update_from_internal(); @@ -395,7 +399,6 @@ rte_config_init(void) rte_config.process_type); return -1; } - return 0; } diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index fa205fd29..5421e934e 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -488,6 +488,10 @@ rte_config_init(void) if (rte_eal_config_attach() < 0) return -1; eal_mcfg_wait_complete(); + if (eal_mcfg_check_version() < 0) { + RTE_LOG(ERR, EAL, "Primary and secondary process DPDK version mismatch\n"); + return -1; + } if (rte_eal_config_reattach() < 0) return -1; eal_mcfg_update_internal(); @@ -498,7 +502,6 @@ rte_config_init(void) rte_config.process_type); return -1; } - return 0; }