-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Update inet6.py for Destination Option #4695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.
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. |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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'.
# 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 |
There was a problem hiding this comment.
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'.
# 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 |
There was a problem hiding this comment.
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).
# modification let's packet flow with Destination | |
# modification lets packet flow with Destination |
Copilot uses AI. Check for mistakes.
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:
cd test && ./run_tests
ortox
)