From: Daniel Wagner <[email protected]>
The statistic counters should be updated as soon the
interface enters LOWER_UP state ('cable' connected).
Therefore we do not depend on the state of the
Service object, which fixes also the shortcoming
we have currently with private connections. Those
services do not enter the ONLINE state.
At least for ethernet the lower_up callback
has not been called because the service was
createt 'too late'.
---
src/ipconfig.c | 23 +++++++++++++++++++++++
src/service.c | 14 +++++++++-----
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 51c4619..a7d5d32 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1017,6 +1017,8 @@ int __connman_ipconfig_clear_address(struct
connman_ipconfig *ipconfig)
int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig)
{
struct connman_ipdevice *ipdevice;
+ gboolean up = FALSE, down = FALSE;
+ gboolean lower_up = FALSE, lower_down = FALSE;
DBG("ipconfig %p", ipconfig);
@@ -1043,6 +1045,27 @@ int __connman_ipconfig_enable(struct connman_ipconfig
*ipconfig)
ipconfig_list = g_list_append(ipconfig_list, ipconfig);
+ if (ipdevice->flags & IFF_UP)
+ up = TRUE;
+ else
+ down = TRUE;
+
+ if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) ==
+ (IFF_RUNNING | IFF_LOWER_UP))
+ lower_up = TRUE;
+ else if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) == 0)
+ lower_down = TRUE;
+
+ if (up == TRUE && ipconfig->ops->up)
+ ipconfig->ops->up(ipconfig);
+ if (lower_up == TRUE && ipconfig->ops->lower_up)
+ ipconfig->ops->lower_up(ipconfig);
+
+ if (lower_down == TRUE && ipconfig->ops->lower_down)
+ ipconfig->ops->lower_down(ipconfig);
+ if (down == TRUE && ipconfig->ops->down)
+ ipconfig->ops->down(ipconfig);
+
return 0;
}
diff --git a/src/service.c b/src/service.c
index fd694e8..c2c2bc3 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2062,8 +2062,6 @@ int __connman_service_indicate_state(struct
connman_service *service,
__connman_notifier_connect(service->type);
- __connman_service_stats_start(service);
-
default_changed();
} else if (state == CONNMAN_SERVICE_STATE_DISCONNECT) {
__connman_location_finish(service);
@@ -2074,9 +2072,6 @@ int __connman_service_indicate_state(struct
connman_service *service,
dns_changed(service);
__connman_notifier_disconnect(service->type);
-
- __connman_service_stats_stop(service);
- __connman_storage_save_service(service);
}
if (state == CONNMAN_SERVICE_STATE_FAILURE) {
@@ -2639,12 +2634,21 @@ static void service_down(struct connman_ipconfig
*ipconfig)
static void service_lower_up(struct connman_ipconfig *ipconfig)
{
+ struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+
connman_info("%s lower up", connman_ipconfig_get_ifname(ipconfig));
+
+ __connman_service_stats_start(service);
}
static void service_lower_down(struct connman_ipconfig *ipconfig)
{
+ struct connman_service *service = connman_ipconfig_get_data(ipconfig);
+
connman_info("%s lower down", connman_ipconfig_get_ifname(ipconfig));
+
+ __connman_service_stats_stop(service);
+ __connman_storage_save_service(service);
}
static void service_ip_bound(struct connman_ipconfig *ipconfig)
--
1.6.6.1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman