summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2016-08-17 15:10:06 +0900
committerErik Kline <ek@google.com>2016-09-12 18:17:03 +0900
commit61b542ef379106207b419360c7f2761208e9dfbf (patch)
tree79015b132e2dff81d3f2ad0502f1f3f3b28bb26b
parentd8c5b0ce0f39f7fc7601397f67102abbbb21902d (diff)
downloadandroid_external_dnsmasq-61b542ef379106207b419360c7f2761208e9dfbf.tar.gz
android_external_dnsmasq-61b542ef379106207b419360c7f2761208e9dfbf.tar.bz2
android_external_dnsmasq-61b542ef379106207b419360c7f2761208e9dfbf.zip
Log and ignore unusable interfaces from update_ifaces
Bug: 30882741 Change-Id: I198607a293bb8da8d09330933065e0d10d52916b
-rwxr-xr-xsrc/dnsmasq.c4
-rwxr-xr-xsrc/network.c14
2 files changed, 15 insertions, 3 deletions
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index a1b6578..24e7055 100755
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -1013,14 +1013,14 @@ static int check_android_listeners(fd_set *set) {
set_servers(params);
check_servers();
} else {
- my_syslog(LOG_ERR, _("Malformatted msg '%s'"), current_cmd);
+ my_syslog(LOG_ERR, _("Misformatted msg '%s'"), current_cmd);
retcode = -1;
}
} else if (!strcmp(cmd, "update_ifaces")) {
if (params != NULL) {
set_interfaces(params);
} else {
- my_syslog(LOG_ERR, _("Malformatted msg '%s'"), current_cmd);
+ my_syslog(LOG_ERR, _("Misformatted msg '%s'"), current_cmd);
retcode = -1;
}
} else {
diff --git a/src/network.c b/src/network.c
index 2df8c75..f2c3073 100755
--- a/src/network.c
+++ b/src/network.c
@@ -983,6 +983,12 @@ void set_interfaces(const char *interfaces)
}
strncpy(s, interfaces, sizeof(s));
while((interface = strsep(&next, SEPARATOR))) {
+ if (!if_nametoindex(interface)) {
+ my_syslog(LOG_ERR,
+ _("interface given in %s: '%s' has no ifindex; ignoring"),
+ __FUNCTION__, interface);
+ continue;
+ }
if_tmp = safe_malloc(sizeof(struct iname));
memset(if_tmp, 0, sizeof(struct iname));
if ((if_tmp->name = strdup(interface)) == NULL) {
@@ -992,15 +998,21 @@ void set_interfaces(const char *interfaces)
daemon->if_names = if_tmp;
}
+ /*
+ * Enumerate IP addresses (via RTM_GETADDR), adding IP entries to
+ * daemon->interfaces for interface names listed in daemon->if_names.
+ * The sockets are created by the create_bound_listener call below.
+ */
if (!enumerate_interfaces()) {
die(_("enumerate interfaces error in set_interfaces: %s"), NULL, EC_BADNET);
}
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) {
if (if_tmp->name && !if_tmp->used) {
- die(_("unknown interface given %s in set_interfaces: %s"), if_tmp->name, EC_BADNET);
+ my_syslog(LOG_ERR, _("unknown interface given %s in set_interfaces()"), if_tmp->name);
}
}
+
/* success! - setup to free the old */
/* check for any that have been removed */
for (old_iface = prev_interfaces; old_iface; old_iface=old_iface->next) {