[PATCH 4/4] ipv4: set nameserver via service.

Forest Bond forest at alittletooquiet.net
Thu Apr 22 12:56:20 PDT 2010


Rather than make resolver calls directly, the ipv4 driver now modifies the
nameservers associated with the service.  This allows DHCP-provided nameservers
to be selectively overridden.
---
 src/ipv4.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/ipv4.c b/src/ipv4.c
index fa56078..fb88749 100644
--- a/src/ipv4.c
+++ b/src/ipv4.c
@@ -40,8 +40,7 @@ struct connman_ipv4 {
 	struct in_addr broadcast;
 };
 
-static int set_ipv4(struct connman_element *element,
-			struct connman_ipv4 *ipv4, const char *nameserver)
+static int set_ipv4(struct connman_element *element, struct connman_ipv4 *ipv4)
 {
 	struct ifreq ifr;
 	struct sockaddr_in addr;
@@ -95,11 +94,6 @@ static int set_ipv4(struct connman_element *element,
 
 	close(sk);
 
-	if (nameserver == NULL)
-		connman_error("No nameserver for %s defined", ifr.ifr_name);
-	else
-		connman_resolver_append(ifr.ifr_name, NULL, nameserver);
-
 	return 0;
 }
 
@@ -125,8 +119,6 @@ static int clear_ipv4(struct connman_element *element)
 
 	DBG("ifname %s", ifr.ifr_name);
 
-	connman_resolver_remove_all(ifr.ifr_name);
-
 	memset(&addr, 0, sizeof(addr));
 	addr.sin_family = AF_INET;
 	addr.sin_addr.s_addr = INADDR_ANY;
@@ -172,6 +164,8 @@ static char *index2name(int index)
 
 static int ipv4_probe(struct connman_element *element)
 {
+	struct connman_service *service;
+	GList *nameservers = NULL;
 	struct connman_element *connection;
 	struct connman_ipv4 ipv4;
 	const char *address = NULL, *netmask = NULL, *broadcast = NULL;
@@ -207,7 +201,11 @@ static int ipv4_probe(struct connman_element *element)
 		ipv4.broadcast.s_addr = ipv4.address.s_addr |
 						~ipv4.netmask.s_addr;
 
-	set_ipv4(element, &ipv4, nameserver);
+	set_ipv4(element, &ipv4);
+
+	service = __connman_element_get_service(element);
+	nameservers = g_list_append(nameservers, (gpointer)nameserver);
+	__connman_service_replace_nameservers(service, nameservers);
 
 	connman_timeserver_append(timeserver);
 
-- 
1.6.0.4



More information about the connman mailing list