diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 4d81066e6c3a..4ec7de171670 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -455,6 +455,8 @@ Modem libraries * Added the :c:func:`pdn_dynamic_params_get_v6` function to get PDN parameters for IPv6-only. +* Updated the :ref:`nrf_modem_lib_lte_net_if` to automatically set the actual link :term:`Maximum Transmission Unit (MTU)` on the network interface when PDN connectivity is gained. + Multiprotocol Service Layer libraries ------------------------------------- diff --git a/lib/nrf_modem_lib/lte_net_if/lte_net_if.c b/lib/nrf_modem_lib/lte_net_if/lte_net_if.c index 15476b1a400b..5ac78e85a6b3 100644 --- a/lib/nrf_modem_lib/lte_net_if/lte_net_if.c +++ b/lib/nrf_modem_lib/lte_net_if/lte_net_if.c @@ -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 = 0; + int rc; + + rc = pdn_dynamic_params_get(0, NULL, NULL, &mtu); + if ((rc != 0) || (mtu == 0)) { + LOG_WRN("MTU query failed, error: %d, MTU: %d", rc, mtu); + /* 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); } diff --git a/lib/nrf_modem_lib/nrf9x_sockets.c b/lib/nrf_modem_lib/nrf9x_sockets.c index a593b22222f0..da8c84266366 100644 --- a/lib/nrf_modem_lib/nrf9x_sockets.c +++ b/lib/nrf_modem_lib/nrf9x_sockets.c @@ -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,