Skip to content

Update inet6.py for Destination Option#4695

Open
arnavdas88 wants to merge 4 commits intosecdev:masterfrom
arnavdas88:patch-1
Open

Update inet6.py for Destination Option#4695
arnavdas88 wants to merge 4 commits intosecdev:masterfrom
arnavdas88:patch-1

Conversation

@arnavdas88
Copy link

Extension Headers can show weird behavious. Linux's sk_buff considers the IPv6 Payload to be either TCP, UDP or ICMP. It does not consider Extension Headers to be the payload.

Following similar architecture, This small modification let's packet flow with Destination Option on both, request and response packets be captured as well, which was not the case before, as a packet flow with DestOpt ExtHdr in both request and response will be skipped by the previously implemented logic.

No current GitHub issue exists, because there are no publicly available PDM (RFC8250) Server available, and for the same reason, the Unit Tests are not relevent.

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

Extension Headers can show weird behavious. Linux's sk_buff considers the IPv6 Payload to be either TCP, UDP or ICMP. It does not consider Extension Headers to be the payload.

Following similar architecture, This small modification let's packet flow with Destination Option on both, request and response packets be captured as well.
@guedou
Copy link
Member

guedou commented Mar 16, 2025

Thanks for this PR! This looks good to me.

Could you add corresponding unit tests into https://github.com/secdev/scapy/edit/master/test/scapy/layers/inet6.uts ? This will ensure that your code works as expected, and catch future regressions.

@guedou guedou requested a review from Copilot September 14, 2025 17:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the IPv6 packet answer logic to properly handle Destination Option extension headers by checking for UDP/TCP layers directly instead of relying solely on the payload chain. This follows Linux's sk_buff architecture which considers TCP, UDP, or ICMP as the IPv6 payload rather than extension headers.

  • Modified the answers() method in IPv6 class to handle Destination Option extension headers differently
  • Added direct UDP/TCP layer checking when processing packets with Destination Option headers
  • Preserved backward compatibility by falling back to the previous implementation for other cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.64%. Comparing base (a4f958b) to head (58af5c3).
⚠️ Report is 134 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4695      +/-   ##
==========================================
- Coverage   82.13%   80.64%   -1.50%     
==========================================
  Files         361      370       +9     
  Lines       86830    91731    +4901     
==========================================
+ Hits        71319    73973    +2654     
- Misses      15511    17758    +2247     
Files with missing lines Coverage Δ
scapy/layers/inet6.py 88.55% <100.00%> (+<0.01%) ⬆️

... and 106 files with indirect coverage changes

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

@guedou guedou marked this pull request as ready for review February 14, 2026 11:08
@guedou guedou self-assigned this Feb 14, 2026
@guedou guedou requested a review from gpotter2 February 14, 2026 16:11
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