[PATCH net-next v6 5/7] net: kunit: attach net_iov frags to target skbs in unreadable tests

From
Mina Almasry <hidden>
Date
2026-11-20 20:14:17
Reply to
Mina Almasry, 2026-11-20
In netmem_ref_test_net_iov(), the target skb passed to skb_shift() has
no fragments and unreadable == 0 while shifting from an unreadable
net_iov skb. In netmem_ref_test_try_coalesce(), subtest 3 manually sets
to->unreadable = 1 on a linear skb with nr_frags == 0, which cannot
occur in real code where skb->unreadable tracks unreadable fragments.

Give both target skbs an initial net_iov fragment from the same binding
before shifting or coalescing so the tests remain valid once memory
provider compatibility is enforced across skb_shift() and
skb_try_coalesce().

Signed-off-by: Mina Almasry <redacted>
---
 net/core/net_test.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/core/net_test.c b/net/core/net_test.c
index 19f422300d9c..1cfa947c11f2 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -1099,6 +1099,9 @@ static void netmem_ref_test_net_iov(struct kunit *test)
 	copy = alloc_skb(0, GFP_KERNEL);
 	KUNIT_ASSERT_NOT_NULL(test, copy);
 	copy->pp_recycle = 1;
+	skb_fill_netmem_desc(copy, 0, netmem, 64, 16);
+	copy->len = 16;
+	copy->data_len = 16;
 	KUNIT_EXPECT_EQ(test, skb_shift(copy, skb, 16), 16);
 	KUNIT_EXPECT_EQ(test, atomic_long_read(&niov.desc.pp_ref_count), 3L);
 	KUNIT_EXPECT_EQ(test, atomic_long_read(&binding.ref.data->count),
@@ -1730,18 +1733,19 @@ static void netmem_ref_test_try_coalesce(struct kunit *test)
 	from = alloc_skb(0, GFP_KERNEL);
 	KUNIT_ASSERT_NOT_NULL(test, to);
 	KUNIT_ASSERT_NOT_NULL(test, from);
-	skb_put(to, skb_tailroom(to));
 	to->pp_recycle = 1;
-	to->unreadable = 1;
 	from->pp_recycle = 1;
-	skb_add_rx_frag_netmem(from, 0, niov_nm, 0, 64, PAGE_SIZE);
+	skb_add_rx_frag_netmem(to, 0, niov_nm, 0, 32, PAGE_SIZE);
+	napi_pp_get_page(niov_nm);
+	skb_add_rx_frag_netmem(from, 0, niov_nm, 32, 64, PAGE_SIZE);
 	napi_pp_get_page(niov_nm);
 
 	clone = skb_clone(from, GFP_KERNEL);
 	KUNIT_ASSERT_NOT_NULL(test, clone);
 	KUNIT_EXPECT_TRUE(test, skb_try_coalesce(to, from, &fragstolen,
 						 &delta));
-	KUNIT_EXPECT_EQ(test, atomic_long_read(&niov.desc.pp_ref_count), 4L);
+	KUNIT_EXPECT_TRUE(test, to->unreadable);
+	KUNIT_EXPECT_EQ(test, atomic_long_read(&niov.desc.pp_ref_count), 5L);
 	KUNIT_EXPECT_EQ(test, atomic_long_read(&binding.ref.data->count),
 			base_iov_ref);
 	consume_skb(from);
-- 
2.56.1.750.gf70dc682cf-goog
Thread (8 messages) 8 messages, 1 author, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help