diff options
author | Erik Kline <ek@google.com> | 2016-09-13 02:28:06 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-09-13 02:28:06 +0000 |
commit | 3293d082ff5208a54963264cc34e3065279c11ca (patch) | |
tree | 2624be2824821e0e8edf1dfec14abf59657b63ee | |
parent | 2b2acae0474f18149e5d696aa7aba74d192f1fe6 (diff) | |
parent | ca135c12abf76ce217b89c82d6040c2afa4f6648 (diff) | |
download | dnsmasq-3293d082ff5208a54963264cc34e3065279c11ca.tar.gz |
Log and ignore unusable interfaces from update_ifaces am: 61b542ef37
am: ca135c12ab
Change-Id: I95537cd55d041f544f397ffe756a31f3c26a77e0
-rwxr-xr-x | src/dnsmasq.c | 4 | ||||
-rwxr-xr-x | src/network.c | 14 |
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) { |