Skip to content

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 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.

@@ -481,7 +481,20 @@ def answers(self, other):
elif other.nh == 43 and isinstance(other.payload, IPv6ExtHdrSegmentRouting): # noqa: E501
return self.payload.answers(other.payload.payload) # Buggy if self.payload is a IPv6ExtHdrRouting # noqa: E501
elif other.nh == 60 and isinstance(other.payload, IPv6ExtHdrDestOpt):
return self.payload.answers(other.payload.payload)
# Extension Headers can show weird behavious.
Copy link
Preview

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

There's a typo in the comment: 'behavious' should be 'behavior'.

Suggested change
# Extension Headers can show weird behavious.
# Extension Headers can show weird behavior.

Copilot uses AI. Check for mistakes.

# 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
Copy link
Preview

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

The word 'This' should not be capitalized mid-sentence. It should be 'this small'.

Suggested change
# Following similar architecture, This small
# Following similar architecture, this small

Copilot uses AI. Check for mistakes.

# 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
Copy link
Preview

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

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

Incorrect use of apostrophe: 'let's' should be 'lets' (third person singular verb, not contraction).

Suggested change
# modification let's packet flow with Destination
# modification lets packet flow with Destination

Copilot uses AI. Check for mistakes.

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