mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:45:07 -05:00
clientlog: separate NTP timestamps from IP addresses
Instead of keeping one pair of RX and TX timestamp for each address, add a separate RX->TX map using an ordered circular buffer. Save the RX timestamps as 64-bit integers and search them with a combined linear interpolation and binary algorithm. This enables the server to support multiple interleaved clients sharing the same IP address (e.g. NAT) and it will allow other improvements to be implemented later. A drawback is that a single broken client sending interleaved requests at a high rate (without spoofing the source address) can now prevent clients on other addresses from getting interleaved responses. The total number of saved timestamps does not change. It's still determined by the clientloglimit directive. A new option may be added later if needed. The whole buffer is allocated at once, but only on first use to not waste memory on client-only configurations.
This commit is contained in:
@@ -43,9 +43,14 @@ extern int CLG_GetClientIndex(IPAddr *client);
|
||||
extern int CLG_LogServiceAccess(CLG_Service service, IPAddr *client, struct timespec *now);
|
||||
extern int CLG_LimitServiceRate(CLG_Service service, int index);
|
||||
extern void CLG_LogAuthNtpRequest(void);
|
||||
extern void CLG_GetNtpTimestamps(int index, NTP_int64 **rx_ts, NTP_int64 **tx_ts);
|
||||
extern int CLG_GetNtpMinPoll(void);
|
||||
|
||||
/* Functions to save and retrieve timestamps for server interleaved mode */
|
||||
extern void CLG_SaveNtpTimestamps(NTP_int64 *rx_ts, struct timespec *tx_ts);
|
||||
extern void CLG_UpdateNtpTxTimestamp(NTP_int64 *rx_ts, struct timespec *tx_ts);
|
||||
extern int CLG_GetNtpTxTimestamp(NTP_int64 *rx_ts, struct timespec *tx_ts);
|
||||
extern void CLG_DisableNtpTimestamps(NTP_int64 *rx_ts);
|
||||
|
||||
/* And some reporting functions, for use by chronyc. */
|
||||
|
||||
extern int CLG_GetNumberOfIndices(void);
|
||||
|
||||
Reference in New Issue
Block a user