wwan/ofono: handle missing default gateway

It is normal for the operator to not provide a default gateway address, in
which case it must be set to 0.0.0.0, as can be seen in upstream ofono test
scripts [1].

[1] https://git.kernel.org/pub/scm/network/ofono/ofono.git/commit/test/process-context-settings?id=945a621a2ddfc01b8bdd8936044cb7d2604e8608

Fixes: a6e81af87f ('wwan: add support for using oFono as a modem manager')
(cherry picked from commit 96ae8b794f)
This commit is contained in:
Sicelo A. Mhlongo 2023-09-13 10:12:35 +02:00 committed by Beniamino Galvani
parent fc65b8ff45
commit 4fbd70c50a

View file

@ -1276,8 +1276,11 @@ handle_settings(NMModemOfono *self, GVariant *v_dict)
nm_l3_config_data_add_address_4(priv->l3cd_4, &address);
if (!g_variant_lookup(v_dict, "Gateway", "&s", &s) || !s) {
_LOGW("Settings 'Gateway' missing");
goto out;
/* It is normal for point-to-point connections to not have a gateway IP
* specified. Use 0.0.0.0 in that case.
*/
_LOGD("Settings 'Gateway' missing. Setting it to 0.0.0.0");
s = "0.0.0.0";
}
if (!nm_inet_parse_bin(AF_INET, s, NULL, &gateway_network)) {
_LOGW("invalid 'Gateway': %s", s);