@@ -937,6 +937,50 @@ static void test_sockmap_same_sock(void)
937
937
test_sockmap_pass_prog__destroy (skel );
938
938
}
939
939
940
+ static void test_sockmap_skb_verdict_vsock_poll (void )
941
+ {
942
+ struct test_sockmap_pass_prog * skel ;
943
+ int err , map , conn , peer ;
944
+ struct bpf_program * prog ;
945
+ struct bpf_link * link ;
946
+ char buf = 'x' ;
947
+ int zero = 0 ;
948
+
949
+ skel = test_sockmap_pass_prog__open_and_load ();
950
+ if (!ASSERT_OK_PTR (skel , "open_and_load" ))
951
+ return ;
952
+
953
+ if (create_pair (AF_VSOCK , SOCK_STREAM , & conn , & peer ))
954
+ goto destroy ;
955
+
956
+ prog = skel -> progs .prog_skb_verdict ;
957
+ map = bpf_map__fd (skel -> maps .sock_map_rx );
958
+ link = bpf_program__attach_sockmap (prog , map );
959
+ if (!ASSERT_OK_PTR (link , "bpf_program__attach_sockmap" ))
960
+ goto close ;
961
+
962
+ err = bpf_map_update_elem (map , & zero , & conn , BPF_ANY );
963
+ if (!ASSERT_OK (err , "bpf_map_update_elem" ))
964
+ goto detach ;
965
+
966
+ if (xsend (peer , & buf , 1 , 0 ) != 1 )
967
+ goto detach ;
968
+
969
+ err = poll_read (conn , IO_TIMEOUT_SEC );
970
+ if (!ASSERT_OK (err , "poll" ))
971
+ goto detach ;
972
+
973
+ if (xrecv_nonblock (conn , & buf , 1 , 0 ) != 1 )
974
+ FAIL ("xrecv_nonblock" );
975
+ detach :
976
+ bpf_link__detach (link );
977
+ close :
978
+ xclose (conn );
979
+ xclose (peer );
980
+ destroy :
981
+ test_sockmap_pass_prog__destroy (skel );
982
+ }
983
+
940
984
void test_sockmap_basic (void )
941
985
{
942
986
if (test__start_subtest ("sockmap create_update_free" ))
@@ -997,4 +1041,6 @@ void test_sockmap_basic(void)
997
1041
test_skmsg_helpers_with_link (BPF_MAP_TYPE_SOCKMAP );
998
1042
if (test__start_subtest ("sockhash sk_msg attach sockhash helpers with link" ))
999
1043
test_skmsg_helpers_with_link (BPF_MAP_TYPE_SOCKHASH );
1044
+ if (test__start_subtest ("sockmap skb_verdict vsock poll" ))
1045
+ test_sockmap_skb_verdict_vsock_poll ();
1000
1046
}
0 commit comments