Log and ignore unusable interfaces from update_ifaces
Bug: 30882741
Change-Id: I198607a293bb8da8d09330933065e0d10d52916b
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 @@
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 @@
}
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 @@
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) {