Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 5a0eb55

Browse files
authored
Merge pull request #616 from holbrookt/tunnel-lwip-alloc-fix
Add WEAVE_TRAILER_RESERVE_SIZE to Tunnel pbuf allocation from LwIP
2 parents 097e6a2 + ac2b3cf commit 5a0eb55

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/inet/TunEndPoint.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ err_t TunEndPoint::LwIPPostToInetEventQ (struct netif *netif, struct pbuf *p)
549549
INET_ERROR err = INET_NO_ERROR;
550550
TunEndPoint* ep = static_cast<TunEndPoint *>(netif->state);
551551
Weave::System::Layer& lSystemLayer = ep->SystemLayer();
552-
PacketBuffer* buf = PacketBuffer::NewWithAvailableSize(p->tot_len);
553-
554-
// Starting off with a reserved size of the default WEAVE_SYSTEM_CONFIG_HEADER_RESERVE_SIZE
555-
// which allows for adding the Weave header and the underlying transport and IP headers
556-
// encapsulating this tunneled packet.
557552

553+
// Allocate space for the tunneled IP packet. The reserved space will be the
554+
// default for the Weave and underlying TCP/IP headers (WEAVE_SYSTEM_CONFIG_HEADER_RESERVE_SIZE).
555+
// The requested data size will include the full pbuf received from LwIP plus
556+
// WEAVE_TRAILER_RESERVE_SIZE for holding the HMAC.
557+
PacketBuffer* buf = PacketBuffer::NewWithAvailableSize(p->tot_len + WEAVE_TRAILER_RESERVE_SIZE);
558558
VerifyOrExit(buf != NULL, lwipErr = ERR_MEM);
559559

560560
buf->SetDataLength(p->tot_len);

0 commit comments

Comments
 (0)