Skip to content

Fix sniffer join waiting indefinitely#4781

Merged
gpotter2 merged 1 commit into
secdev:masterfrom
louis-6wind:sniffer-join
Jul 17, 2025
Merged

Fix sniffer join waiting indefinitely#4781
gpotter2 merged 1 commit into
secdev:masterfrom
louis-6wind:sniffer-join

Conversation

@louis-6wind

Copy link
Copy Markdown
Contributor

When trying to stop a sniffer that was not already started, Scapy_Exception("Unsupported (offline or unsupported socket)") is no more raised and join() is waiting indefinitely.

Restore the previous stop_cb behavior.

Fixes: 6689da4 ("Add missing type in AsyncSniffer (#4665)")

Checklist:

  • If you are new to Scapy: I have checked CONTRIBUTING.md (esp. section submitting-pull-requests)
  • I squashed commits belonging together
  • I added unit tests or explained why they are not relevant
  • [] I executed the regression tests (using cd test && ./run_tests or tox)
  • If the PR is still not finished, please create a Draft Pull Request

fixes #xxx

Co-Authored-By: Louis Scalbert <louis.scalbert@6wind.com>
@codecov

codecov Bot commented Jul 17, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.02%. Comparing base (bd7f2a3) to head (fd95d44).
Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4781      +/-   ##
==========================================
- Coverage   81.23%   81.02%   -0.21%     
==========================================
  Files         363      365       +2     
  Lines       88404    89067     +663     
==========================================
+ Hits        71811    72167     +356     
- Misses      16593    16900     +307     
Files with missing lines Coverage Δ
scapy/sendrecv.py 86.53% <100.00%> (+0.11%) ⬆️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2

Copy link
Copy Markdown
Member

Thanks for the PR. Although I don't understand how you can reach this code (running remains False until you start() ?!), I agree that the current test is broken.

@gpotter2 gpotter2 merged commit 0a36696 into secdev:master Jul 17, 2025
24 checks passed
@louis-6wind

Copy link
Copy Markdown
Contributor Author

Thank you for the merge. But it is not working for me

Traceback (most recent call last):
  File "/usr/sbin/XXXXX, line 774, in sniffer_close
    sniffer.stop()
  File "/usr/local/lib/python3.12/dist-packages/scapy/sendrecv.py", line 1404, in stop
    if self.continue_sniff:
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'AsyncSniffer' object has no attribute 'continue_sniff'

@louis-6wind

louis-6wind commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

To reproduce:

from scapy.all import AsyncSniffer
sniffer=AsyncSniffer(
    iface="ens3",
    store=False,
    promisc=False,
)
sniffer.start()
sniffer.stop()

I got:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.12/dist-packages/scapy/sendrecv.py", line 1404, in stop
if self.continue_sniff:
^^^^^^^^^^^^^^^^^^^
AttributeError: 'AsyncSniffer' object has no attribute 'continue_sniff'

Basically I am monitoring the interfaces with netlink to start/stop sniffer. It happens in case of flapping

@gpotter2 gpotter2 added this to the 2.7.0 milestone Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants