[linux] fix missing correct mtu (#5642)

Set correct MTU so that big IPv6 datagrams can automatically be fragmented
by host IP stack.
This commit is contained in:
Yakun Xu
2020-10-14 07:17:40 -07:00
committed by GitHub
parent ad87f636e5
commit c595ee6c36
+5 -1
View File
@@ -275,7 +275,7 @@ enum
};
#endif
static const size_t kMaxIp6Size = 1536;
static constexpr size_t kMaxIp6Size = OPENTHREAD_CONFIG_IP6_MAX_DATAGRAM_LENGTH;
#define OPENTHREAD_POSIX_LOG_TUN_PACKETS 0
@@ -548,6 +548,7 @@ static void processReceive(otMessage *aMessage, void *aContext)
#endif
assert(sInstance == aContext);
assert(length <= kMaxIp6Size);
VerifyOrExit(sTunFd > 0, OT_NOOP);
@@ -1292,6 +1293,9 @@ static void platformConfigureTunDevice(otInstance *aInstance,
VerifyOrDie(ioctl(sTunFd, TUNSETLINK, ARPHRD_VOID) == 0, OT_EXIT_ERROR_ERRNO);
strncpy(deviceName, ifr.ifr_name, deviceNameLen);
ifr.ifr_mtu = static_cast<int>(kMaxIp6Size);
VerifyOrDie(ioctl(sIpFd, SIOCSIFMTU, static_cast<void *>(&ifr)) == 0, OT_EXIT_ERROR_ERRNO);
}
#endif