From: Anatoly Burakov Date: Fri, 5 Jul 2019 17:26:27 +0000 (+0100) Subject: eal: prevent different primary/secondary process versions X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ae3b4bc4fb9ca179eac5c4c9b51b4853b3afe7c7;p=dpdk.git eal: prevent different primary/secondary process versions 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 Acked-by: David Marchand --- diff --git a/lib/librte_eal/common/eal_common_mcfg.c b/lib/librte_eal/common/eal_common_mcfg.c index fe8d2b7268..1825d90838 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 573233896e..030f903adc 100644 --- a/lib/librte_eal/common/eal_memcfg.h +++ b/lib/librte_eal/common/eal_memcfg.h @@ -19,6 +19,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). */ @@ -81,6 +83,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 3bd1a04f73..13ca1202cb 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_internal(); diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c index f7cb90a41b..2e5499f9b4 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -489,6 +489,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();