selftests: net: reuseport_addr_any: report epoll_wait timeouts honestly
Subsystems (3)
PATCH 1/1 selftests: net: reuseport_addr_any: report epoll_wait timeouts honestly
receive_once() waits 3ms for a packet but only checks for errors (i < 0). On timeout (i == 0) it falls through and uses ev.data.fd uninitialized. recv() on a garbage fd fails with a misleading "failed to recv" (or worse, blocks or returns a bogus fd). Report the timeout for what it is; errnum 0, since epoll_wait sets no errno on timeout.
--- tools/testing/selftests/net/reuseport_addr_any.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/net/reuseport_addr_any.c +2 -0
@@ -155,6 +155,8 @@ static int receive_once(int epfd, int proto) i =epoll_wait (epfd, &ev,1 ,3 );if (i <0 )error (1 , errno,"epoll_wait failed" ); +if (i ==0 ) +error (1 ,0 ,"epoll_wait timed out waiting for packet" );if (proto ==SOCK_STREAM ) { fd =accept (ev.data.fd,NULL ,NULL );
Signature · 1 line
2.43.0
Quoted 28 lines · Omokefe Emmanuel Onanaroghene
receive_once()waits 3ms for a packet but only checks for errors (i < 0). On timeout (i == 0) it falls through and uses ev.data.fd uninitialized.recv()on a garbage fd fails with a misleading "failed to recv" (or worse, blocks or returns a bogus fd). Report the timeout for what it is; errnum 0, sinceepoll_waitsets no errno on timeout.Signed-off-by Omokefe Emmanuel Onanaroghene <[email protected]>--- tools/testing/selftests/net/reuseport_addr_any.c | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/net/reuseport_addr_any.c +2
-0@@ -155,6 +155,8 @@ static int receive_once(int epfd, int proto) i =epoll_wait (epfd, &ev,1 ,3 );if (i <0 )error (1 , errno,"epoll_wait failed" ); +if (i ==0 ) +error (1 ,0 ,"epoll_wait timed out waiting for packet" );if (proto ==SOCK_STREAM ) { fd =accept (ev.data.fd,NULL ,NULL );Signature · 1 line
2.43.0