Skip to content

Commit 36fffbb

Browse files
mmhalKernel Patches Daemon
authored andcommitted
selftests/bpf: sockmap_redir: Fix OOB handling
In some test cases, OOB packets might have been left unread. Flush them out and introduce additional checks. Signed-off-by: Michal Luczaj <[email protected]>
1 parent c00239e commit 36fffbb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/testing/selftests/bpf/prog_tests/sockmap_redir.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
184184
FAIL_ERRNO("unsupported: packet missing, retval=%zd", n);
185185
}
186186

187+
/* af_unix send("ab", MSG_OOB) spits out 2 packets, but only the latter
188+
* ("b") is designated OOB. If the peer is in a sockmap, the OOB packet
189+
* will be silently dropped. Otherwise OOB stays in the queue and should
190+
* be taken care of.
191+
*/
192+
if ((send_flags & MSG_OOB) && !pass && !drop) {
193+
errno = 0;
194+
n = recv_timeout(sd_peer, &recv_buf, 1, MSG_OOB, IO_TIMEOUT_SEC);
195+
/* Ignore unsupported sk_msg error */
196+
if (n != 1 && errno != EOPNOTSUPP)
197+
FAIL_ERRNO("recv(OOB): retval=%zd", n);
198+
}
199+
187200
/* Ensure queues are empty */
188201
fail_recv("bpf.recv(sd_send)", sd_send, 0);
189202
if (sd_in != sd_send)
@@ -192,6 +205,9 @@ static void handle_unsupported(int sd_send, int sd_peer, int sd_in, int sd_out,
192205
fail_recv("bpf.recv(sd_out)", sd_out, 0);
193206
if (sd_recv != sd_out)
194207
fail_recv("bpf.recv(sd_recv)", sd_recv, 0);
208+
209+
fail_recv("recv(sd_peer, OOB)", sd_peer, MSG_OOB);
210+
fail_recv("recv(sd_out, OOB)", sd_out, MSG_OOB);
195211
}
196212

197213
static void test_send_redir_recv(int sd_send, int send_flags, int sd_peer,

0 commit comments

Comments
 (0)