Skip to content

Fix serialization for QinQ #315

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

Closed
wants to merge 2 commits into from

Conversation

teodoro-vargas
Copy link
Contributor

Current implementation of libtins uses Dot1Q frame to represent both Dot1Q and Dot1AD (QinQ). The serialization of a packet with double tagging writes the PIDs in the wrong order: 0x8100 (Dot1Q) followed by 0x88a8 (Dot1AD), when the order should be 0x88a8 (Dot1AD) followed by 0x8100 (Dot1Q).

@mfontanini
Copy link
Owner

Wouldn't it be simpler to simply fix Dot1Q instead of introducing a new class to fix this? e.g. flip the check and instead of doing what it's currently doing with the inner_pdu, do it with the parent_pdu.

@teodoro-vargas
Copy link
Contributor Author

@mfontanini That would require to assume that the parent frame is an EthernetII, since the method parent_pdu returns a PDU and a cast would be necessary. We can try that option, but we think that that casting can be a little dangerous.

@mfontanini
Copy link
Owner

You don't have to cast the parent PDU, you can just call PDU::pdu_type and see if it's the ethernet one.

@teodoro-vargas
Copy link
Contributor Author

Ok, that didn't work for me. However, keeping the change in the write_serialization method in EthernetII and removing the Dot1AD frame did.
Still, having to get the Dot1Q frame and then check if there's another Dot1Q frame inside, instead of just looking for the Dot1AD frame, would be a little annoyance for some people.

@teodoro-vargas teodoro-vargas changed the title Add QinQ frame Fix serialization for QinQ Sep 26, 2018
@teodoro-vargas
Copy link
Contributor Author

@mfontanini I believe that the approach you mentioned didn't work because of the pdu_type value during the serialization process (which is a static value of 0x8100, in Dot1Q). In the latest commit of this PR, It's checked directly in the EthernetII frame if the following two frames are Dot1Q, in which case, a QinQ PID is written (0x88a8).
Please, let us know if the change is still incorrect.

@teodoro-vargas
Copy link
Contributor Author

@mfontanini friendly ping. We applied the fixes you requested.
Thanks.

@mfontanini
Copy link
Owner

Looks good! Do you mind adding a test? Specifically something that constructs a simple packet like EthernetII() / Dot1Q() / Dot1Q() / something using some tag for each dot1q frame, the serializing it, parsing it back and making sure everything works?

@teodoro-vargas
Copy link
Contributor Author

Updated PR is in #316

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