I don't think it's AF_UNIX alone, I'm getting select() timeout for all family: ./test_progs:udp_redir_to_connected:1775: ingress: read: Timer expired udp_redir_to_connected:FAIL:1775 #120/36 sockmap_listen/sockmap IPv4 test_udp_redir:FAIL ./test_progs:inet_unix_redir_to_connected:1865: ingress: read: Timer expired inet_unix_redir_to_connected:FAIL:1865 ./test_progs:inet_unix_redir_to_connected:1865: ingress: read: Timer expired inet_unix_redir_to_connected:FAIL:1865 ./test_progs:unix_inet_redir_to_connected:1947: ingress: read: Timer expired unix_inet_redir_to_connected:FAIL:1947 ./test_progs:unix_inet_redir_to_connected:1947: ingress: read: Timer expired unix_inet_redir_to_connected:FAIL:1947 ... ./test_progs:udp_redir_to_connected:1775: ingress: read: Timer expired udp_redir_to_connected:FAIL:1775 #120/73 sockmap_listen/sockmap IPv6 test_udp_redir:FAIL ./test_progs:inet_unix_redir_to_connected:1865: ingress: read: Timer expired inet_unix_redir_to_connected:FAIL:1865 ./test_progs:inet_unix_redir_to_connected:1865: ingress: read: Timer expired inet_unix_redir_to_connected:FAIL:1865 ./test_progs:unix_inet_redir_to_connected:1947: ingress: read: Timer expired unix_inet_redir_to_connected:FAIL:1947 ./test_progs:unix_inet_redir_to_connected:1947: ingress: read: Timer expired unix_inet_redir_to_connected:FAIL:1947 #120/74 sockmap_listen/sockmap IPv6 test_udp_unix_redir:FAIL ./test_progs:unix_redir_to_connected:1605: ingress: read: Timer expired unix_redir_to_connected:FAIL:1605 #120/75 sockmap_listen/sockmap Unix test_unix_redir:FAIL ./test_progs:unix_redir_to_connected:1605: ingress: read: Timer expired unix_redir_to_connected:FAIL:1605 On Thu, Aug 26, 2021 at 12:07 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Thu, Aug 26, 2021 at 11:18 AM sunyucong@xxxxxxxxx > <sunyucong@xxxxxxxxx> wrote: > > > > Reporting back: I tried a select() based approach, (as attached below) > > but unfortunately it doesn't seem to work. During testing, I am > > always getting full timeout errors as the socket never seems to become > > ready to read(). My guess is that this has something to do with the > > sockets being created through sockpair() , but I am unable to confirm. > > > > On the other hand, the previous patch approach works perfectly fine, I > > would still like to request to apply that instead. > > Ok. Applied your earlier patch, but it's a short term workaround. > select() should work for af_unix. > I suspect something got broken with the redirect. > Cong, Jiang, > could you please take a look ? > > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c > > b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c > > index 5c5979046523..247e8b7a6911 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c > > +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c > > @@ -949,7 +949,6 @@ static void redir_to_connected(int family, int > > sotype, int sock_mapfd, > > int err, n; > > u32 key; > > char b; > > - int retries = 100; > > > > zero_verdict_count(verd_mapfd); > > > > @@ -1002,15 +1001,12 @@ static void redir_to_connected(int family, int > > sotype, int sock_mapfd, > > goto close_peer1; > > if (pass != 1) > > FAIL("%s: want pass count 1, have %d", log_prefix, pass); > > -again: > > + > > + if (poll_read(c0, IO_TIMEOUT_SEC)) > > + FAIL_ERRNO("%s: read", log_prefix); > > n = read(c0, &b, 1); > > - if (n < 0) { > > - if (errno == EAGAIN && retries--) { > > - usleep(1000); > > - goto again; > > - } > > + if (n < 0) > > FAIL_ERRNO("%s: read", log_prefix); > > - } > > if (n == 0) > > FAIL("%s: incomplete read", log_prefix); > > > > @@ -1571,7 +1567,6 @@ static void unix_redir_to_connected(int sotype, > > int sock_mapfd, > > const char *log_prefix = redir_mode_str(mode); > > int c0, c1, p0, p1; > > unsigned int pass; > > - int retries = 100; > > int err, n; > > int sfd[2]; > > u32 key; > > @@ -1606,15 +1601,11 @@ static void unix_redir_to_connected(int > > sotype, int sock_mapfd, > > if (pass != 1) > > FAIL("%s: want pass count 1, have %d", log_prefix, pass); > > > > -again: > > + if (poll_read(mode == REDIR_INGRESS ? p0 : c0, IO_TIMEOUT_SEC)) > > + FAIL_ERRNO("%s: read", log_prefix); > > n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1); > > - if (n < 0) { > > - if (errno == EAGAIN && retries--) { > > - usleep(1000); > > - goto again; > > - } > > + if (n < 0) > > FAIL_ERRNO("%s: read", log_prefix); > > - } > > if (n == 0) > > FAIL("%s: incomplete read", log_prefix); > > > > @@ -1748,7 +1739,6 @@ static void udp_redir_to_connected(int family, > > int sock_mapfd, int verd_mapfd, > > const char *log_prefix = redir_mode_str(mode); > > int c0, c1, p0, p1; > > unsigned int pass; > > - int retries = 100; > > int err, n; > > u32 key; > > char b; > > @@ -1781,15 +1771,11 @@ static void udp_redir_to_connected(int family, > > int sock_mapfd, int verd_mapfd, > > if (pass != 1) > > FAIL("%s: want pass count 1, have %d", log_prefix, pass); > > > > -again: > > + if (poll_read(mode == REDIR_INGRESS ? p0 : c0, IO_TIMEOUT_SEC * 10)) > > + FAIL_ERRNO("%s: read", log_prefix); > > n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1); > > - if (n < 0) { > > - if (errno == EAGAIN && retries--) { > > - usleep(1000); > > - goto again; > > - } > > + if (n < 0) > > FAIL_ERRNO("%s: read", log_prefix); > > - } > > if (n == 0) > > FAIL("%s: incomplete read", log_prefix); > > > > @@ -1841,7 +1827,6 @@ static void inet_unix_redir_to_connected(int > > family, int type, int sock_mapfd, > > const char *log_prefix = redir_mode_str(mode); > > int c0, c1, p0, p1; > > unsigned int pass; > > - int retries = 100; > > int err, n; > > int sfd[2]; > > u32 key; > > @@ -1876,15 +1861,11 @@ static void inet_unix_redir_to_connected(int > > family, int type, int sock_mapfd, > > if (pass != 1) > > FAIL("%s: want pass count 1, have %d", log_prefix, pass); > > > > -again: > > + if (poll_read(mode == REDIR_INGRESS ? p0 : c0, IO_TIMEOUT_SEC)) > > + FAIL_ERRNO("%s: read", log_prefix); > > n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1); > > - if (n < 0) { > > - if (errno == EAGAIN && retries--) { > > - usleep(1000); > > - goto again; > > - } > > + if (n < 0) > > FAIL_ERRNO("%s: read", log_prefix); > > - } > > if (n == 0) > > FAIL("%s: incomplete read", log_prefix); > > > > @@ -1932,7 +1913,6 @@ static void unix_inet_redir_to_connected(int > > family, int type, int sock_mapfd, > > int sfd[2]; > > u32 key; > > char b; > > - int retries = 100; > > > > zero_verdict_count(verd_mapfd); > > > > @@ -1963,15 +1943,11 @@ static void unix_inet_redir_to_connected(int > > family, int type, int sock_mapfd, > > if (pass != 1) > > FAIL("%s: want pass count 1, have %d", log_prefix, pass); > > > > -again: > > + if (poll_read(mode == REDIR_INGRESS ? p0 : c0, IO_TIMEOUT_SEC)) > > + FAIL_ERRNO("%s: read", log_prefix); > > n = read(mode == REDIR_INGRESS ? p0 : c0, &b, 1); > > - if (n < 0) { > > - if (errno == EAGAIN && retries--) { > > - usleep(1000); > > - goto again; > > - } > > + if (n < 0) > > FAIL_ERRNO("%s: read", log_prefix); > > - } > > if (n == 0) > > FAIL("%s: incomplete read", log_prefix);