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
427427 }
428428
429429 /* Search for the end of the packet in verbatim mode */
430− if (!pkt_continues(pkt->options) || !pkt->valid)
430+ if (!pkt_continues(pkt->options))
431431 return nb_frags;
432432
433433 next_frag = pkt_stream->current_pkt_nb;
434434 pkt++;
435435 while (next_frag++ < pkt_stream->nb_pkts) {
436436 nb_frags++;
437− if (!pkt_continues(pkt->options) || !pkt->valid)
437+ if (!pkt_continues(pkt->options))
438438 break;
439439 pkt++;
440440 }
@@ -665,11 +665,11 @@ static struct pkt_stream *__pkt_stream_generate_custom(struct ifobject *ifobj, s · 224 unmodified lines
665665 if (!frame->valid || !pkt_continues(frame->options))
666666 payload++;
667667 } else {
668− if (frame->valid)
668+ if (frame->valid) {
669669 len += frame->len;
670− if (frame->valid && pkt_continues(frame->options))
671− continue;
672−
670+ if (pkt_continues(frame->options))
671+ continue;
672+ }
673673 pkt->pkt_nb = pkt_nb;
674674 pkt->len = len;
675675 pkt->valid = frame->valid;
@@ -1250,10 +1250,9 @@ static int __send_pkts(struct ifobject *ifobject, struct xsk_socket_info *xsk, · 574 unmodified lines
12501250 }
12511251 }
12521252
1253− if (pkt && pkt->valid) {
1253+ if (pkt && pkt->valid)
12541254 valid_pkts++;
1255− valid_frags += nb_frags;
1256− }
1255+ valid_frags += nb_frags;
12571256 }
12581257
12591258 pthread_mutex_lock(&pacing_mutex);
@@ -2099,13 +2098,16 @@ int testapp_invalid_desc_mb(struct test_spec *test) · 839 unmodified lines
20992098 {0, 0, 0, false, 0},
21002099 /* Invalid address in the second frame */
21012100 {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},
21032103 /* Invalid len in the middle */
21042104 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
21052105 {0, XSK_UMEM__INVALID_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
2106+ {0, MIN_PKT_SIZE, 0, false, 0},
21062107 /* Invalid options in the middle */
21072108 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XDP_PKT_CONTD},
21082109 {0, XSK_UMEM__LARGE_FRAME_SIZE, 0, false, XSK_DESC__INVALID_OPTION},
2110+ {0, MIN_PKT_SIZE, 0, false, 0},
21092111 /* Transmit 2 frags, receive 3 */
21102112 {0, XSK_UMEM__MAX_FRAME_SIZE, 0, true, XDP_PKT_CONTD},
21112113 {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
21172119
21182120 if (umem->unaligned_mode) {
21192121 /* Crossing a chunk boundary allowed */
2120− pkts[12].valid = true;
2121− pkts[13].valid = true;
2122+ pkts[15].valid = true;
2123+ pkts[16].valid = true;
21222124 }
21232125
21242126 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