Skip to content

fix: prevent MTU clamp to zero when previous-hop has no HW_MTU#32

Merged
attermann merged 1 commit intoattermann:masterfrom
jrl290:fix/mtu-clamp-zero-ph-mtu
Mar 24, 2026
Merged

fix: prevent MTU clamp to zero when previous-hop has no HW_MTU#32
attermann merged 1 commit intoattermann:masterfrom
jrl290:fix/mtu-clamp-zero-ph-mtu

Conversation

@jrl290
Copy link
Contributor

@jrl290 jrl290 commented Mar 8, 2026

Problem

When forwarding a LINKREQUEST through a transport node, the MTU clamping logic in Transport::inbound() uses std::min(nh_mtu, ph_mtu) to pick the lower of the next-hop and previous-hop interface MTUs.

However, when the previous-hop interface has no HW_MTU configured (ph_mtu == 0), std::min(nh_mtu, 0) clamps the path MTU to zero instead of using nh_mtu.

This happens when:

  1. A LINKREQUEST enters via an interface that doesn't report an HW_MTU
  2. nh_mtu < path_mtu is true (so the clamping branch executes)
  3. ph_mtu is 0 from initialization → std::min(nh_mtu, 0) = 0

The result is a zero-byte MTU in the signalling bytes, which causes the link to either fail or produce unusable segment sizes.

Fix

Change:

path_mtu = std::min(nh_mtu, ph_mtu);

To:

path_mtu = std::min(nh_mtu, (ph_mtu > 0) ? ph_mtu : nh_mtu);

When ph_mtu is 0 (unknown/unconfigured), fall back to nh_mtu rather than clamping to zero.

Testing

Discovered and verified on ESP32 transport nodes (Heltec V3/V4) forwarding LXMF resource transfers between TCP clients. Without this fix, resource transfers through the transport node stall permanently when the inbound interface lacks an HW_MTU value.

When forwarding a LINKREQUEST through a transport node, the MTU clamping
logic uses std::min(nh_mtu, ph_mtu) to pick the lower of the next-hop
and previous-hop interface MTUs. However, when the previous-hop interface
has no HW_MTU configured (ph_mtu == 0), this clamps the path MTU to 0
instead of using the next-hop MTU.

This can happen when the LINKREQUEST enters via an interface that doesn't
report an HW_MTU but nh_mtu < path_mtu is true (so we enter the clamping
branch). The result is a zero-byte MTU in the signalling bytes, which
causes the link to fail.

Fix: use std::min(nh_mtu, (ph_mtu > 0) ? ph_mtu : nh_mtu) so that when
ph_mtu is 0 (unknown), we fall back to nh_mtu rather than clamping to 0.
@attermann attermann merged commit b24a8a8 into attermann:master Mar 24, 2026
@attermann
Copy link
Owner

Simple yet effective. TY.

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