All of lore.kernel.org
 help / color / mirror / Atom feed
* recvmmsg() behaviour with MSG_PEEK flag
@ 2022-07-15 11:03 Alexander Babayants
  2022-07-15 11:21 ` Eric Dumazet
  2022-07-15 14:23 ` Jann Horn
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Babayants @ 2022-07-15 11:03 UTC (permalink / raw)
  To: linux-api; +Cc: davem, edumazet, kuba, pabeni, mtk.manpages

Hello!

The behaviour of recvmmsg() with MSG_PEEK flag confuses me. I'd expect
it to peek multiple messages at once, but it seems to peek only the
first one, filling each of the provided struct msghdr with a copy of
the first message. I do not see if it is documented anywhere, is it a
bug or intended design?

What I want to achieve is to first peek into the socket, get the size
of each message, then allocate appropriate buffers and read the
messages with the second recvmmsg() call. This seems to be a
relatively common pattern for reading single messages via recvmsg(),
and I naively expected it to work with recvmmsg() too.

-- 
Regards,
Alexander Babayants.

^ permalink raw reply	[flat|nested] 5+ messages in thread
* recvmmsg() behaviour with MSG_PEEK flag
@ 2022-07-14 22:11 Alexander Babayants
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Babayants @ 2022-07-14 22:11 UTC (permalink / raw)
  To: netdev

(sorry in advance - I'm not sure it is the right mailing list for the
question, if it is not, feel free to redirect me)

The behaviour of recvmmsg() with MSG_PEEK flag confuses me. I'd expect
it to peek multiple messages at once, but it seems to peek only the
first one, filling each of the provided struct msghdr with a copy of
the first message. I do not see if it is documented anywhere, is it a
bug or intended design?

What I want to achieve is to first peek into the socket, get the size
of each message, then allocate appropriate buffers and read the
messages with the second recvmmsg() call. This seems to be a
relatively common pattern for reading single messages via recvmsg(),
and I naively expected it to work with recvmmsg() too.

-- 
Regards,
Alexander Babayants.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-15 14:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 11:03 recvmmsg() behaviour with MSG_PEEK flag Alexander Babayants
2022-07-15 11:21 ` Eric Dumazet
2022-07-15 12:17   ` Alexander Babayants
2022-07-15 14:23 ` Jann Horn
  -- strict thread matches above, loose matches on Subject: below --
2022-07-14 22:11 Alexander Babayants

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.