From bfb7fc612bf97b3bc8b6ad15aa0426a49836b222 Mon Sep 17 00:00:00 2001 From: Oguzhan Turk Date: Mon, 23 Dec 2024 10:00:57 +0100 Subject: [PATCH] applications: slm: try to continue even no DNS record was sent We shouldn't expect 2 DNS records from ISP. Because it sends sometimes 1 and even 0. It must try to continue like in MOSH. Signed-off-by: Oguzhan Turk --- applications/serial_lte_modem/src/slm_ppp.c | 8 ++++---- .../releases/release-notes-changelog.rst | 1 + lib/pdn/pdn.c | 20 +++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/applications/serial_lte_modem/src/slm_ppp.c b/applications/serial_lte_modem/src/slm_ppp.c index 8baf6ec950a..c6aadad4aa4 100644 --- a/applications/serial_lte_modem/src/slm_ppp.c +++ b/applications/serial_lte_modem/src/slm_ppp.c @@ -214,10 +214,10 @@ static int ppp_start_internal(void) &ctx->ipcp.my_options.dns2_address, &mtu); if (ret) { /* If any error happened on pdn getting with IPv4, try to parse with IPv6 */ - ret = pdn_dynamic_params_get_v6(PDP_CID, NULL, NULL, &mtu); - if (ret) { - return ret; - } + pdn_dynamic_params_get_v6(PDP_CID, NULL, NULL, &mtu); + /* Don't check fallback's return value and try to continue. + * ISP may not send DNS records. + */ } if (mtu) { 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 1fe46a72431..af50adfed41 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -453,6 +453,7 @@ Modem libraries * :ref:`pdn_readme` library: * Added the :c:func:`pdn_dynamic_params_get_v6` function to get PDN parameters for IPv6-only. + * Changed logic DNS record expectation. Because ISP sends sometimes 1 and even 0. * :ref:`lte_lc_readme` library: diff --git a/lib/pdn/pdn.c b/lib/pdn/pdn.c index da58c665015..93bc21bc036 100644 --- a/lib/pdn/pdn.c +++ b/lib/pdn/pdn.c @@ -632,8 +632,8 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, /* If IPv4 is enabled, it will be the first response line. */ matched = nrf_modem_at_scanf(at_cmd, fmt, &dns4_pri_str, &dns4_sec_str, &mtu); - /* Need to match at least the two IP addresses, or there is an error */ - if (matched < 2) { + + if (matched < 1) { return -EBADMSG; } @@ -643,8 +643,10 @@ int pdn_dynamic_params_get(uint8_t cid, struct in_addr *dns4_pri, } } if (dns4_sec) { - if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) { - return -EADDRNOTAVAIL; + if (matched >= 2) { + if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) { + return -EADDRNOTAVAIL; + } } } if (ipv4_mtu) { @@ -681,8 +683,8 @@ int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri, /* If IPv6 is enabled, it will be the first response line. */ matched = nrf_modem_at_scanf(at_cmd, fmt, &dns6_pri_str, &dns6_sec_str, &mtu); - /* Need to match at least the two IP addresses, or there is an error */ - if (matched < 2) { + + if (matched < 1) { return -EBADMSG; } @@ -692,8 +694,10 @@ int pdn_dynamic_params_get_v6(uint8_t cid, struct in6_addr *dns6_pri, } } if (dns6_sec) { - if (zsock_inet_pton(AF_INET6, dns6_sec_str, dns6_sec) != 1) { - return -EADDRNOTAVAIL; + if (matched >= 2) { + if (zsock_inet_pton(AF_INET6, dns6_sec_str, dns6_sec) != 1) { + return -EADDRNOTAVAIL; + } } } if (ipv6_mtu) {