Don't enumerate interfaces if no interfaces were found.

When dnsmasq receives a list of interfaces, but cannot find any
of them (e.g., because they have all been deleted), it enters the
default non-Android codepath where it listens on all interfaces.

Then, if any of the interfaces on the system is deleted while it
is starting up on all interfaces, it can enter a codepath where
it gets stuck for 20(!) seconds for DAD to complete on an
interface that no longer exists.

Bug: 152695206
Test: new test coverage in netd_integration_test
Merged-In: Id9289e5a22dddceb53782d75e3caa4f6a88c6fb1
Change-Id: Id9289e5a22dddceb53782d75e3caa4f6a88c6fb1
diff --git a/src/network.c b/src/network.c
index 34d821d..98b4f68 100644
--- a/src/network.c
+++ b/src/network.c
@@ -833,8 +833,11 @@
      * 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.
+     * Only do this if at least one interface was found. Otherwise,
+     * enumerate_interfaces will start listening on all interfaces on
+     * the system.
      */
-    if (!enumerate_interfaces()) {
+    if (daemon->if_names != NULL && !enumerate_interfaces()) {
         die(_("enumerate interfaces error in set_interfaces: %s"), NULL, EC_BADNET);
     }