netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Socket error queue with timestamping and SOF_TIMESTAMPING_OPT_CMSG
@ 2018-04-03 15:19 Miroslav Lichvar
  2018-04-03 15:51 ` Soheil Hassas Yeganeh
  0 siblings, 1 reply; 2+ messages in thread
From: Miroslav Lichvar @ 2018-04-03 15:19 UTC (permalink / raw)
  To: netdev
  Cc: Willem de Bruijn, Soheil Hassas Yeganeh, Richard Cochran,
	Keller, Jacob E

I came across an interesting issue with error messages in sockets with
enabled timestamping using the SOF_TIMESTAMPING_OPT_CMSG option. When
the socket is connected and there is an error (e.g. due to destination
unreachable ICMP), select() indicates there is an exception on the
socket, but recvmsg() reading from the error queue returns with EAGAIN
and the application gets stuck in an infinite loop.

Some observations:
- it happens on both AF_INET and AF_INET6 SOCK_DGRAM sockets
- enabling the IP_RECVERR option avoids getting EAGAIN
- using recvmmsg() instead of recvmsg() avoids getting EAGAIN
  (that is why I didn't notice it earlier)
- disabling TX timestamping doesn't prevent the socket from having an
  exception
- reading from the non-error queue stops the loop

Is this a bug?

It looks to me like SOF_TIMESTAMPING_OPT_CMSG implicitly, but only
partially, enables IP_RECVERR. Are applications required to use
IP_RECVERR in this case? My expectation was that without IP_RECVERR
the error queue would only have messages with transmit timestamps, and
nothing would change with reporting of real errors. Also, from the
documentation I had an impression that SOF_TIMESTAMPING_OPT_CMSG is a
no-op on AF_INET6 sockets.

-- 
Miroslav Lichvar

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

end of thread, other threads:[~2018-04-03 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 15:19 Socket error queue with timestamping and SOF_TIMESTAMPING_OPT_CMSG Miroslav Lichvar
2018-04-03 15:51 ` Soheil Hassas Yeganeh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).