Re: [PATCH 1/7] libibverbs: Add link layer field port attribute

Or Gerlitz
2011-07-20T18:08:26Z

Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:

> The commit comment states the goal is to have new apps see
> IBV_LINK_LAYER_UNSPECIFIED for all possible combinations of old stuff underneath.
> [...] The problem is with the userspace ABI out of libibverbs. Current
> libibverbs does not zero its ib_port_attr structure before returning.

> Build this with Or's patch applied, then run it against libibverbs 1.1.5
>  struct ibv_port_attr attr;
>  attr.link_layer = 100;
>  ibv_query_port(..,&attr);
>  assert(attr.link_layer == IBV_LINK_LAYER_UNSPECIFIED); // Fails!

impossible, see below why

> That is an ABI breaking issue that is not dealt with by Or's patch - couple choices:
>  1) Require and document callers using ibv_query_port to zero attr
>    before hand when using link_layer
>  2) Crank the symbol version on ibv_query_port so dynamic linking fails
>  3) Inline the memset in ibverbs.h:

YES, #3 is what the patch does, and it follows your suggestion!!

+static inline int ___ibv_query_port(struct ibv_context *context,
+ uint8_t port_num,
+ struct ibv_port_attr *port_attr)
+{
+ port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED;
+ port_attr->pad = 0;
+
+ return context->ops.query_port(context, port_num, port_attr);
+}
+

+#define ibv_query_port(context, port_num, port_attr) \
+ ___ibv_query_port(context, port_num, port_attr)
+

So we are okay now, correct?

Or.