Repository navigation
fix(inet): include encapsulated payload padding in UDP checksum calculation (#4906) - #5191
adilalperenciftci wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is localized to UDP checksum construction and is directly covered by a regression test reproducing the reported mismatch.
Review effort: Lite
Findings: None
What changed in this PR
This PR fixes UDP checksum computation for IPv6/IPv4 underlayers when the UDP payload contains encapsulated-frame padding bytes that are present on the wire (and within the declared UDP length) but are appended during build_padding() after UDP.post_build() runs.
Changes:
- Adjust UDP checksum calculation to include encapsulated payload padding bytes up to the declared UDP length when rebuilding packets.
- Add a UTScapy regression test reproducing issue #4906 (VXLAN/IPv6 example) and asserting the recalculated checksum matches the received value.
| File | Description |
|---|---|
scapy/layers/inet.py |
Includes payload padding (added via build_padding()) in the bytes used for UDP checksum computation when the UDP length exceeds the built header+payload length. |
test/scapy/layers/inet6.uts |
Adds a regression test validating checksum recalculation matches the captured checksum for an encapsulated/padded UDP-over-IPv6 packet. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7835f8c to
07da874
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5191 +/- ##
==========================================
- Coverage 80.37% 80.07% -0.31%
==========================================
Files 375 375
Lines 97683 97686 +3
==========================================
- Hits 78516 78220 -296
- Misses 19167 19466 +299
🚀 New features to boost your workflow:
|
|
The two red jobs look unrelated to this change: the Windows failure is the J1939 BAM frame-delay test, while this PR only touches inet.py and inet6.uts. Could someone rerun the failed jobs? |
|
I reviewed the two remaining red jobs against this PR's diff. The Python 3.7 job fails because gzip.compress(..., mtime=0) is unsupported there in test/regression.uts; the Windows Python 3.14 job fails the J1939 SlowTestSocket frame-delay assertion (expected 4 frames, got 1). These are known matrix issues outside the UDP checksum change in scapy/layers/inet.py and test/scapy/layers/inet6.uts. The checksum-focused coverage and all other checks pass, and @polybassa has approved the patch. Could a maintainer treat these as unrelated or rerun the two jobs? |
…lation (secdev#4906) AI-Assisted: no
07da874 to
c5af204
Compare
|
I rebased the UDP checksum change onto the current master, which removes Python 3.7 from the matrix and includes the existing Windows timing fixes. Workflow 40506575396 is waiting for maintainer approval: https://github.com/secdev/scapy/actions/runs/40506575396 Could a maintainer approve this workflow run? |
|
Thanks for the review and approval @polybassa! Whenever you have a moment, could you please approve the workflow run for the updated commit? |
Fixes #4906. Corrects UDP checksum calculation when encapsulated frames include inner padding up to declared UDP length.