mirror of
https://github.com/espressif/openthread.git
synced 2026-08-08 03:37:46 +00:00
[nat64] handle IPv4 options and discard source route options (#12818)
OpenThread's NAT64 translator assumed a fixed IPv4 header length of 20 bytes, which caused incorrect parsing and translation of IPv4 packets containing options (IHL > 5). Specifically, if an IPv4 packet with options was received: 1. The transport header was read from a fixed 20-byte offset, leading to corruption of transport layer fields (e.g., UDP ports). 2. Only 20 bytes were removed from the message, leaving the IPv4 options at the beginning of the translated IPv6 payload. 3. Mandatory security checks for source route options were bypassed. This commit fixes these issues by: - Updating Ip4::Header to validate IHL and provide the actual header length. - Using the actual header length for transport header parsing and IPv4 header removal in the NAT64 translator. - Implementing a check to discard packets with LSRR or SSRR options as required by RFC 7915. A new Nexus regression test is added to verify the fix.
This commit is contained in:
@@ -78,8 +78,9 @@ void TestIp4Header(void)
|
||||
|
||||
header.Clear();
|
||||
header.InitVersionIhl();
|
||||
header.SetTotalLength(header.GetHeaderLength());
|
||||
VerifyOrQuit(header.IsValid());
|
||||
VerifyOrQuit(header.GetTotalLength() == 0);
|
||||
VerifyOrQuit(header.GetTotalLength() == sizeof(Header));
|
||||
VerifyOrQuit(header.GetProtocol() == 0);
|
||||
VerifyOrQuit(header.GetTtl() == 0);
|
||||
VerifyOrQuit(header.GetSource().mFields.m32 == 0);
|
||||
|
||||
Reference in New Issue
Block a user