Never use a statically-configured IID on wifi.
Bug: 12111730
Change-Id: I062d81f2b65e6e89baae0f840cbd673f8051d523
diff --git a/config.c b/config.c
index de8a26f..b147868 100644
--- a/config.c
+++ b/config.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <cutils/config_utils.h>
+#include <netutils/ifc.h>
#include "config.h"
#include "dns64.h"
@@ -276,7 +277,7 @@
void config_generate_local_ipv6_subnet(struct in6_addr *interface_ip) {
int i;
- if (IN6_IS_ADDR_UNSPECIFIED(&Global_Clatd_Config.ipv6_host_id)) {
+ if (Global_Clatd_Config.use_dynamic_iid) {
/* Generate a random interface ID. */
gen_random_iid(interface_ip,
&Global_Clatd_Config.ipv4_local_subnet,
@@ -300,6 +301,7 @@
unsigned net_id) {
cnode *root = config_node("", "");
void *tmp_ptr = NULL;
+ unsigned flags;
if(!root) {
logmsg(ANDROID_LOG_FATAL,"out of memory");
@@ -358,6 +360,17 @@
if (!config_item_ip6(root, "ipv6_host_id", "::", &Global_Clatd_Config.ipv6_host_id))
goto failed;
+ /* In order to prevent multiple devices attempting to use the same clat address, never use a
+ statically-configured interface ID on a broadcast interface such as wifi. */
+ if (!IN6_IS_ADDR_UNSPECIFIED(&Global_Clatd_Config.ipv6_host_id)) {
+ ifc_init();
+ ifc_get_info(Global_Clatd_Config.default_pdp_interface, NULL, NULL, &flags);
+ ifc_close();
+ Global_Clatd_Config.use_dynamic_iid = (flags & IFF_BROADCAST) != 0;
+ } else {
+ Global_Clatd_Config.use_dynamic_iid = 1;
+ }
+
return 1;
failed: