Fix sniff timeout when libpcap select returns readable with no packets#5008
Open
T3pp31 wants to merge 1 commit into
Open
Fix sniff timeout when libpcap select returns readable with no packets#5008T3pp31 wants to merge 1 commit into
T3pp31 wants to merge 1 commit into
Conversation
Use nonblock_recv() in timed sniff loops when the socket supports it, so a blocking pcap_next_ex cannot stall past the sniff timeout (secdev#4590). Regression test simulates libpcap reporting the fd as readable while nonblock_recv returns no BPF-matched packet. Co-authored-by: Cursor <cursoragent@cursor.com>
Member
|
Hi & thanks for the PR ! It has great performance implications to use a non blocking read instead of a blocking one. I am therefore not sure that this is the proper way of tackling the issue. |
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.
Summary
sniff(..., timeout=N)uses a libpcap socket,selectmay report the capture fd as readable even when no BPF-matched packets are available; a blockingpcap_next_exinrecv()could then stall past the sniff timeout (same class as Timeout doesn't work when no sniffing results with L2pcapListenSocket #74).nonblock_recv()when the socket supports it, via anonblockflag on sessionrecv().selectwhilenonblock_recv()yields no packet.Fixes #4590
Test plan
sniff timeout with select-ready but empty pcap socket (#4590)intest/regression.utstimeout=1, blockingrecv()never calledMade with Cursor