I have devices that manually define PDP context 0 in order to set the APN to the required value for the SIM.
Typically, once connected to the network, the IP address gets assigned to this PDP context, and everything works fine:
rpc --id 0x3ea lte_at_cmd -c "AT+CGDCONT?" +CGDCONT: 0,"IP","teal","10.131.245.148",0,0 OK
Occasionally, the IP address gets assigned to a non-0 PDP context, e.g:
rpc --id 0xcc0000eb1e000036 lte_at_cmd -c "AT+CGDCONT?" +CGDCONT: 0,"IP","teal","",0,0 +CGDCONT: 1,"IP","teal","10.27.112.146",0,0 OK
This is a problem, because all of the Zephyr network stack integrations assume the only valid PDP context is 0.
1. PDN callback ignores the context ID: https://github.com/nrfconnect/sdk-nrf/blob/61b8072c1b78777887ec73e640dc694d53b9eab1/lib/nrf_modem_lib/lte_net_if/lte_net_if.c#L284
2. IP address retrieval hardcodes context ID 0: https://github.com/nrfconnect/sdk-nrf/blob/61b8072c1b78777887ec73e640dc694d53b9eab1/lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.c#L79
3. PDN callbacks are only registered for the default context: https://github.com/nrfconnect/sdk-nrf/blob/61b8072c1b78777887ec73e640dc694d53b9eab1/lib/nrf_modem_lib/lte_net_if/lte_net_if.c#L390
The result of this is that the application is connected to the network, the network has assigned an IP address, and yet the networking stack thinks it has no network connectivity.