mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-01-20 12:50:19 -05:00
socket: add support for Linux timestamping transmit IDs
Add a new field to the SCK_Message structure to enable setting and getting of the Linux timestamping transmit IDs enabled by the SOF_TIMESTAMPING_OPT_ID socket option. The ID can be set for each packet individually by the SCM_TS_OPT_ID control message (supported on Linux 6.13 and newer). This will allow procesing of transmit timestamps without extracting data from the data-link frames.
This commit is contained in:
16
socket.c
16
socket.c
@@ -850,6 +850,7 @@ init_message_nonaddress(SCK_Message *message)
|
||||
message->timestamp.if_index = INVALID_IF_INDEX;
|
||||
message->timestamp.l2_length = 0;
|
||||
message->timestamp.tx_flags = 0;
|
||||
message->timestamp.tx_id = 0;
|
||||
|
||||
message->descriptor = INVALID_SOCK_FD;
|
||||
}
|
||||
@@ -1020,6 +1021,8 @@ process_header(struct msghdr *msg, int msg_length, int sock_fd, int flags,
|
||||
log_message(sock_fd, 1, message, "Unexpected extended error in", NULL);
|
||||
r = 0;
|
||||
}
|
||||
|
||||
message->timestamp.tx_id = err.ee_data;
|
||||
}
|
||||
#endif
|
||||
else if (match_cmsg(cmsg, SOL_SOCKET, SCM_RIGHTS, 0)) {
|
||||
@@ -1251,6 +1254,19 @@ send_message(int sock_fd, SCK_Message *message, int flags)
|
||||
|
||||
*ts_tx_flags = message->timestamp.tx_flags;
|
||||
}
|
||||
|
||||
#ifdef SCM_TS_OPT_ID
|
||||
if (message->timestamp.tx_id != 0) {
|
||||
uint32_t *tx_id;
|
||||
|
||||
tx_id = add_control_message(&msg, SOL_SOCKET, SCM_TS_OPT_ID,
|
||||
sizeof (*tx_id), sizeof (cmsg_buf));
|
||||
if (!tx_id)
|
||||
return 0;
|
||||
|
||||
*tx_id = message->timestamp.tx_id;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (flags & SCK_FLAG_MSG_DESCRIPTOR) {
|
||||
|
||||
Reference in New Issue
Block a user