Skip to content

tftp: extend multi-block read results in place - #5110

Merged
gpotter2 merged 2 commits into
secdev:masterfrom
KernelClint:perf/tftp-read-accumulation
Aug 27, 2026
Merged

tftp: extend multi-block read results in place#5110
gpotter2 merged 2 commits into
secdev:masterfrom
KernelClint:perf/tftp-read-accumulation

Conversation

@KernelClint

Copy link
Copy Markdown
Contributor

TFTP_read is Scapy's client automaton for downloading a file block by block. Each accepted remote
DATA block reaches immutable self.res += recvd at
scapy/layers/tftp.py:196-234,
which recopies every prior response before waiting for the next block.

From 4,000 to 16,000 full blocks, median processing grew from 82.41 ms to 1,308.05 ms, with a 2.13
exponent and an 11.5% noise floor. Patched times were 21.39 ms to 87.75 ms, with a 1.04 exponent and
a 1.7% noise floor.

This change retains the single-block bytes path, extends one bytearray after a second block, and
converts it back to bytes at the final transition. The focused regression failed on the unmodified
revision and passed with the patch.

AI-Assisted: yes (GPT-5.6-Cyber)
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.63%. Comparing base (ba8641a) to head (5c2606f).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5110      +/-   ##
==========================================
+ Coverage   80.59%   80.63%   +0.03%     
==========================================
  Files         390      390              
  Lines       96892    96895       +3     
==========================================
+ Hits        78094    78130      +36     
+ Misses      18798    18765      -33     
Files with missing lines Coverage Δ
scapy/layers/tftp.py 96.96% <100.00%> (ø)

... and 15 files with indirect coverage changes

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

Comment thread scapy/layers/tftp.py Outdated
Addresses review feedback on secdev#5110: rather than switching self.res between
bytes and bytearray, initialise it as a bytearray and convert once when the
automaton returns. Removes the isinstance branching; the accumulate line goes
back to a plain +=.

AI-Assisted: yes (GPT-5.6-Sol)
@gpotter2
gpotter2 merged commit 9eaf27e into secdev:master Aug 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants