De-flakify sock_diag_test.
SockDestroyUdpTest.testClosesUdpSockets was failing a low percentage of the time because of two bugs: 1. When creating a UDP socket pair, we were connecting one socket to the other, but the other socket to iself. This made it possible for sockets on ::ffff:127.0.0.1 and ::1 to be bound to the same port, and: 2. The code that attempts to get a diag_msg for a given socket did not consider the fact that socket dumps, unlike operations that operate on a specific socket with a cookie, do not use the IP addresses in idiag_src and idiag_dst. This made it so that attempting to close a socket on [::1:1234 might have instead closed a different socket on [::ffff:127.0.0.1]:1234. Fix #1 by not doing the wrong thing, and fix #2 by using the inode number to ensure that FindSockInfoFromFd returns the requested socket. Also remove FindSockInfoFromReq, since it was only used once and was potentially misleading - while it only returns one socket, it might not return the one the caller expects. This allows us to tighten the code and ensure that operations that are supposed to return one socket only ever return one socket. Test: all_tests.sh passes on android-3.18. Bug: 31119353 Change-Id: I5d65e5a30c37490db516b5c6e730f89b5fea1b27
Loading
Please sign in to comment