@@ -108,6 +108,35 @@ static void test_sockmap_create_update_free(enum bpf_map_type map_type)
108
108
close (s );
109
109
}
110
110
111
+ static void test_sockmap_vsock_delete_on_close (void )
112
+ {
113
+ int err , c , p , map ;
114
+ const int zero = 0 ;
115
+
116
+ err = create_pair (AF_VSOCK , SOCK_STREAM , & c , & p );
117
+ if (!ASSERT_OK (err , "create_pair(AF_VSOCK)" ))
118
+ return ;
119
+
120
+ map = bpf_map_create (BPF_MAP_TYPE_SOCKMAP , NULL , sizeof (int ),
121
+ sizeof (int ), 1 , NULL );
122
+ if (!ASSERT_GE (map , 0 , "bpf_map_create" )) {
123
+ close (c );
124
+ goto out ;
125
+ }
126
+
127
+ err = bpf_map_update_elem (map , & zero , & c , BPF_NOEXIST );
128
+ close (c );
129
+ if (!ASSERT_OK (err , "bpf_map_update" ))
130
+ goto out ;
131
+
132
+ err = bpf_map_update_elem (map , & zero , & p , BPF_NOEXIST );
133
+ ASSERT_OK (err , "after close(), bpf_map_update" );
134
+
135
+ out :
136
+ close (p );
137
+ close (map );
138
+ }
139
+
111
140
static void test_skmsg_helpers (enum bpf_map_type map_type )
112
141
{
113
142
struct test_skmsg_load_helpers * skel ;
@@ -987,6 +1016,8 @@ void test_sockmap_basic(void)
987
1016
test_sockmap_create_update_free (BPF_MAP_TYPE_SOCKMAP );
988
1017
if (test__start_subtest ("sockhash create_update_free" ))
989
1018
test_sockmap_create_update_free (BPF_MAP_TYPE_SOCKHASH );
1019
+ if (test__start_subtest ("sockmap vsock delete on close" ))
1020
+ test_sockmap_vsock_delete_on_close ();
990
1021
if (test__start_subtest ("sockmap sk_msg load helpers" ))
991
1022
test_skmsg_helpers (BPF_MAP_TYPE_SOCKMAP );
992
1023
if (test__start_subtest ("sockhash sk_msg load helpers" ))
0 commit comments