Skip to content

Commit 2e1d6a0

Browse files
tvyavahaborkmann
authored andcommitted
selftests/xsk: Fix for SEND_RECEIVE_UNALIGNED test
Fix test broken by shared umem test and framework enhancement commit. Correct the current implementation of pkt_stream_replace_half() by ensuring that nb_valid_entries are not set to half, as this is not true for all the tests. Ensure that the expected value for valid_entries for the SEND_RECEIVE_UNALIGNED test equals the total number of packets sent, which is 4096. Create a new function called pkt_stream_pkt_set() that allows for packet modification to meet specific requirements while ensuring the accurate maintenance of the valid packet count to prevent inconsistencies in packet tracking. Fixes: 6d198a8 ("selftests/xsk: Add a test for shared umem feature") Reported-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Tushar Vyavahare <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Acked-by: Magnus Karlsson <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c838fe1 commit 2e1d6a0

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tools/testing/selftests/bpf/xskxceiver.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,24 @@ static u32 pkt_nb_frags(u32 frame_size, struct pkt_stream *pkt_stream, struct pk
634634
return nb_frags;
635635
}
636636

637+
static bool set_pkt_valid(int offset, u32 len)
638+
{
639+
return len <= MAX_ETH_JUMBO_SIZE;
640+
}
641+
637642
static void pkt_set(struct pkt_stream *pkt_stream, struct pkt *pkt, int offset, u32 len)
638643
{
639644
pkt->offset = offset;
640645
pkt->len = len;
641-
if (len > MAX_ETH_JUMBO_SIZE) {
642-
pkt->valid = false;
643-
} else {
644-
pkt->valid = true;
645-
pkt_stream->nb_valid_entries++;
646-
}
646+
pkt->valid = set_pkt_valid(offset, len);
647+
}
648+
649+
static void pkt_stream_pkt_set(struct pkt_stream *pkt_stream, struct pkt *pkt, int offset, u32 len)
650+
{
651+
bool prev_pkt_valid = pkt->valid;
652+
653+
pkt_set(pkt_stream, pkt, offset, len);
654+
pkt_stream->nb_valid_entries += pkt->valid - prev_pkt_valid;
647655
}
648656

649657
static u32 pkt_get_buffer_len(struct xsk_umem_info *umem, u32 len)
@@ -665,7 +673,7 @@ static struct pkt_stream *__pkt_stream_generate(u32 nb_pkts, u32 pkt_len, u32 nb
665673
for (i = 0; i < nb_pkts; i++) {
666674
struct pkt *pkt = &pkt_stream->pkts[i];
667675

668-
pkt_set(pkt_stream, pkt, 0, pkt_len);
676+
pkt_stream_pkt_set(pkt_stream, pkt, 0, pkt_len);
669677
pkt->pkt_nb = nb_start + i * nb_off;
670678
}
671679

@@ -700,10 +708,9 @@ static void __pkt_stream_replace_half(struct ifobject *ifobj, u32 pkt_len,
700708

701709
pkt_stream = pkt_stream_clone(ifobj->xsk->pkt_stream);
702710
for (i = 1; i < ifobj->xsk->pkt_stream->nb_pkts; i += 2)
703-
pkt_set(pkt_stream, &pkt_stream->pkts[i], offset, pkt_len);
711+
pkt_stream_pkt_set(pkt_stream, &pkt_stream->pkts[i], offset, pkt_len);
704712

705713
ifobj->xsk->pkt_stream = pkt_stream;
706-
pkt_stream->nb_valid_entries /= 2;
707714
}
708715

709716
static void pkt_stream_replace_half(struct test_spec *test, u32 pkt_len, int offset)

0 commit comments

Comments
 (0)