Add packet timestamp support#2
Open
trondn wants to merge 2 commits into
Open
Conversation
Under OpenSSL 3.0+, unexpected socket closures before a clean SSL/TLS shutdown alert is exchanged are classified as protocol errors rather than clean EOFs. This behavior change causes various regression tests to fail. To resolve these compatibility issues: 1. bufferevent_openssl.c: Identify the SSL_R_UNEXPECTED_EOF_WHILE_READING protocol error and treat it as a dirty shutdown (clean TCP closure) to ensure backward compatibility. 2. test/regress_http.c (https_bev): Enable 'allow_dirty_shutdown = 1' on server bufferevents inside the mock HTTPS server to cleanly handle abrupt client socket closures. 3. test/regress_http.c (http_incomplete_errorcb): Recognize SSL protocol errors arising from raw socket shutdowns on OpenSSL 3.0 as successful terminations during the incomplete HTTP request test.
Implement kernel-measured socket receive timestamps with nanosecond precision on supported platforms via the recvmsg() syscall. Timestamps are stored per-chain in the evbuffer. Infrastructure changes: - evbuffer-internal.h: Add timestamp storage and validity flag to evbuffer_chain structure. - evbuffer_read_with_timestamp(): New internal function for reading data via recvmsg(), parsing control messages for timestamps, and safeguarding against MSG_CTRUNC truncation. - bufferevent-internal.h: Add recv_timestamps_enabled flag to the bufferevent_private structure. - bufferevent_sock.c: Enable receive timestamps and swap standard reads with evbuffer_read_with_timestamp() when requested. - bufferevent_openssl.c: Add a custom socket BIO to extract kernel timestamps during direct socket reads, and propagate timestamps from underlying bufferevents in filtered TLS mode. - Build system: Add CMake and Autotools socket timestamp checks for SO_TIMESTAMP and SO_TIMESTAMPNS option availability. Public API additions: - BEV_OPT_RECV_TIMESTAMPS option flag for socket bufferevents. - evbuffer_get_timestamp() to fetch the receipt timestamp of the oldest data currently in the buffer. - evbuffer_commit_space_with_timespec() to commit reserved space and manually attach a timestamp to the committed chains. Platform support: - Linux 2.6.22+: Nanosecond (SO_TIMESTAMPNS) and microsecond (SO_TIMESTAMP) precision. - macOS 10.12+: Microsecond (SO_TIMESTAMP) precision. Testing: - Added unit tests for evbuffer receive timestamping. - Added direct socket and filtered OpenSSL bufferevent timestamp regress tests. - Verified all 344 unit tests pass successfully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FIx the test suite to work with OpenSSL 3.x and add support for the packet timestamp