From: Pasi Sjöholm <[email protected]>
It is possible that IPv6.Settings-properties does not include
ip-address, gateway or nameservers when the context is made active.
This is due underlying ofono-driver/ril sending the assigned ipv4-addresses
first and then the assigned ipv6-addresses (within 3 secs).
This happens especially only with dual/ipv4v6-protocol. To be able
to reconfigure the addresses later we set the method either AUTO
or DHCP.
---
plugins/ofono.c | 58 +++++++++++++++++++++++++++++++--------------------------
1 file changed, 32 insertions(+), 26 deletions(-)
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 8821f1e..16d3b41 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -257,7 +257,6 @@ static void network_context_free(struct network_context
*context)
static void set_connected(struct modem_data *modem)
{
struct connman_service *service;
- bool setip = false;
enum connman_ipconfig_method method;
char *nameservers;
int index;
@@ -266,10 +265,8 @@ static void set_connected(struct modem_data *modem)
index = modem->context->index;
- method = modem->context->ipv4_method;
- if (index < 0 || (!modem->context->ipv4_address &&
- method == CONNMAN_IPCONFIG_METHOD_FIXED)) {
- connman_error("Invalid index and/or address");
+ if (index < 0 ) {
+ connman_error("Invalid index");
return;
}
@@ -277,28 +274,36 @@ static void set_connected(struct modem_data *modem)
if (!service)
return;
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
- method == CONNMAN_IPCONFIG_METHOD_DHCP) {
- connman_service_create_ip4config(service, index);
- connman_network_set_index(modem->network, index);
-
- connman_network_set_ipv4_method(modem->network, method);
-
- setip = true;
- }
-
+ method = modem->context->ipv4_method;
if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
- connman_network_set_ipaddress(modem->network,
+ if (modem->context->ipv4_address) {
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network, method);
+ connman_network_set_ipaddress(modem->network,
modem->context->ipv4_address);
+ } else {
+ connman_error("Invalid ipv4-address");
+ return;
+ }
+ } else {
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network,
CONNMAN_IPCONFIG_METHOD_DHCP);
}
method = modem->context->ipv6_method;
if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
- connman_service_create_ip6config(service, index);
- connman_network_set_ipv6_method(modem->network, method);
- connman_network_set_ipaddress(modem->network,
+ if (modem->context->ipv6_address) {
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network, method);
+ connman_network_set_ipaddress(modem->network,
modem->context->ipv6_address);
- setip = true;
+ } else {
+ connman_error("Invalid ipv6-address");
+ return;
+ }
+ } else {
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network,
CONNMAN_IPCONFIG_METHOD_AUTO);
}
/* Set the nameservers */
@@ -317,8 +322,9 @@ static void set_connected(struct modem_data *modem)
modem->context->ipv6_nameservers);
}
- if (setip)
- connman_network_set_connected(modem->network, true);
+ connman_network_set_index(modem->network, index);
+ connman_network_set_connected(modem->network, true);
+
}
static void set_disconnected(struct modem_data *modem)
@@ -921,16 +927,16 @@ static void extract_ipv6_settings(DBusMessageIter *array,
if (index < 0)
goto out;
- context->ipv6_method = CONNMAN_IPCONFIG_METHOD_FIXED;
-
context->ipv6_address =
connman_ipaddress_alloc(CONNMAN_IPCONFIG_TYPE_IPV6);
if (!context->ipv6_address)
goto out;
context->index = index;
- connman_ipaddress_set_ipv6(context->ipv6_address, address,
- prefix_length, gateway);
+ if (!connman_ipaddress_set_ipv6(context->ipv6_address, address,
+ prefix_length, gateway)) {
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_FIXED;
+ }
g_free(context->ipv6_nameservers);
context->ipv6_nameservers = nameservers;
--
2.1.0
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman