Skip to content

Commit

Permalink
net: gso_test: support CONFIG_MAX_SKB_FRAGS up to 45
Browse files Browse the repository at this point in the history
The test allocs a single page to hold all the frag_list skbs. This
is insufficient on kernels with CONFIG_MAX_SKB_FRAGS=45, due to the
increased skb_shared_info frags[] array length.

        gso_test_func: ASSERTION FAILED at net/core/gso_test.c:210
        Expected alloc_size <= ((1UL) << 12), but
            alloc_size == 5075 (0x13d3)
            ((1UL) << 12) == 4096 (0x1000)

Simplify the logic. Just allocate a page for each frag_list skb.

Fixes: 4688ecb ("net: expand skb_segment unit test with frag_list coverage")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
wdebruij authored and davem330 committed Nov 13, 2023
1 parent 438cbcd commit e6daf12
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions net/core/gso_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,17 @@ static void gso_test_func(struct kunit *test)
}

if (tcase->frag_skbs) {
unsigned int total_size = 0, total_true_size = 0, alloc_size = 0;
unsigned int total_size = 0, total_true_size = 0;
struct sk_buff *frag_skb, *prev = NULL;

page = alloc_page(GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, page);
page_ref_add(page, tcase->nr_frag_skbs - 1);

for (i = 0; i < tcase->nr_frag_skbs; i++) {
unsigned int frag_size;

page = alloc_page(GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, page);

frag_size = tcase->frag_skbs[i];
frag_skb = build_skb(page_address(page) + alloc_size,
frag_skb = build_skb(page_address(page),
frag_size + shinfo_size);
KUNIT_ASSERT_NOT_NULL(test, frag_skb);
__skb_put(frag_skb, frag_size);
Expand All @@ -204,11 +203,8 @@ static void gso_test_func(struct kunit *test)

total_size += frag_size;
total_true_size += frag_skb->truesize;
alloc_size += frag_size + shinfo_size;
}

KUNIT_ASSERT_LE(test, alloc_size, PAGE_SIZE);

skb->len += total_size;
skb->data_len += total_size;
skb->truesize += total_true_size;
Expand Down

0 comments on commit e6daf12

Please sign in to comment.