I am exercising Linux timestamping capabilities (TX timestamps in particular).
Everything is working fine, I just cannot understand why reading from MSG_ERRQUEUE has to give me two ancillary messages: SO_TIMESTAMPING & IP_RECVERR.
That's perfectly aligned with kernel documentation: https://docs.kernel.org/networking/timestamping.html
2.1.1 Transmit timestamps with MSG_ERRQUEUE. For transmit timestamps the outgoing packet is looped back to the socket’s error queue with the send timestamp(s) attached. A process receives the timestamps by calling recvmsg() with flag MSG_ERRQUEUE set and with a msg_control buffer sufficiently large to receive the relevant metadata structures. The recvmsg call returns the original outgoing data packet with two ancillary messages attached.
I cannot imagine how I am supposed to use IP_RECVERR message as without it I can still read SO_TIMESTAMPING ancillary data.
Does anyone have an idea?
Having spend some time with documentation and paying with all available options I can answer this question.
I need to parse IP_RECVERR control message (which is sock_extended_err) because ee_info field identifies timestamp time which follows in SO_TIMESTAMPING ctrl message. It can be: SCM_TSTAMP_SND, SCM_TSTAMP_SCHED or SCM_TSTAMP_ACK depending on setting SOF_TIMESTAMPING_TX_SOFTWARE, SOF_TIMESTAMPING_TX_SCHED and SOF_TIMESTAMPING_TX_ACK.
Initially I was confused because old kernel version (e.g. 3.10) uses sock_extended_err but it does not support anything except SOF_TIMESTAMPING_TX_SOFTWARE for TX timestamps.