When devices are initialized, we check if the interface is
up and if it is, we cleanup the interface. This is not nice if
the interface is already provisioned and contains a valid IP
address.
If that is the case, then we check if IPv4 address and netmask
are the same as what we are trying to provision. If the addresses
are the same, then we do not init the interface because the it is
already setup. We only do this check for IPv4 addresses.
---
src/device.c | 21 +++++++++++++++++++++
src/main.c | 2 +-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index 761d9ec..5c018d9 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1424,6 +1424,7 @@ static void cleanup_devices(void)
for (i = 0; interfaces[i]; i++) {
bool filtered;
int index;
+ struct sockaddr_in sin_addr, sin_mask;
filtered = __connman_device_isfiltered(interfaces[i]);
if (filtered)
@@ -1433,6 +1434,26 @@ static void cleanup_devices(void)
if (index < 0)
continue;
+ if (!__connman_inet_get_address_netmask(index, &sin_addr,
+ &sin_mask)) {
+ char *address = g_strdup(inet_ntoa(sin_addr.sin_addr));
+ char *netmask = g_strdup(inet_ntoa(sin_mask.sin_addr));
+
+ if (__connman_config_address_provisioned(address,
+ netmask,
+ AF_INET)) {
+ DBG("Skip %s which is already provisioned "
+ "with %s/%s", interfaces[i], address,
+ netmask);
+ g_free(address);
+ g_free(netmask);
+ continue;
+ }
+
+ g_free(address);
+ g_free(netmask);
+ }
+
DBG("cleaning up %s index %d", interfaces[i], index);
connman_inet_ifdown(index);
diff --git a/src/main.c b/src/main.c
index c1d4620..5eeade5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -651,6 +651,7 @@ int main(int argc, char *argv[])
__connman_service_init();
__connman_provider_init();
__connman_network_init();
+ __connman_config_init();
__connman_device_init(option_device, option_nodevice);
__connman_ippool_init();
@@ -661,7 +662,6 @@ int main(int argc, char *argv[])
__connman_tethering_init();
__connman_counter_init();
__connman_manager_init();
- __connman_config_init();
__connman_stats_init();
__connman_clock_init();
--
1.7.11.7
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman