diff options
author | Erik Kline <ek@google.com> | 2016-09-13 02:17:10 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-09-13 02:17:10 +0000 |
commit | ca135c12abf76ce217b89c82d6040c2afa4f6648 (patch) | |
tree | 79015b132e2dff81d3f2ad0502f1f3f3b28bb26b | |
parent | d8c5b0ce0f39f7fc7601397f67102abbbb21902d (diff) | |
parent | 61b542ef379106207b419360c7f2761208e9dfbf (diff) | |
download | android_external_dnsmasq-ca135c12abf76ce217b89c82d6040c2afa4f6648.tar.gz android_external_dnsmasq-ca135c12abf76ce217b89c82d6040c2afa4f6648.tar.bz2 android_external_dnsmasq-ca135c12abf76ce217b89c82d6040c2afa4f6648.zip |
Log and ignore unusable interfaces from update_ifaces
am: 61b542ef37
Change-Id: I142bd84bd7d24e46ec5a5eca8aec5802fdcbfa0f
-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) { |