Skip to content

Commit

Permalink
nrf_modem_lib: lte_net_if: query actual link MTU
Browse files Browse the repository at this point in the history
Update the network interface MTU before raising the connectivity event,
so that the MTU as queried by downstream users is correct, instead of
an assumed value based on IPv6 required minimums.

Signed-off-by: Jordan Yates <[email protected]>
  • Loading branch information
JordanYates committed Dec 15, 2024
1 parent 05b9d9e commit 8a58c00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/nrf_modem_lib/lte_net_if/lte_net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,29 @@ void lte_net_if_modem_fault_handler(void)
net_if_dormant_on(iface_bound);
}

static uint16_t pdn_mtu(void)
{
unsigned int mtu;
int rc;

rc = pdn_dynamic_params_get(0, NULL, NULL, &mtu);
if (rc != 0) {
LOG_WRN("MTU query failed, error: %d", rc);
/* Fallback to the minimum value that IPv4 is required to support */
mtu = NET_IPV4_MTU;
}
LOG_DBG("Network MTU: %d", mtu);
return mtu;
}

/* Called when we detect LTE connectivity has been gained.
*
* Marks the iface as active and cancels any pending timeout.
* Queries the network MTU, marks the iface as active, and cancels any pending timeout.
*/
static void become_active(void)
{
LOG_DBG("Becoming active");
net_if_set_mtu(iface_bound, pdn_mtu());
net_if_dormant_off(iface_bound);
k_work_cancel_delayable(&connection_timeout_work);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/nrf_modem_lib/nrf9x_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ static struct offloaded_if_api nrf9x_iface_offload_api = {
.enable = nrf9x_iface_enable,
};

/* TODO Get the actual MTU for the nRF9x LTE link. */
/* Actual MTU for the nRF9x LTE link is handled by `lte_net_if.c` */
NET_DEVICE_OFFLOAD_INIT(nrf9x_socket, "nrf9x_socket",
nrf9x_socket_offload_init,
NULL,
Expand Down

0 comments on commit 8a58c00

Please sign in to comment.