@@ -305,6 +305,80 @@ static void test_sockmap_ktls_tx_cork(int family, int sotype, bool push)
305
305
test_sockmap_ktls__destroy (skel );
306
306
}
307
307
308
+ static void test_sockmap_ktls_tx_no_buf (int family , int sotype , bool push )
309
+ {
310
+ int c = 0 , p = 0 , one = 1 , two = 2 ;
311
+ struct test_sockmap_ktls * skel ;
312
+ unsigned char * data = NULL ;
313
+ struct msghdr msg = {0 };
314
+ struct iovec iov [2 ];
315
+ int prog_fd , map_fd ;
316
+ int txrx_buf = 1024 ;
317
+ int iov_length = 8192 ;
318
+ int err ;
319
+
320
+ skel = test_sockmap_ktls__open_and_load ();
321
+ if (!ASSERT_TRUE (skel , "open ktls skel" ))
322
+ return ;
323
+
324
+ err = create_pair (family , sotype , & c , & p );
325
+ if (!ASSERT_OK (err , "create_pair()" ))
326
+ goto out ;
327
+
328
+ err = setsockopt (c , SOL_SOCKET , SO_RCVBUFFORCE , & txrx_buf , sizeof (int ));
329
+ err |= setsockopt (p , SOL_SOCKET , SO_SNDBUFFORCE , & txrx_buf , sizeof (int ));
330
+ if (!ASSERT_OK (err , "set buf limit" ))
331
+ goto out ;
332
+
333
+ prog_fd = bpf_program__fd (skel -> progs .prog_sk_policy_redir );
334
+ map_fd = bpf_map__fd (skel -> maps .sock_map );
335
+
336
+ err = bpf_prog_attach (prog_fd , map_fd , BPF_SK_MSG_VERDICT , 0 );
337
+ if (!ASSERT_OK (err , "bpf_prog_attach sk msg" ))
338
+ goto out ;
339
+
340
+ err = bpf_map_update_elem (map_fd , & one , & c , BPF_NOEXIST );
341
+ if (!ASSERT_OK (err , "bpf_map_update_elem(c)" ))
342
+ goto out ;
343
+
344
+ err = bpf_map_update_elem (map_fd , & two , & p , BPF_NOEXIST );
345
+ if (!ASSERT_OK (err , "bpf_map_update_elem(p)" ))
346
+ goto out ;
347
+
348
+ skel -> bss -> apply_bytes = 1024 ;
349
+
350
+ err = init_ktls_pairs (c , p );
351
+ if (!ASSERT_OK (err , "init_ktls_pairs(c, p)" ))
352
+ goto out ;
353
+
354
+ data = calloc (iov_length , sizeof (char ));
355
+ if (!data )
356
+ goto out ;
357
+
358
+ iov [0 ].iov_base = data ;
359
+ iov [0 ].iov_len = iov_length ;
360
+ iov [1 ].iov_base = data ;
361
+ iov [1 ].iov_len = iov_length ;
362
+ msg .msg_iov = iov ;
363
+ msg .msg_iovlen = 2 ;
364
+
365
+ for (;;) {
366
+ err = sendmsg (c , & msg , MSG_DONTWAIT );
367
+ if (err <= 0 )
368
+ break ;
369
+ }
370
+
371
+ out :
372
+ if (data )
373
+ free (data );
374
+ if (c )
375
+ close (c );
376
+ if (p )
377
+ close (p );
378
+
379
+ test_sockmap_ktls__destroy (skel );
380
+ }
381
+
308
382
static void run_tests (int family , enum bpf_map_type map_type )
309
383
{
310
384
int map ;
@@ -329,6 +403,8 @@ static void run_ktls_test(int family, int sotype)
329
403
test_sockmap_ktls_tx_cork (family , sotype , false);
330
404
if (test__start_subtest ("tls tx cork with push" ))
331
405
test_sockmap_ktls_tx_cork (family , sotype , true);
406
+ if (test__start_subtest ("tls tx egress with no buf" ))
407
+ test_sockmap_ktls_tx_no_buf (family , sotype , true);
332
408
}
333
409
334
410
void test_sockmap_ktls (void )
0 commit comments