From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id A25231B170 for ; Fri, 2 Feb 2018 17:46:29 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id f3so13705879wmc.1 for ; Fri, 02 Feb 2018 08:46:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zxH8bzpxaIK0E2bkyu80a7SWjhk91MWb9Coyg43BByc=; b=HbTOpHGNxkQyATlCcyjHboVr+k9oHa8Szb/B0WlF/lCPdB62lvuB8iq6Yz7d9TcB/H RazzNoZZy71agX9c+Y7fiMbj7c5wprEileFKqs3s8Kcc8+A/HjDS2/C04CqP7F4kICmB V0hRtVflXT2wHXgkll59+bgqmP5SfDjcSBKU0ptO3WhL1LOUUE6HeLXULt5LrD+Iju3/ Lp2VrnsJkqSmJzmWqm4JGAv8xhSdG3VQ22eEkagJaFeKOdMsNEeIsuNVi6JNX+tNWety f82U6NOOIWd+droLcPUMJGIeeiTLcAADNxKt87lbEWnrVjGbQKcOarf/B6TvRvfIAXrR b9Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zxH8bzpxaIK0E2bkyu80a7SWjhk91MWb9Coyg43BByc=; b=gVD62NoHZFAV8phszF0f0F227hDi+6Rn6gv0UOnP9Z8lTP3ufCxP3BoS3shVdmvU6L C9qVpg39J+aXf4i4/cwUB2OlmFmkYIhVbIiWNKFk869M/YKt5m+FmDL+bVL4S44hVmvR WCykEf7aw/WXQyRzmqosUPt2Kmn7SKJaQ3mthTK2lia61EUJib+yq+6v5ZCw340gCI19 9ajJCQBAxjh8mD2szfVMicHtdiZREZZeKSh07KJY9LjGtDQce0D7XDFyAp2sks9SPUJF u87Ly3Ho9UIQbGQdVH15YeYruZzoWc15ZPoyU1ipA8Lze6rxe8xfXFL+5uUbyaFKzbTb zo1Q== X-Gm-Message-State: APf1xPC4pgpal2bUi2wS4asUdt6CXnHfgfiya0AilJIZyxXkqFn8j4Ct KkLEWUiAGgfAn62iqKudf4YyTw== X-Google-Smtp-Source: AH8x2276GYrmtWl9od9yKSaNQmg2/KxYgalTBJCCwlv4YHX1qlU0/V28JnKbKMHfNjCfP3M5S7Wq1w== X-Received: by 10.28.225.133 with SMTP id y127mr400339wmg.55.1517589989142; Fri, 02 Feb 2018 08:46:29 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c49sm4644354wrc.48.2018.02.02.08.46.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 08:46:28 -0800 (PST) Date: Fri, 2 Feb 2018 17:46:16 +0100 From: Adrien Mazarguil To: Shahaf Shuler Cc: Nelio Laranjeiro , dev@dpdk.org, Marcelo Ricardo Leitner Message-ID: <20180202164050.13017-4-adrien.mazarguil@6wind.com> References: <20180202144736.8239-1-adrien.mazarguil@6wind.com> <20180202164050.13017-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180202164050.13017-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v2 3/4] net/mlx: version rdma-core glue libraries 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: , X-List-Received-Date: Fri, 02 Feb 2018 16:46:29 -0000 When built as separate objects, these libraries do not have unique names. Since they do not maintain a stable ABI, loading an incompatible library may result in a crash (e.g. in case multiple versions are installed). This patch addresses the above by versioning glue libraries, both on the file system (version suffix) and by comparing a dedicated version field member in glue structures. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/Makefile | 8 ++++++-- drivers/net/mlx4/mlx4.c | 5 +++++ drivers/net/mlx4/mlx4_glue.c | 1 + drivers/net/mlx4/mlx4_glue.h | 6 ++++++ drivers/net/mlx5/Makefile | 8 ++++++-- drivers/net/mlx5/mlx5.c | 5 +++++ drivers/net/mlx5/mlx5_glue.c | 1 + drivers/net/mlx5/mlx5_glue.h | 6 ++++++ 8 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile index c004ac71c..cc9db9977 100644 --- a/drivers/net/mlx4/Makefile +++ b/drivers/net/mlx4/Makefile @@ -33,7 +33,9 @@ include $(RTE_SDK)/mk/rte.vars.mk # Library name. LIB = librte_pmd_mlx4.a -LIB_GLUE = librte_pmd_mlx4_glue.so +LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION) +LIB_GLUE_BASE = librte_pmd_mlx4_glue.so +LIB_GLUE_VERSION = 18.02.1 # Sources. SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c @@ -64,6 +66,7 @@ CFLAGS += -D_XOPEN_SOURCE=600 CFLAGS += $(WERROR_FLAGS) ifeq ($(CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS),y) CFLAGS += -DMLX4_GLUE='"$(LIB_GLUE)"' +CFLAGS += -DMLX4_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' CFLAGS_mlx4_glue.o += -fPIC LDLIBS += -ldl else @@ -131,6 +134,7 @@ $(LIB): $(LIB_GLUE) $(LIB_GLUE): mlx4_glue.o $Q $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) \ + -Wl,-h,$(LIB_GLUE) \ -s -shared -o $@ $< -libverbs -lmlx4 mlx4_glue.o: mlx4_autoconf.h @@ -139,6 +143,6 @@ endif clean_mlx4: FORCE $Q rm -f -- mlx4_autoconf.h mlx4_autoconf.h.new - $Q rm -f -- mlx4_glue.o $(LIB_GLUE) + $Q rm -f -- mlx4_glue.o $(LIB_GLUE_BASE)* clean: clean_mlx4 diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 201d39b6e..61a852fb9 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -808,6 +808,11 @@ rte_mlx4_pmd_init(void) assert(((const void *const *)mlx4_glue)[i]); } #endif + if (strcmp(mlx4_glue->version, MLX4_GLUE_VERSION)) { + ERROR("rdma-core glue \"%s\" mismatch: \"%s\" is required", + mlx4_glue->version, MLX4_GLUE_VERSION); + return; + } mlx4_glue->fork_init(); rte_pci_register(&mlx4_driver); } diff --git a/drivers/net/mlx4/mlx4_glue.c b/drivers/net/mlx4/mlx4_glue.c index 47ae7ad0f..3b79d320e 100644 --- a/drivers/net/mlx4/mlx4_glue.c +++ b/drivers/net/mlx4/mlx4_glue.c @@ -240,6 +240,7 @@ mlx4_glue_dv_set_context_attr(struct ibv_context *context, } const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){ + .version = MLX4_GLUE_VERSION, .fork_init = mlx4_glue_fork_init, .get_async_event = mlx4_glue_get_async_event, .ack_async_event = mlx4_glue_ack_async_event, diff --git a/drivers/net/mlx4/mlx4_glue.h b/drivers/net/mlx4/mlx4_glue.h index de251c622..368f906bf 100644 --- a/drivers/net/mlx4/mlx4_glue.h +++ b/drivers/net/mlx4/mlx4_glue.h @@ -19,7 +19,13 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#ifndef MLX4_GLUE_VERSION +#define MLX4_GLUE_VERSION "" +#endif + +/* LIB_GLUE_VERSION must be updated every time this structure is modified. */ struct mlx4_glue { + const char *version; int (*fork_init)(void); int (*get_async_event)(struct ibv_context *context, struct ibv_async_event *event); diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 4b20d718b..4086f2039 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -33,7 +33,9 @@ include $(RTE_SDK)/mk/rte.vars.mk # Library name. LIB = librte_pmd_mlx5.a -LIB_GLUE = librte_pmd_mlx5_glue.so +LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION) +LIB_GLUE_BASE = librte_pmd_mlx5_glue.so +LIB_GLUE_VERSION = 18.02.1 # Sources. SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5.c @@ -74,6 +76,7 @@ CFLAGS += $(WERROR_FLAGS) CFLAGS += -Wno-strict-prototypes ifeq ($(CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS),y) CFLAGS += -DMLX5_GLUE='"$(LIB_GLUE)"' +CFLAGS += -DMLX5_GLUE_VERSION='"$(LIB_GLUE_VERSION)"' CFLAGS_mlx5_glue.o += -fPIC LDLIBS += -ldl else @@ -180,6 +183,7 @@ $(LIB): $(LIB_GLUE) $(LIB_GLUE): mlx5_glue.o $Q $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) \ + -Wl,-h,$(LIB_GLUE) \ -s -shared -o $@ $< -libverbs -lmlx5 mlx5_glue.o: mlx5_autoconf.h @@ -188,6 +192,6 @@ endif clean_mlx5: FORCE $Q rm -f -- mlx5_autoconf.h mlx5_autoconf.h.new - $Q rm -f -- mlx5_glue.o $(LIB_GLUE) + $Q rm -f -- mlx5_glue.o $(LIB_GLUE_BASE)* clean: clean_mlx5 diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 050cfac0d..341230d2b 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1151,6 +1151,11 @@ rte_mlx5_pmd_init(void) assert(((const void *const *)mlx5_glue)[i]); } #endif + if (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) { + ERROR("rdma-core glue \"%s\" mismatch: \"%s\" is required", + mlx5_glue->version, MLX5_GLUE_VERSION); + return; + } mlx5_glue->fork_init(); rte_pci_register(&mlx5_driver); } diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c index 8f500be6e..1c4396ada 100644 --- a/drivers/net/mlx5/mlx5_glue.c +++ b/drivers/net/mlx5/mlx5_glue.c @@ -308,6 +308,7 @@ mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type) } const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ + .version = MLX5_GLUE_VERSION, .fork_init = mlx5_glue_fork_init, .alloc_pd = mlx5_glue_alloc_pd, .dealloc_pd = mlx5_glue_dealloc_pd, diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h index 7fed302ba..b5efee3b6 100644 --- a/drivers/net/mlx5/mlx5_glue.h +++ b/drivers/net/mlx5/mlx5_glue.h @@ -19,6 +19,10 @@ #pragma GCC diagnostic error "-Wpedantic" #endif +#ifndef MLX5_GLUE_VERSION +#define MLX5_GLUE_VERSION "" +#endif + #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT struct ibv_counter_set; struct ibv_counter_set_data; @@ -27,7 +31,9 @@ struct ibv_counter_set_init_attr; struct ibv_query_counter_set_attr; #endif +/* LIB_GLUE_VERSION must be updated every time this structure is modified. */ struct mlx5_glue { + const char *version; int (*fork_init)(void); struct ibv_pd *(*alloc_pd)(struct ibv_context *context); int (*dealloc_pd)(struct ibv_pd *pd); -- 2.11.0