History

selftests/xsk: account reclaimed invalid Tx descriptors

Invalid Tx descriptors are now returned through the completion ring, regardless of whether they form a standalone packet or belong to an invalid multi-buffer packet. The selftests previously counted only descriptors belonging to valid packets, with a special exception for some invalid multi-buffer packets in verbatim streams. This undercounts completion entries when a standalone invalid descriptor or another invalid packet is reclaimed by the kernel. Keep valid_pkts as the number of packets expected on the Rx side, but count every descriptor submitted to the Tx ring in valid_frags, as every such descriptor is now expected to be returned through the completion ring. Make fragment counting in verbatim mode follow the packet boundary instead of stopping at the first invalid fragment. Update custom stream generation so an invalid middle fragment terminates the generated Rx packet while Tx completion accounting still covers the complete invalid packet. Also add explicit end fragments after invalid middle descriptors. This exercises the kernel drain logic and verifies that subsequent valid packets are not interpreted as continuations of the invalid packet.

Maciej Fijalkowski committed 3 months ago

Commit f49d99e1 parent c5b1ca61 file · +14 −12Browse files

Unified · Split

tools/testing/selftests/bpf/prog_tests/test_xsk.c+14−12
@@ -427,14 +427,14 @@ static u32 pkt_nb_frags(u32 frame_size, struct pkt_stream *pkt_stream, struct pk · 426 unmodified lines
427 }427 }
428 428
429 /* Search for the end of the packet in verbatim mode */429 /* Search for the end of the packet in verbatim mode */
430 if (!pkt_continues(pkt->options) || !pkt->valid)430 if (!pkt_continues(pkt->options))
431 return nb_frags;431 return nb_frags;
432 432
433 next_frag = pkt_stream->current_pkt_nb;433 next_frag = pkt_stream->current_pkt_nb;
434 pkt++;434 pkt++;
435 while (next_frag++ < pkt_stream->nb_pkts) {435 while (next_frag++ < pkt_stream->nb_pkts) {
436 nb_frags++;436 nb_frags++;
437 if (!pkt_continues(pkt->options) || !pkt->valid)437 if (!pkt_continues(pkt->options))
438 break;438 break;
439 pkt++;439 pkt++;
440 }440 }
@@ -665,11 +665,11 @@ static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, s · 224 unmodified lines
665 if (!frame->valid || !pkt_continues(frame->options))665 if (!frame->valid || !pkt_continues(frame->options))
666 payload++;666 payload++;
667 } else {667 } else {
668 if (frame->valid)668 if (frame->valid) {
669 len += frame->len;669 len += frame->len;
670 if (frame->valid && pkt_continues(frame->options))670 if (pkt_continues(frame->options))
671 continue;671 continue;
672 672 }
673 pkt->pkt_nb = pkt_nb;673 pkt->pkt_nb = pkt_nb;
674 pkt->len = len;674 pkt->len = len;
675 pkt->valid = frame->valid;675 pkt->valid = frame->valid;
@@ -1250,10 +1250,9 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, · 574 unmodified lines
1250 }1250 }
1251 }1251 }
1252 1252
1253 if (pkt && pkt->valid) {1253 if (pkt && pkt->valid)
1254 valid_pkts++;1254 valid_pkts++;
1255 valid_frags += nb_frags;1255 valid_frags += nb_frags;
1256 }
1257 }1256 }
1258 1257
1259 pthread_mutex_lock(&pacing_mutex);1258 pthread_mutex_lock(&pacing_mutex);
@@ -2099,13 +2098,16 @@ int testapp_invalid_desc_mb(struct test_spec *test) · 839 unmodified lines
2099 {0, 0, 0, false, 0},2098 {0, 0, 0, false, 0},
2100 /* Invalid address in the second frame */2099 /* Invalid address in the second frame */
2101 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},2100 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2102 {umem_sz, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},2101 {umem_sz * 2, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2102 {0, MIN_PKT_SIZE, 0, false, 0},
2103 /* Invalid len in the middle */2103 /* Invalid len in the middle */
2104 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},2104 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2105 {0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},2105 {0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2106 {0, MIN_PKT_SIZE, 0, false, 0},
2106 /* Invalid options in the middle */2107 /* Invalid options in the middle */
2107 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},2108 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2108 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},2109 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},
2110 {0, MIN_PKT_SIZE, 0, false, 0},
2109 /* Transmit 2 frags, receive 3 */2111 /* Transmit 2 frags, receive 3 */
2110 {0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},2112 {0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},
2111 {0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, 0},2113 {0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, 0},
@@ -2117,8 +2119,8 @@ int testapp_invalid_desc_mb(struct test_spec *test) · 5 unmodified lines
2117 2119
2118 if (umem->unaligned_mode) {2120 if (umem->unaligned_mode) {
2119 /* Crossing a chunk boundary allowed */2121 /* Crossing a chunk boundary allowed */
2120 pkts[12].valid = true;2122 pkts[15].valid = true;
2121 pkts[13].valid = true;2123 pkts[16].valid = true;
2122 }2124 }
2123 2125
2124 test->mtu = MAX_ETH_JUMBO_SIZE;2126 test->mtu = MAX_ETH_JUMBO_SIZE;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t