From: James Lee <james@codeconstruct.com.au>
To: Jeremy Kerr <jk@codeconstruct.com.au>,
Matt Johnston <matt@codeconstruct.com.au>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
James Lee <james@codeconstruct.com.au>
Subject: [PATCH net-next v3 7/7] net: mctp: usblib: Add test for failing append
Date: Wed, 14 Oct 2026 12:47:37 +0800 [thread overview]
Message-ID: <20261014-dev-mctp-usb-lib-test-v3-7-ee5bc3ea1db1@codeconstruct.com.au> (raw)
In-Reply-To: <20261014-dev-mctp-usb-lib-test-v3-0-ee5bc3ea1db1@codeconstruct.com.au>
Add test ensuring that network device stats are updated appropriately
when a previously pushed packet fails to send during a subsequent push.
Signed-off-by: James Lee <james@codeconstruct.com.au>
---
v2:
- Fix preemption management
v3:
- Rename mctp_usblib_test_tx_overflow()
- Correct stats collection
- Remove magic numbers from mctp_usblib_test_append_failure()
---
drivers/net/mctp/mctp-usblib-test.c | 42 +++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/net/mctp/mctp-usblib-test.c b/drivers/net/mctp/mctp-usblib-test.c
index 16c2c9963d2d4493268687764a1e9209f8c9a901..b7e8743c561f948a9528fccfaa5a50cd78b3320e 100644
--- a/drivers/net/mctp/mctp-usblib-test.c
+++ b/drivers/net/mctp/mctp-usblib-test.c
@@ -868,6 +868,47 @@ static void mctp_usblib_test_tx_multi_push(struct kunit *test)
KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(sends));
}
+static void mctp_usblib_test_append_failure(struct kunit *test)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ struct rtnl_link_stats64 stats;
+ struct mctp_usblib_tx_ops ops;
+ struct mctp_usblib_tx *tx;
+ struct net_device *ndev;
+ struct sk_buff *skb;
+ u64 tx_dropped;
+ size_t i;
+ u8 *buf;
+ int rc;
+
+ const size_t packet_count = 3;
+ const size_t len = (MCTP_USB_1_0_XFER_SIZE / packet_count) + 1
+ - sizeof(struct mctp_usb_hdr);
+ static_assert(len >= MCTP_USB_BTU);
+
+ ctx = mctp_usblib_test_init(test);
+ ndev = ctx->dev->ndev;
+
+ ops.send = mctp_usblib_test_tx_send_fail;
+
+ tx = mctp_usblib_test_tx_init(test, &ops, ctx, false);
+ buf = mctp_usblib_test_init_buf(test, len);
+
+ for (i = 0; i < packet_count; i++) {
+ tx_dropped = dev_get_stats(ndev, &stats)->tx_dropped;
+ KUNIT_EXPECT_EQ(test, tx_dropped, 0);
+ skb = mctp_usblib_test_init_skb(test, len, ndev, buf);
+
+ rc = mctp_usblib_tx_push(ndev, tx, skb, i != packet_count - 1);
+ KUNIT_EXPECT_EQ(test, rc, 0);
+ KUNIT_EXPECT_TRUE(test, list_empty(&ctx->tx_xfers));
+ }
+
+ tx_dropped = dev_get_stats(ndev, &stats)->tx_dropped;
+ KUNIT_EXPECT_EQ(test, tx_dropped, packet_count);
+ KUNIT_EXPECT_NULL(test, tx->cur_ctx);
+}
+
static struct kunit_case mctp_usblib_test_cases[] = {
KUNIT_CASE(mctp_usblib_test_rx_single),
KUNIT_CASE_PARAM(mctp_usblib_test_rx_pkt_span,
@@ -880,6 +921,7 @@ static struct kunit_case mctp_usblib_test_cases[] = {
KUNIT_CASE(mctp_usblib_test_tx_pkt_span),
KUNIT_CASE(mctp_usblib_test_tx_multi_push),
KUNIT_CASE(mctp_usblib_test_tx_failing_send),
+ KUNIT_CASE(mctp_usblib_test_append_failure),
{}
};
--
2.47.3
prev parent reply other threads:[~2026-10-14 4:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 4:47 [PATCH net-next v3 0/7] net: mctp: usblib: Increase coverage of kunit testing James Lee
2026-10-14 4:47 ` [PATCH net-next v3 1/7] net: mctp: usblib: Add to parameterized kunit tests James Lee
2026-10-14 4:47 ` [PATCH net-next v3 2/7] net: mctp: usblib: Add test for splits inside headers James Lee
2026-10-14 4:47 ` [PATCH net-next v3 3/7] net: mctp: usblib: Add tests of invalid headers James Lee
2026-10-14 4:47 ` [PATCH net-next v3 4/7] net: mctp: usblib: Complete rx tests James Lee
2026-10-14 4:47 ` [PATCH net-next v3 5/7] net: mctp: usblib: Simplify allocation logic in mctp_usblib_test_rx_init James Lee
2026-10-14 4:47 ` [PATCH net-next v3 6/7] net: mctp: usblib: Add initial kunit tx tests James Lee
2026-10-14 4:47 ` James Lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014-dev-mctp-usb-lib-test-v3-7-ee5bc3ea1db1@codeconstruct.com.au \
--to=james@codeconstruct.com.au \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavoars@kernel.org \
--cc=jk@codeconstruct.com.au \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox