Mobile network connection sometimes ends up in ipv6-only state after period of no reception
This is about Librem 5 with PureOS. Normally, the mobile network connection for me gives support for both ipv4 and ipv6, because a bearer of type "ipv4v6" is used. That is good.
However, after passing an area of no mobile reception (or simulating that using a Faraday cage which I did for testing), when networking is restored it sometimes ends up in a ipv6-only mode, which in practice means that some important things stop working for me. (The Phosh icon to indicate loss of networking is not shown in this case, probably because networking does work for ipv6.)
Having played around with this and tested it a number of times I believe what happens in the following: the three kinds of bearers (ipv4v6, ipv4, ipv6) are tested in a certain order, with ipv4v6 being tested first, so if ipv4v6 works then that is used, which is the normal case. However, when reception comes back after some time without reception, any of the three kinds (ipv4v6, ipv4, ipv6) may get picked, it becomes kind of random as it depends on which one is being tested when the reception comes back.
It seems like, when there is no reception, attempts are made to connect using ipv4v6, if that fails then ipv4 and ipv6 are tested, then ipv4v6 is tested again, then ipv4 and ipv6 again, and so on. If reception happens to come back when ipv6 is tested, then ipv6 is used and the phone ends up in a ipv6-only state. Similarly, if reception happens to come back when ipv4 is tested, then ipv4 is used and the phone ends up in a ipv4-only state. So we get a ipv6-only or ipv4-only state (instead of the desired ipv4v6) just due to "bad luck" with the timing regarding the moment when reception comes back.
It seems to me like a reasonable fix for this would be to change the algorithm a bit. The current algorithm seems to be similar to round-robin testing of the three variants (ipv4v6, ipv4, ipv6) and picking whichever happens to work first. Instead of that, I would like to have something like the following: first check if there is any mobile reception at all, of any kind. In case of no reception, then don't try to connect networking, just wait until there is reception. When there is reception, then try the three kinds (ipv4v6, ipv4, ipv6), starting with ipv4v6.
Would it make sense to try implementing something like that in ModemManager? (or somewhere else, if so, where?)
Other ideas for how to solve this?