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