Android 9.0.0 Release 30 (PQ1A.190105.004)
Avoid spinning endlessly on packet socket errors

In the event the packet socket has an error, it is likely not cleared
and clatd can spin in a tight loop. This may happen when a network is
going down (ENETDOWN, ENETUNREACH, ...). Ordinarily the
ConnectivityService/Nat464Xlat/ClatdController control plane would
tear down clatd in this case.  However, if the control plane is
deadlocked, clatd will chew up CPU indefinitely.

This fix consists of detecting when poll() exits due to a socket error
and trying to clear the error by issuing a no-op recv() on the packet
socket and a 0-byte read() for the /dev/tun socket.

Test: manually, on a marlyn device (kernel 3.18.70)
Bug: 78602493
Change-Id: Ic23f999712a674df11e981a4314ad371e8d5fb6d
(cherry picked from commit 69dc60de5d53488a3c45737ec17b242d703d682b)
1 file changed