Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Haven't really found the bug, but I'm questioning some of the code anyway. Uploading tweaks. While computing the nexthdr of a given IPv6 packet, the code was performing the following assignment: Local network header pointer = skb_network_header(skb) + local network header offset (By "local" I mean the scope of the variable.) This operation is reused for outer and inner packets, and strongly requires and assumes that skb_network_offset(skb) is zero: - For outer packets, it doesn't make sense to add anything to skb_network_header(skb) to get a pointer to the network header, and "local network header offset" is skb_network_offset(skb). - For inner packets, "local network header offset" is an offset from skb->data, which means that skb_network_header(skb) needs to equal skb->data. (Hence, skb_network_offset(skb) = 0.) Which is supposed to always the case, which is the reason why this isn't really a bug, unless the kernel itself has another bug to match. I thought about putting a validation in place to ensure that the network header offset is zero for all outer packets, but then I realized that the whole reason why I was making this so convoluted was because I didn't want the code to touch skb->data. (Instead relying on available kernel API.) I noticed that there is at least one function around (offset_to_ptr()) that does it anyway. (And I don't think that there is a way around that unless the packet.c module is completely rewritten.) So the new code is Local network header pointer = skb->data + local network header offset Which actually expresses the intent much more clearly. The following are old assumptions that stand valid still: - The skb_network_offset() offset is relative to skb->data. - The skb_header_pointer() offset is relative to skb->data. The following is no longer an assumption and Jool should continue working fine if the kernel happens to break it: - skb_network_offset(skb) during a packet's entrance to a Netfilter hook is zero. So that's what this commit comes down to; I removed an potential future bug opportunity and made the code clearer as a bonus.
- Loading branch information