Skip to content

Commit

Permalink
libibverbs: Fix ABI_placeholder1 and ABI_placeholder2 assignment
Browse files Browse the repository at this point in the history
[ Upstream commit 88789b7 ]

The assignment of ABI_placeholder1 and ABI_placeholder2 must be
after the provider populated context_ex->ibv_create_flow and
context_ex->ibv_destroy_flow.

Applications, which compiled against old libibverbs released between
commit 501b53b and 1111cf9, will fail if they are linked
with libibverbs released after 1111cf9 and call ibv_create_flow.

[1] 501b53b ("Fix create/destroy flow API")

Fixes: 1111cf9 ("verbs: Always allocate a verbs_context")
Signed-off-by: Honggang Li <honli@redhat.com>
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
  • Loading branch information
Honggang-LI authored and nmorey committed Jun 9, 2020
1 parent 4f926f1 commit 6c7a6d4
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions libibverbs/device.c
Expand Up @@ -216,23 +216,6 @@ int verbs_init_context(struct verbs_context *context_ex,
context_ex->context.abi_compat = __VERBS_ABI_IS_EXTENDED;
context_ex->sz = sizeof(*context_ex);

/*
* In order to maintain backward/forward binary compatibility
* with apps compiled against libibverbs-1.1.8 that use the
* flow steering addition, we need to set the two
* ABI_placeholder entries to match the driver set flow
* entries. This is because apps compiled against
* libibverbs-1.1.8 use an inline ibv_create_flow and
* ibv_destroy_flow function that looks in the placeholder
* spots for the proper entry points. For apps compiled
* against libibverbs-1.1.9 and later, the inline functions
* will be looking in the right place.
*/
context_ex->ABI_placeholder1 =
(void (*)(void))context_ex->ibv_create_flow;
context_ex->ABI_placeholder2 =
(void (*)(void))context_ex->ibv_destroy_flow;

context_ex->priv = calloc(1, sizeof(*context_ex->priv));
if (!context_ex->priv) {
errno = ENOMEM;
Expand Down Expand Up @@ -313,6 +296,23 @@ LATEST_SYMVER_FUNC(ibv_open_device, 1_1, "IBVERBS_1.1",
context_ex->create_cq_ex = __lib_ibv_create_cq_ex;
}

/*
* In order to maintain backward/forward binary compatibility
* with apps compiled against libibverbs-1.1.8 that use the
* flow steering addition, we need to set the two
* ABI_placeholder entries to match the driver set flow
* entries. This is because apps compiled against
* libibverbs-1.1.8 use an inline ibv_create_flow and
* ibv_destroy_flow function that looks in the placeholder
* spots for the proper entry points. For apps compiled
* against libibverbs-1.1.9 and later, the inline functions
* will be looking in the right place.
*/
context_ex->ABI_placeholder1 =
(void (*)(void))context_ex->ibv_create_flow;
context_ex->ABI_placeholder2 =
(void (*)(void))context_ex->ibv_destroy_flow;

return &context_ex->context;
}

Expand Down

0 comments on commit 6c7a6d4

Please sign in to comment.