liburing icon indicating copy to clipboard operation
liburing copied to clipboard

recvmsg returns EINVAL when trying to retrieve control message

Open fabxc opened this issue 2 years ago • 4 comments

I am trying to use io_uring_prep_recvmsg. I set up the struct msghdr correctly but always get an EINVAL return code.

Excerpt from my setup:

      ctx->iov.iov_base = reinterpret_cast<char*>(buf.data()),
      ctx->iov.iov_len = buf.size();

      memset(ctx->cmsg, 0, sizeof(ctx->cmsg));
      ctx->msg.msg_control = ctx->cmsg;
      ctx->msg.msg_controllen = sizeof(ctx->cmsg);
      ctx->msg.msg_iov = &ctx->iov;
      ctx->msg.msg_iovlen = 1;
      io_uring_prep_recvmsg(sqe, fd, &ctx->msg, 0);

If I replace the last line with a plain recvmsg call it works as expected. If I leave msg_control and msg_controllen unset, it also works with io_uring_prep_recvmsg.

My kernel version is 5.4. Are there any known limitations around this?

fabxc avatar Aug 09 '23 16:08 fabxc

cmsg is not supported in older kernels, it'll work in newer ones.

axboe avatar Aug 09 '23 16:08 axboe

Slightly related, is the support in 5.4 missing sockets completely? readv/writev return EINVAL with 5.4 too.

alkis avatar Aug 24 '23 13:08 alkis

Slightly related, is the support in 5.4 missing sockets completely? readv/writev return EINVAL with 5.4 too.

No, it should work, I think, at least I don't remember any restriction like that

isilence avatar Aug 29 '23 13:08 isilence

Slightly related, is the support in 5.4 missing sockets completely? readv/writev return EINVAL with 5.4 too.

No, it should work, I think, at least I don't remember any restriction like that

Verified that it does work.

alkis avatar Sep 28 '23 07:09 alkis