[PATCH] service: Look up interface name from index

patrik.flykt at linux.intel.com patrik.flykt at linux.intel.com
Thu Nov 15 03:57:04 PST 2012


From: Patrik Flykt <patrik.flykt at linux.intel.com>

When disconnecting, both ipconfigs have been removed from the service.
Look up the interface name from the interface index instead in order
to remove the nameservers.
---
 src/service.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/service.c b/src/service.c
index 7381af3..1e9c825 100644
--- a/src/service.c
+++ b/src/service.c
@@ -930,14 +930,15 @@ static void remove_searchdomains(struct connman_service *service,
 
 static void update_nameservers(struct connman_service *service)
 {
-	const char *ifname;
+	int index;
+	char *ifname;
 
-	if (service->ipconfig_ipv4)
-		ifname = __connman_ipconfig_get_ifname(service->ipconfig_ipv4);
-	else if (service->ipconfig_ipv6)
-		ifname = __connman_ipconfig_get_ifname(service->ipconfig_ipv6);
-	else
-		ifname = NULL;
+	index = __connman_service_get_index(service);
+	ifname = connman_inet_ifname(index);
+
+	DBG("service %p index %d ifname %s ipconfig ipv4 %p ipv6 %p",
+			service, index, ifname,
+			service->ipconfig_ipv4, service->ipconfig_ipv6);
 
 	if (ifname == NULL)
 		return;
@@ -947,10 +948,12 @@ static void update_nameservers(struct connman_service *service)
 	case CONNMAN_SERVICE_STATE_IDLE:
 	case CONNMAN_SERVICE_STATE_ASSOCIATION:
 	case CONNMAN_SERVICE_STATE_CONFIGURATION:
+		g_free(ifname);
 		return;
 	case CONNMAN_SERVICE_STATE_FAILURE:
 	case CONNMAN_SERVICE_STATE_DISCONNECT:
 		connman_resolver_remove_all(ifname);
+		g_free(ifname);
 		return;
 	case CONNMAN_SERVICE_STATE_READY:
 	case CONNMAN_SERVICE_STATE_ONLINE:
@@ -995,6 +998,7 @@ static void update_nameservers(struct connman_service *service)
 	} else if (service->domainname != NULL)
 		connman_resolver_append(ifname, service->domainname, NULL);
 
+	g_free(ifname);
 	connman_resolver_flush();
 }
 
-- 
1.7.10.4




More information about the connman mailing list