Hi Jukka,
> Turning off running interfaces that have IP address,
> causes all routes related to those interfaces to be
> removed by kernel. This way connman will get a fresh
> start without any extra and obsolete routes around.
> ---
> src/device.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/src/device.c b/src/device.c
> index ec732b8..47721bc 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -1186,6 +1186,51 @@ list:
> return FALSE;
> }
>
> +static void cleanup_devices()
> +{
function with no arguments are declared as function(void).
> + /*
> + * Check what interfaces are currently up and if connman is
> + * suppose to handle the interface, then cleanup the mess
> + * related to that interface. There might be weird routes etc
> + * that are related to that interface and that might confuse
> + * connmand. So in this case we just turn the interface down
> + * so that kernel removes routes/addresses automagically and
> + * then proceed the startup.
> + *
> + * Note that this cleanup must be done before rtnl/detect code
> + * has activated interface watches.
> + */
> +
> + char **interfaces;
> + int i;
> +
> + interfaces = __connman_inet_get_running_interfaces();
if (interfaces == NULL)
return;
> +
> + for (i = 0; interfaces != NULL && interfaces[i] != NULL; i++) {
And then remove the interfaces != NULL check here.
> + connman_bool_t filtered;
> + int index;
> +
> + filtered = __connman_device_isfiltered(interfaces[i]);
> + if (filtered == TRUE)
> + continue;
> +
> + index = connman_inet_ifindex(interfaces[i]);
> + if (index < 0)
> + continue;
> +
> + DBG("cleaning up %s index %d", interfaces[i], index);
> +
> + connman_inet_ifdown(index);
> +
> + /*
> + * ConnMan will turn the interface UP automagically so
I assume you mean automatically. While I like the magic part, but it is
not magic ;)
> + * no need to do it here.
> + */
> + }
> +
> + g_strfreev(interfaces);
> +}
> +
> int __connman_device_init(const char *device, const char *nodevice)
> {
> DBG("");
> @@ -1196,6 +1241,8 @@ int __connman_device_init(const char *device, const
> char *nodevice)
> if (nodevice != NULL)
> nodevice_filter = g_strsplit(nodevice, ",", -1);
>
> + cleanup_devices();
> +
> return 0;
> }
>
Regards
Marcel
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman