On Wed, Jan 13, 2016 at 4:57 AM, Patrik Flykt <patrik.flykt@linux.intel.com> wrote:
When the default route is removed, it is more than likely that the
corresponding service cannot be in state online anymore. Downgrade
the affected service state. This in turn will trigger a new online
check and resolve the state back to online if at all possible.
---

This might fix the issue with dhcp_failure() reported by Naveen Singh.

Please test!

       Patrik


src/service.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index abf0899..3fa5ae5 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6380,12 +6380,27 @@ static void service_ip_release(struct connman_ipconfig *ipconfig,
        settings_changed(service, ipconfig);
 }

-static void service_route_changed(struct connman_ipconfig *ipconfig,
+static void service_defaultroute_set(struct connman_ipconfig *ipconfig,
                                const char *ifname)
 {
        struct connman_service *service = __connman_ipconfig_get_data(ipconfig);

-       DBG("%s route changed", ifname);
+       DBG("service %p %s defaultroute set", service, ifname);
+
+       settings_changed(service, ipconfig);
+}
+
+static void service_defaultroute_unset(struct connman_ipconfig *ipconfig,
+                               const char *ifname)
+{
+       struct connman_service *service = __connman_ipconfig_get_data(ipconfig);
+
+       DBG("service %p %s defaultroute unset", service, ifname);
+
+       if (service->state == CONNMAN_SERVICE_STATE_ONLINE)
+               __connman_service_ipconfig_indicate_state(service,
+                               CONNMAN_SERVICE_STATE_READY,
+                               __connman_ipconfig_get_config_type(ipconfig));
When the default route is removed why we are changing the state to READY. Should not it be CONFIGURE? 

        settings_changed(service, ipconfig);
 }
@@ -6397,8 +6412,8 @@ static const struct connman_ipconfig_ops service_ops = {
        .lower_down     = service_lower_down,
        .ip_bound       = service_ip_bound,
        .ip_release     = service_ip_release,
-       .route_set      = service_route_changed,
-       .route_unset    = service_route_changed,
+       .route_set      = service_defaultroute_set,
+       .route_unset    = service_defaultroute_unset,
 };

 static struct connman_ipconfig *create_ip4config(struct connman_service *service,

In stead of changing this why do not we use service_ip_bound and service_ip_release to do the specific state transitions. These functions are the entry point. Right now the service state transition to READY is happening from  __connman_connection_gateway_add which we should remove. This is the sequence that I am proposing:
1) In service_ip_bound transition from configuration to ready
2) In service_ip_release transition from ready to configuration

There is a small check we need to perform specially when we are going from 169 address to (DHCP) address. We would like to release the link local IP first if it is currently in the link local state and then set the IP. This would allow service_ip_release to be called first and then service_ip_bound. 

Regards
Naveen

--
2.1.4