On Fri, 2013-10-04 at 14:59 +0300, Jukka Rissanen wrote:
> 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 we notice this case, then corresponding interface
> is not cleaned.
> ---
> src/device.c | 22 ++++++++++++++++++++++
> src/main.c | 2 +-
> 2 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/src/device.c b/src/device.c
> index 761d9ec..1313fb0 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;
>
> filtered = __connman_device_isfiltered(interfaces[i]);
> if (filtered)
> @@ -1433,6 +1434,27 @@ static void cleanup_devices(void)
> if (index < 0)
> continue;
>
> + memset(&sin, 0, sizeof(sin));
> +
> + if (!__connman_inet_get_interface_address(index, AF_INET,
> + &sin.sin_addr)) {
> + /*
> + * If the interface contains an IP address, then check
> + * if it is the same as what we are trying to provision.
> + * If the addresses are the same, then do not init the
> + * interface because the it is already setup. We only do
> + * this check for IPv4 addresses.
> + */
This comment should go into the commit message (either this patch or
partly into the previous one.
> + char *address = inet_ntoa(sin.sin_addr);
> +
> + if (__connman_config_is_address_provisioned(address,
> + AF_INET)) {
> + DBG("Skip %s which is already provisioned "
> + "with %s", interfaces[i], address);
> + continue;
> + }
> + }
> +
> 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();
>
Patrik
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman