jonhoo / rust-ibverbs

Bindings for RDMA ibverbs through rdma-core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[RFC] GUID byte-order

planetA opened this issue · comments

Hello,

ibv_get_device_guid returns GUID in "network byte order" [1], which means big endian.

On another hand, the Rust counterpart returns u64, which I expect to be in the host byte order, which is little endian on my system. I would suggest to convert the result of the C version into host order. What would be your thoughts?

  1. https://linux.die.net/man/3/ibv_get_device_guid

Ah, good catch! I think we should do the same thing that we ended up doing for Gid in #7. See the code there to handle the endianness. Would you be willing to submit a PR along those lines?

Hi, I created a pull request, which unfortunately does not work yet.

I tried to make a __be64 type as a tuple, so that it will not be convertible from u64 automatically. Unfortunately, it breaks ibv_gid type with the following error message

warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
   --> src/lib.rs:895:27
    |
895 |             raw: unsafe { gid.raw },
    |                           ^^^^^^^ expected array `[u8; 16]`, found struct `__BindgenUnionField`
    |
    = note: expected array `[u8; 16]`
              found struct `__BindgenUnionField<[u8; 16]>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

I'm still a newbie with Rust. Could you have a look at #16 to say if I'm moving in the right direction?