Skip to content

Conversation

@zvibazak
Copy link

We found an error when setting self.traffic_class on IPv6Header when self.flow_label is greater then 2 bytes.
I added a shift-right by 16 and it fixed.

zvibazak added 2 commits May 13, 2021 17:27
Error when setting traffic_class on IPv6Header when flow_label is greater then 2 bytes
@majibow
Copy link

majibow commented Apr 13, 2022

The fix is correct, although I would have removed the bitwise-and on flow label, since its not necessary.
struct.pack_into('!H', self.raw, 0, 0x6000 | (val << 4) | (self.flow_label >> 16))

Otherwise, I would also add a bitwise-and to traffic class, for safety/clarity.
struct.pack_into('!H', self.raw, 0, 0x6000 | ((val & 0x00FF) << 4) | ((self.flow_label & 0x000FFFFF) >> 16))

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