Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applications: slm: try to continue even no DNS record was sent #19701

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TaeZStkyoht
Copy link
Contributor

@TaeZStkyoht TaeZStkyoht commented Dec 23, 2024

We shouldn't expect 2 DNS records from ISP. Because it sends sometimes 1 and even 0. We must just try to continue to establish PPP connection.

Real world scenario:
ISP sends DNS records as:

  • Onomondo eSim in Germany in NB-IoT mode: 0 (command result: +CGCONTRDP: 0,,"onomondo","","")
  • Vodafone sim in Turkey in NB-IoT mode: 0 (command result: +CGCONTRDP: 0,,"internet","","")
  • Turkcell sim in Turkey in NB-IoT mode: 0 (command result: +CGCONTRDP: 0,,"nbiot","","")
  • JIO sim in India in NB-IoT mode: 1 (command result: +CGCONTRDP: 0,,"jionet","","","2405:0200:0800:0000:0000:0000:0000:0006","")

MOSH was already working fine with allowing like that I've implemented here for SLM. We were using MOSH in at_cmd_mode on our product. However we want to use SLM; because, SLM is an application while MOSH is a sample. And we want to also be able to access GPIO command to swtich sim/eSim from outside easily. SLM is capable of doing it while MOSH not.

If this change is really directly not ok for you, I can also make it configurable with KConfig. By default can be false and we can set it to true on our project. Nevertheless, MOSH works like that, why not SLM?

@TaeZStkyoht TaeZStkyoht requested review from a team as code owners December 23, 2024 09:15
@github-actions github-actions bot added the doc-required PR must not be merged without tech writer approval. label Dec 23, 2024
@NordicBuilder
Copy link
Contributor

Thank you for your contribution!
It seems you are not a member of the nrfconnect GitHub organization. External contributions are handled as follows:
Large contributions, affecting multiple subsystems for example, may be rejected if they are complex, may introduce regressions due to lack of test coverage, or if they are not consistent with the architecture of nRF Connect SDK.
PRs will be run in our continuous integration (CI) test system.
If CI passes, PRs will be tagged for review and merged on successful completion of review. You may be asked to make some modifications to your contribution during review.
If CI fails, PRs may be rejected or may be tagged for review and rework.
PRs that become outdated due to other changes in the repository may be rejected or rework requested.
External contributions will be prioritized for review based on the relevance to current development efforts in nRF Connect SDK. Bug fix PRs will be prioritized.
You may raise issues or ask for help from our Technical Support team by visiting https://devzone.nordicsemi.com/.

Note: This comment is automatically posted and updated by the Contribs GitHub Action.

@NordicBuilder NordicBuilder added the external External contribution label Dec 23, 2024
@TaeZStkyoht TaeZStkyoht force-pushed the fix_dns_records_expectation branch 2 times, most recently from 53d856f to bfb7fc6 Compare December 23, 2024 10:38
@TaeZStkyoht TaeZStkyoht changed the title applications: slm: try to continue even no DNS records was sent applications: slm: try to continue even no DNS record was sent Dec 23, 2024
Copy link
Contributor

@MarkusLassila MarkusLassila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good finding. The functions should be changed so that they do not fail in the scenarios where the number of the DNS addresses is unexpected.

if (ret) {
return ret;
}
pdn_dynamic_params_get_v6(PDP_CID, NULL, NULL, &mtu);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that the error code should be swallowed in a case where there are no DNS-addresses provided. Instead the functions should take into account that this is a possibility and indicate which DNS-addresses were successfully fetched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But normally, I passed NULL to these parameters. It means this code block in slm_ppp.c already doesn't care about whether dns count 1 or 2. I think this is also related to next review point below that you wrote. With current implementation maybe I can check with error code and allow to continue whether return value is zero or -EBADMSG. Is it ok? Or let's discuss first the next review point below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm checking return value to allow to continue on ppp establishment if it's zero or -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could dns4_pri (and dns4_sec) be used to indicate that DNS address was not found, if it was asked? Setting the pointers to null is likely asking for trouble, but the bytes could be set to 0, to indicate no address. Another possibility would be to return how many addresses we found (or to add out parameters to indicate what we found).

Same for IPv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one is logical? I can do any of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I made it with setting to 0. Now dns4_pri, dns4_sec, ipv4_mtu, dns6_pri, dns6_sec, ipv6_mtu will be containing zeros.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would at least allow the caller to check if the address was fetched successfully. However, I am starting to lean on having a separate function for getting MTU and for this to return the amount of DNS addresses that were found. But let's wait for libmodem comments before proceeding with any of this.

if (matched >= 2) {
if (zsock_inet_pton(AF_INET, dns4_sec_str, dns4_sec) != 1) {
return -EADDRNOTAVAIL;
}
}
}
if (ipv4_mtu) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires that matched == 3, this will fail to get the mtu with the current changes. We should take into account how many addresses were actually found and get the correct mtu.

Same for IPv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand why will it fail to get mtu. I check >= because it can contain both 2 and 3 case. 2 means only DNS addresses were fetched. 3 means DNS addresses + MTU were fetched. Could you explain me more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original assumption was that scanf returned all the matches, so one DNS address and MTU would still result in matched = 2. Which would then fail to set the ipv4_mtu as there were less matches than intended. This would then have failed the subsequent matched check == 3. Unfortunately my assumption was wrong

Actually scanf returns only the matches up to the first non-matched value. So with one DNS address and MTU, would resut in matched = 1. This is problematic as what we really need in this case is the MTU and either one, two or even zero DNS addresses.

I don't think that this is necessarily possible with the current implementation and it is possible that we would need to have a separate method for fetching MTU. This needs a comment from libmodem, so please do not start implementing this at this point.

@TaeZStkyoht TaeZStkyoht force-pushed the fix_dns_records_expectation branch from bfb7fc6 to 2cd13a7 Compare December 23, 2024 16:16
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 <[email protected]>
@TaeZStkyoht TaeZStkyoht force-pushed the fix_dns_records_expectation branch from 2cd13a7 to d1fa9c0 Compare December 23, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-required PR must not be merged without tech writer approval. external External contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants