summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-03-14 17:28:52 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-03-19 13:08:41 +0200
commitecefd0ab5b5d00db39ac999c18173c31164a448c (patch)
treea17627e0ad10711dee2d49f786100d44524fe428
parent601b74f0a26927c28627401f1ad46a790a2da330 (diff)
downloadconnman-ecefd0ab5b5d00db39ac999c18173c31164a448c.tar.gz
connman-ecefd0ab5b5d00db39ac999c18173c31164a448c.tar.bz2
connman-ecefd0ab5b5d00db39ac999c18173c31164a448c.zip
service: Allow removing only certain type nameservers
When nameserver are removed by __connman_connection_gateway_remove() then remove only certain type nameserver (IPv4 or IPv6). This is needed so that we do not loose IPv4 routes if only IPv6 nameservers are to be removed. This is needed when there are multiple connected services.
-rw-r--r--src/connection.c2
-rw-r--r--src/connman.h3
-rw-r--r--src/service.c29
3 files changed, 23 insertions, 11 deletions
diff --git a/src/connection.c b/src/connection.c
index fde8f799..545b59f4 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -728,7 +728,7 @@ void __connman_connection_gateway_remove(struct connman_service *service,
else
do_ipv4 = do_ipv6 = TRUE;
- __connman_service_nameserver_del_routes(service);
+ __connman_service_nameserver_del_routes(service, type);
data = g_hash_table_lookup(gateway_hash, service);
if (data == NULL)
diff --git a/src/connman.h b/src/connman.h
index 86096149..617ad328 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -583,7 +583,8 @@ int __connman_service_nameserver_remove(struct connman_service *service,
void __connman_service_nameserver_clear(struct connman_service *service);
void __connman_service_nameserver_add_routes(struct connman_service *service,
const char *gw);
-void __connman_service_nameserver_del_routes(struct connman_service *service);
+void __connman_service_nameserver_del_routes(struct connman_service *service,
+ enum connman_ipconfig_type type);
int __connman_service_timeserver_append(struct connman_service *service,
const char *timeserver);
int __connman_service_timeserver_remove(struct connman_service *service,
diff --git a/src/service.c b/src/service.c
index 77876365..6c8cccc1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -966,7 +966,8 @@ static void nameserver_add_routes(int index, char **nameservers,
}
}
-static void nameserver_del_routes(int index, char **nameservers)
+static void nameserver_del_routes(int index, char **nameservers,
+ enum connman_ipconfig_type type)
{
int i, ret, family;
struct addrinfo hints;
@@ -985,11 +986,18 @@ static void nameserver_del_routes(int index, char **nameservers)
else
family = addr->ai_family;
- if (family == AF_INET)
- connman_inet_del_host_route(index, nameservers[i]);
- else if (family == AF_INET6)
- connman_inet_del_ipv6_host_route(index,
+ switch (family) {
+ case AF_INET:
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV6)
+ connman_inet_del_host_route(index,
nameservers[i]);
+ break;
+ case AF_INET6:
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV4)
+ connman_inet_del_ipv6_host_route(index,
+ nameservers[i]);
+ break;
+ }
freeaddrinfo(addr);
}
@@ -1026,7 +1034,8 @@ void __connman_service_nameserver_add_routes(struct connman_service *service,
}
}
-void __connman_service_nameserver_del_routes(struct connman_service *service)
+void __connman_service_nameserver_del_routes(struct connman_service *service,
+ enum connman_ipconfig_type type)
{
int index = -1;
@@ -1039,9 +1048,10 @@ void __connman_service_nameserver_del_routes(struct connman_service *service)
index = connman_provider_get_index(service->provider);
if (service->nameservers_config != NULL)
- nameserver_del_routes(index, service->nameservers_config);
+ nameserver_del_routes(index, service->nameservers_config,
+ type);
else if (service->nameservers != NULL)
- nameserver_del_routes(index, service->nameservers);
+ nameserver_del_routes(index, service->nameservers, type);
}
static struct connman_stats *stats_get(struct connman_service *service)
@@ -2672,7 +2682,8 @@ static DBusMessage *set_property(DBusConnection *conn,
gw = __connman_ipconfig_get_gateway_from_index(index);
if (gw && strlen(gw))
- __connman_service_nameserver_del_routes(service);
+ __connman_service_nameserver_del_routes(service,
+ CONNMAN_IPCONFIG_TYPE_ALL);
dbus_message_iter_recurse(&value, &entry);