Call read on any event, not just on POLLIN.
The main clatd event loop calls poll() in a loop, but reads only
from FDs that have POLLIN set. This causes it to get into an
infinite loop if one of the fds has POLLERR set.
Instead, read from all fds that have reported events. The read
causes the kernel to return the error to userspace and clear the
socket error flag, and poll starts working correctly after that.
Bug: 17183471
Bug: 17186694
Change-Id: Ie25853e0d60c077d2478b3e5154946e201f96dca
diff --git a/clatd.h b/clatd.h
index 0f4809d..ca7369b 100644
--- a/clatd.h
+++ b/clatd.h
@@ -25,6 +25,8 @@
#define PACKETLEN (MAXMTU+sizeof(struct tun_pi))
#define CLATD_VERSION "1.3"
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
// how frequently (in seconds) to poll for an address change while traffic is passing
#define INTERFACE_POLL_FREQUENCY 30