summaryrefslogtreecommitdiff
path: root/src/rtnl.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-21 16:25:11 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-22 13:23:56 +0200
commit99e49dd2add20aecafe79b24effb4b87353449f9 (patch)
tree921fa679315338259ce489bb03c96ccd172aa476 /src/rtnl.c
parent86f21518b2ad016df155610524d9fc3f72018861 (diff)
downloadconnman-99e49dd2add20aecafe79b24effb4b87353449f9.tar.gz
connman-99e49dd2add20aecafe79b24effb4b87353449f9.tar.bz2
connman-99e49dd2add20aecafe79b24effb4b87353449f9.zip
core: Use interface index instead of interface name
Service and network code use only interface indexes. Convert the rest of the code using interface names to use interface indexes instead. The files affected are: include/resolver.h src/connman.h src/dnsproxy.c src/resolver.c src/rtnl.c src/service.c src/tethering.c As the network and service code used interface indexes, the interface name had to be looked up via a SIOCGIFNAME ioctl when needed. If a service was removed due to the interface and network being taken down, the lookup wouldn't work. This caused DNS servers to be left behind with broken sockets since removing the DNS servers was done using the interface name.
Diffstat (limited to 'src/rtnl.c')
-rw-r--r--src/rtnl.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/rtnl.c b/src/rtnl.c
index 5f3fe155..915654bc 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -611,11 +611,7 @@ static void process_newaddr(unsigned char family, unsigned char prefixlen,
* have now properly configured interface with proper
* autoconfigured address.
*/
- char *interface = connman_inet_ifname(index);
-
- __connman_resolver_redo_servers(interface);
-
- g_free(interface);
+ __connman_resolver_redo_servers(index);
}
}
@@ -1195,7 +1191,7 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
struct in6_addr *servers = NULL;
int i, nr_servers = 0;
int msglen = msg->nduseropt_opts_len;
- char *interface;
+ int index;
DBG("family %d index %d len %d type %d code %d",
msg->nduseropt_family, msg->nduseropt_ifindex,
@@ -1207,8 +1203,8 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
msg->nduseropt_icmp_code != 0)
return;
- interface = connman_inet_ifname(msg->nduseropt_ifindex);
- if (!interface)
+ index = msg->nduseropt_ifindex;
+ if (index < 0)
return;
for (opt = (void *)&msg[1];
@@ -1229,7 +1225,7 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
sizeof(buf)))
continue;
- connman_resolver_append_lifetime(interface,
+ connman_resolver_append_lifetime(index,
NULL, buf, lifetime);
}
@@ -1238,13 +1234,12 @@ static void rtnl_newnduseropt(struct nlmsghdr *hdr)
domains = rtnl_nd_opt_dnssl(opt, &lifetime);
for (i = 0; domains != NULL && domains[i] != NULL; i++)
- connman_resolver_append_lifetime(interface,
+ connman_resolver_append_lifetime(index,
domains[i], NULL, lifetime);
}
}
g_free(domains);
- g_free(interface);
}
static const char *type2string(uint16_t type)