From patchwork Fri Dec 13 15:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13907358 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F07C1E2312 for ; Fri, 13 Dec 2024 15:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103374; cv=none; b=nIYbVeQ259scaBEzv2jkh5+rtVPm2Gyy0US8YOrCPQ4ybdBB2JA+ac3TpRHgRfDVD07OJKWrQKQf21rB5YRZRd3XzZDj60Uh3CElPjVeGVEIZqsgxft4p0sEQrp/znBG8ZYYY6z3V1qBwMqUyE4dS7gZfC5V1lRzN+DB4vW7z/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103374; c=relaxed/simple; bh=D5vMP2Y/iWgk+eAx+fRPz67cMTrMx15yn8URoAuq0Wk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NosljMSmkA4t8Ueq7AXl6RYDgKD0yq6SVV05gDduJcJTG64A/CtcZR3ccrZxOn+AgEphUIZ7Is/P8V5x8By+6VoB9GMloU1sXY4fXxRpEbtM6kVYlB8pvA0mqLpjtBxAMRM27YsNJx42iQFueF2bTe/Blul4+PnXIY0yfcuOVsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PNps1728; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PNps1728" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86466C4CED2; Fri, 13 Dec 2024 15:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734103373; bh=D5vMP2Y/iWgk+eAx+fRPz67cMTrMx15yn8URoAuq0Wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNps1728hVl1IR2Ql30pgvvgPbqM4BoYJwQB+BwLzhZVyehVHUvAaukamiE0WYFgd EzYdQsKUqVIQyuqzKliXiMZ5DnRz6zOoZ1sDAEPJGe/fshtUqMy4K7aW32ntIceCGg mP/LUPXPs9jNO+z2sENcwbQkM0LTfBP8qGKI2DESb4fIdpnlHIzUPJKrxPq/HfBcOv NfDP2+o2cVxUuSzhHtvh2QdAY9lmBpfG0Adn15r61/0MG60bk+2lS52p0t8/lbsXac fZFpmdx6hPiMtnFOLfEuvaw3CJq0Jt/aBZcwFTpIJzln9SgigVUQq4dn9yRfPrBh7z IjKgochN9esOg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , jdamato@fastly.com, almasrymina@google.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com Subject: [PATCH net 1/5] netdev: fix repeated netlink messages in queue dump Date: Fri, 13 Dec 2024 07:22:40 -0800 Message-ID: <20241213152244.3080955-2-kuba@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org> References: <20241213152244.3080955-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The context is supposed to record the next queue do dump, not last dumped. If the dump doesn't fit we will restart from the already-dumped queue, duplicating the message. Before this fix and with the selftest improvements later in this series we see: # ./run_kselftest.sh -t drivers/net:queues.py timeout set to 45 selftests: drivers/net: queues.py KTAP version 1 1..2 # Check| At /root/ksft-net-drv/drivers/net/./queues.py, line 32, in get_queues: # Check| ksft_eq(queues, expected) # Check failed 102 != 100 # Check| At /root/ksft-net-drv/drivers/net/./queues.py, line 32, in get_queues: # Check| ksft_eq(queues, expected) # Check failed 101 != 100 not ok 1 queues.get_queues ok 2 queues.addremove_queues # Totals: pass:1 fail:1 xfail:0 xpass:0 skip:0 error:0 not ok 1 selftests: drivers/net: queues.py # exit=1 With the fix: # ./ksft-net-drv/run_kselftest.sh -t drivers/net:queues.py timeout set to 45 selftests: drivers/net: queues.py KTAP version 1 1..2 ok 1 queues.get_queues ok 2 queues.addremove_queues # Totals: pass:2 fail:0 xfail:0 xpass:0 skip:0 error:0 Fixes: 6b6171db7fc8 ("netdev-genl: Add netlink framework functions for queue") Signed-off-by: Jakub Kicinski Reviewed-by: Joe Damato --- CC: jdamato@fastly.com CC: almasrymina@google.com CC: amritha.nambiar@intel.com CC: sridhar.samudrala@intel.com --- net/core/netdev-genl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 9527dd46e4dc..9f086b190619 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -488,24 +488,21 @@ netdev_nl_queue_dump_one(struct net_device *netdev, struct sk_buff *rsp, struct netdev_nl_dump_ctx *ctx) { int err = 0; - int i; if (!(netdev->flags & IFF_UP)) return err; - for (i = ctx->rxq_idx; i < netdev->real_num_rx_queues;) { - err = netdev_nl_queue_fill_one(rsp, netdev, i, + for (; ctx->rxq_idx < netdev->real_num_rx_queues; ctx->rxq_idx++) { + err = netdev_nl_queue_fill_one(rsp, netdev, ctx->rxq_idx, NETDEV_QUEUE_TYPE_RX, info); if (err) return err; - ctx->rxq_idx = i++; } - for (i = ctx->txq_idx; i < netdev->real_num_tx_queues;) { - err = netdev_nl_queue_fill_one(rsp, netdev, i, + for (; ctx->txq_idx < netdev->real_num_tx_queues; ctx->txq_idx++) { + err = netdev_nl_queue_fill_one(rsp, netdev, ctx->txq_idx, NETDEV_QUEUE_TYPE_TX, info); if (err) return err; - ctx->txq_idx = i++; } return err; From patchwork Fri Dec 13 15:22:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13907359 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E131E2614 for ; Fri, 13 Dec 2024 15:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103374; cv=none; b=ac9oMs4MillRDOzUZQEMDgCGa+cP17vX3rpNusoOWkZtbf5S8A2UOGpNpq0kWf5tPaVF6yV2MWz1CsCtjKVDt60dWOQFaL/qxLPDYBwSAzceko4ht3fT882Vl7YjhQxMl4kUtL49y3evQ6FOjLmaxu9Eh+7IwtxWt6G7D8clUJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103374; c=relaxed/simple; bh=oxa3ts/7B5y3l8N+Y2mQnRTz3SO9TFP1CuLjZ1q9kKs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VtiHvHoC0uraagbzTfcUX9WcvFE2VBKTpiBSmJXKkvzw4au094963zihbIcK515fmmoKvLNtt6N+bkQIMDHkNx0IWLgX8X9i0ewIf4qpYFWBYWRXqpNO0nLzQyONgQaCxH9LeK0KexqlgABSALnitH8+z1w1A6qs+J6HLXSu5lQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ltc1osyn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ltc1osyn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AE13C4CEDD; Fri, 13 Dec 2024 15:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734103374; bh=oxa3ts/7B5y3l8N+Y2mQnRTz3SO9TFP1CuLjZ1q9kKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ltc1osynIIpnBLB+0/kcJ3C0AgUFyeSNL0ru+OAZ8Qw3Q8Ri2oKFKdm6/SEcEGHVh Z5Z/WfFoTFfifftBD+1iqj70iVywrOOsX5MMbNHl7kvr4v68keirCX5v2meacIBOYN gueUFuxBK/XCuBM6pKns7Rbalb7KMJOfF5MnZAy5Tzw9UlJkrnhlmJIjo88m/VQbyu 6KgEQ/uIaEnfbmCieMyOvlWPjxy6/Waip9+QkSJJ6R4/6NvRtw8LOQR+5COWh7Jl8M wzGL57/uH+rHvEKbG42eF3J8ajqUZOtweQE9vTH/nvtmQKV3shQlNPpJdFxjQ2gOgh 3B25957hXV/Jw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , jdamato@fastly.com, almasrymina@google.com, amritha.nambiar@intel.com, xuanzhuo@linux.alibaba.com, sdf@fomichev.me Subject: [PATCH net 2/5] netdev: fix repeated netlink messages in queue stats Date: Fri, 13 Dec 2024 07:22:41 -0800 Message-ID: <20241213152244.3080955-3-kuba@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org> References: <20241213152244.3080955-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The context is supposed to record the next queue do dump, not last dumped. If the dump doesn't fit we will restart from the already-dumped queue, duplicating the message. Before this fix and with the selftest improvements later in this series we see: # ./run_kselftest.sh -t drivers/net:stats.py timeout set to 45 selftests: drivers/net: stats.py KTAP version 1 1..5 ok 1 stats.check_pause ok 2 stats.check_fec ok 3 stats.pkt_byte_sum # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 125, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), len(set(queues[qtype])), # Check failed 45 != 44 repeated queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 127, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, # Check failed 45 != 44 missing queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 125, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), len(set(queues[qtype])), # Check failed 45 != 44 repeated queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 127, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, # Check failed 45 != 44 missing queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 125, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), len(set(queues[qtype])), # Check failed 103 != 100 repeated queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 127, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, # Check failed 103 != 100 missing queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 125, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), len(set(queues[qtype])), # Check failed 102 != 100 repeated queue keys # Check| At /root/ksft-net-drv/drivers/net/./stats.py, line 127, in qstat_by_ifindex: # Check| ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, # Check failed 102 != 100 missing queue keys not ok 4 stats.qstat_by_ifindex ok 5 stats.check_down # Totals: pass:4 fail:1 xfail:0 xpass:0 skip:0 error:0 With the fix: # ./ksft-net-drv/run_kselftest.sh -t drivers/net:stats.py timeout set to 45 selftests: drivers/net: stats.py KTAP version 1 1..5 ok 1 stats.check_pause ok 2 stats.check_fec ok 3 stats.pkt_byte_sum ok 4 stats.qstat_by_ifindex ok 5 stats.check_down # Totals: pass:5 fail:0 xfail:0 xpass:0 skip:0 error:0 Fixes: ab63a2387cb9 ("netdev: add per-queue statistics") Signed-off-by: Jakub Kicinski Reviewed-by: Joe Damato --- CC: jdamato@fastly.com CC: almasrymina@google.com CC: amritha.nambiar@intel.com CC: xuanzhuo@linux.alibaba.com CC: sdf@fomichev.me --- net/core/netdev-genl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 9f086b190619..1be8c7c21d19 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -668,7 +668,7 @@ netdev_nl_stats_by_queue(struct net_device *netdev, struct sk_buff *rsp, i, info); if (err) return err; - ctx->rxq_idx = i++; + ctx->rxq_idx = ++i; } i = ctx->txq_idx; while (ops->get_queue_stats_tx && i < netdev->real_num_tx_queues) { @@ -676,7 +676,7 @@ netdev_nl_stats_by_queue(struct net_device *netdev, struct sk_buff *rsp, i, info); if (err) return err; - ctx->txq_idx = i++; + ctx->txq_idx = ++i; } ctx->rxq_idx = 0; From patchwork Fri Dec 13 15:22:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13907360 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8800F1E3769; Fri, 13 Dec 2024 15:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103375; cv=none; b=Hamt352n2hVvF5tix04zczm4ZfbhHyjTI7U+u8KGYTTBTu5hqIok2PlhpNCIAhG3kplMQ6XS+NP4r5Ns8TBQp5vXLdb6pEA8wo4JuT7Wwr1xaCZrdox8yBvMEh/ptkDMLH3sckGjRVo9uWNHctth3C3S07uRhegKAyjGoG1z+60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103375; c=relaxed/simple; bh=IxAuYcWype869icFjRSyjTERVjyGtQO/sWtOyqzdQaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C/RJ0RGb0Dhw1MWSjymYrdT1tVkpwzcIQ8ikR9vWC3pthvoktI5KgfLAZ1oYL8/7nuTk4REuYglwg34rRO1IK/Xt9TkKT53bJPBUTvjrC8rDA3thY5IVviUxXvLt4kmicQXQMfjdVAoduYwec+2Nb2ciI4JW6daV1qjcYhbMJ1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pLgP0HLd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pLgP0HLd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8580C4CEE0; Fri, 13 Dec 2024 15:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734103375; bh=IxAuYcWype869icFjRSyjTERVjyGtQO/sWtOyqzdQaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLgP0HLdfIOtTPTdTBk7hmrEiTE0OtOo25dDZkNgN7Lcp+FWeQnviY4lYinj+u3M/ lqz2PjXUqlwi0BIWUQm5lwe0RR6MnmoHhvsxeeVdonMSrlk0QhLMY8aUIDNHHRVlTf s/7IT6ROnXMmQpqfCDakXgA+ng3sWKMAPDdBOb3WfzLBT/UbbdaSj+LQYOM0hJjFuh Y7K5pmNCdQQiokdGswGKfBhFAsrSnwAmq6hccQ1uiTuPyUgClK4PDh7wiHIppPT7lI 5c7CgOaKl+4/myRy2j7+OcGFFYcPTLNmM2oYpQkjPXw2zcuajc7JuYc8nM8AbHmFmO jI1SJoPyuLnxQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , shuah@kernel.org, jiri@resnulli.us, petrm@nvidia.com, linux-kselftest@vger.kernel.org Subject: [PATCH net 3/5] selftests: net: support setting recv_size in YNL Date: Fri, 13 Dec 2024 07:22:42 -0800 Message-ID: <20241213152244.3080955-4-kuba@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org> References: <20241213152244.3080955-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org recv_size parameter allows constraining the buffer size for dumps. It's useful in testing kernel handling of dump continuation, IOW testing dumps which span multiple skbs. Let the tests set this parameter when initializing the YNL family. Keep the normal default, we don't want tests to unintentionally behave very differently than normal code. Signed-off-by: Jakub Kicinski Reviewed-by: Joe Damato Reviewed-by: Petr Machata --- CC: shuah@kernel.org CC: jiri@resnulli.us CC: petrm@nvidia.com CC: linux-kselftest@vger.kernel.org --- tools/testing/selftests/net/lib/py/ynl.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/lib/py/ynl.py b/tools/testing/selftests/net/lib/py/ynl.py index a0d689d58c57..076a7e8dc3eb 100644 --- a/tools/testing/selftests/net/lib/py/ynl.py +++ b/tools/testing/selftests/net/lib/py/ynl.py @@ -32,23 +32,23 @@ from .ksft import ksft_pr, ktap_result # Set schema='' to avoid jsonschema validation, it's slow # class EthtoolFamily(YnlFamily): - def __init__(self): + def __init__(self, recv_size=0): super().__init__((SPEC_PATH / Path('ethtool.yaml')).as_posix(), - schema='') + schema='', recv_size=recv_size) class RtnlFamily(YnlFamily): - def __init__(self): + def __init__(self, recv_size=0): super().__init__((SPEC_PATH / Path('rt_link.yaml')).as_posix(), - schema='') + schema='', recv_size=recv_size) class NetdevFamily(YnlFamily): - def __init__(self): + def __init__(self, recv_size=0): super().__init__((SPEC_PATH / Path('netdev.yaml')).as_posix(), - schema='') + schema='', recv_size=recv_size) class NetshaperFamily(YnlFamily): - def __init__(self): + def __init__(self, recv_size=0): super().__init__((SPEC_PATH / Path('net_shaper.yaml')).as_posix(), - schema='') + schema='', recv_size=recv_size) From patchwork Fri Dec 13 15:22:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13907361 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5E8C1E32A3; Fri, 13 Dec 2024 15:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103375; cv=none; b=cooHKqbWaoC46wEag6Nw96kfux3VWoxm7Grp4RFiLUfwifbXGlJ4gKjXUY9kSmG6m3mbmiZcX/fV9rlLY5NSslD4cW8v1ZEFzj1f8ehQlUQ94g1K2rHHrNyVHYlDEn7UBhN0H0M2p1SXRckhWhsNFJqeNOI9ffdEXCLRymA1G2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103375; c=relaxed/simple; bh=0EXUEtGEaoDtvcqeqIHHP8K5Jdr1sqmtrJ3VAn8ZP/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uq2qtQZB1vEFtEa3Wv/ESC7NzxWr8DhQSjN41YBdpVzs/N3h+67BYyxrJvUFXiEoD7+oHXvibNkUL9BQtPbQ/v1InPtMBLjixN11w7jnZzhKVQZrknwxB4gKOzT+xXhm2Gb/J3cCzzpdh3BuYfTPEKGdIht+/Grfi3NMKafWpmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hf333qTd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hf333qTd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40C12C4CED0; Fri, 13 Dec 2024 15:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734103375; bh=0EXUEtGEaoDtvcqeqIHHP8K5Jdr1sqmtrJ3VAn8ZP/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hf333qTdazWLNqea3WVi7kf6Zl7ZNP1VNDsNJLZZxUXm9KHeqwc9zTmcap7kJqnOJ OQWP6NnjEsjrXdjBSE9wtNP/nsw5Ilh9kwVagI1krcdVP3Kd0JqhWDlnsd2nC43JlH yT5JRQjOz6Wi/I/idsioRFRXAqofV4vufC33Fp406PfkaGNoo9IeOFJUTFAk9flzdv Mmzp93Zdz1SaIrwWKXOvlusW0daFKPycB5FF5yadYdquQUPjNta/JblLRDTtHxztb1 Aj8VrN75YANKMFagDy62CeYww+ppKDqpHQX27mnGciOt8S+CH3q3LWPrN61BiMcg39 05rMFUHURzZDg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , shuah@kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net 4/5] selftests: net-drv: queues: sanity check netlink dumps Date: Fri, 13 Dec 2024 07:22:43 -0800 Message-ID: <20241213152244.3080955-5-kuba@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org> References: <20241213152244.3080955-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This test already catches a netlink bug fixed by this series, but only when running on HW with many queues. Make sure the netdevsim instance created has a lot of queues, and constrain the size of the recv_buffer used by netlink. While at it test both rx and tx queues. Signed-off-by: Jakub Kicinski Reviewed-by: Joe Damato Reviewed-by: Petr Machata --- CC: shuah@kernel.org CC: linux-kselftest@vger.kernel.org --- tools/testing/selftests/drivers/net/queues.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/drivers/net/queues.py b/tools/testing/selftests/drivers/net/queues.py index 30f29096e27c..9c5473abbd78 100755 --- a/tools/testing/selftests/drivers/net/queues.py +++ b/tools/testing/selftests/drivers/net/queues.py @@ -8,25 +8,28 @@ from lib.py import cmd import glob -def sys_get_queues(ifname) -> int: - folders = glob.glob(f'/sys/class/net/{ifname}/queues/rx-*') +def sys_get_queues(ifname, qtype='rx') -> int: + folders = glob.glob(f'/sys/class/net/{ifname}/queues/{qtype}-*') return len(folders) -def nl_get_queues(cfg, nl): +def nl_get_queues(cfg, nl, qtype='rx'): queues = nl.queue_get({'ifindex': cfg.ifindex}, dump=True) if queues: - return len([q for q in queues if q['type'] == 'rx']) + return len([q for q in queues if q['type'] == qtype]) return None def get_queues(cfg, nl) -> None: - queues = nl_get_queues(cfg, nl) - if not queues: - raise KsftSkipEx('queue-get not supported by device') + snl = NetdevFamily(recv_size=4096) - expected = sys_get_queues(cfg.dev['ifname']) - ksft_eq(queues, expected) + for qtype in ['rx', 'tx']: + queues = nl_get_queues(cfg, snl, qtype) + if not queues: + raise KsftSkipEx('queue-get not supported by device') + + expected = sys_get_queues(cfg.dev['ifname'], qtype) + ksft_eq(queues, expected) def addremove_queues(cfg, nl) -> None: @@ -57,7 +60,7 @@ import glob def main() -> None: - with NetDrvEnv(__file__, queue_count=3) as cfg: + with NetDrvEnv(__file__, queue_count=100) as cfg: ksft_run([get_queues, addremove_queues], args=(cfg, NetdevFamily())) ksft_exit() From patchwork Fri Dec 13 15:22:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13907362 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EE1F1E3DD6; Fri, 13 Dec 2024 15:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103376; cv=none; b=G3YbBIC0mVP9E2EVwB+GbHX5W67VDE9exjNDQIKJHCeeLa7FmcNBkRaSJGBq7W15HqSxRy6w+60M1y9tfeWzaQVOtcdbCfK7LqUfAVLaD5fBe5u4Sj8YXwxryDaRQKlw2QmLjtQ9xWNKvhfWxyTT+j5yaukx8g1DQqb3p1KaEo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734103376; c=relaxed/simple; bh=dTfzUm/+AiwIm2LTil+sjEdPMycULavutVM5qKOl4BI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IF0GcaSE7/EgHcah8U11cttzholSFrjbioqq2I0EmqlwWdlN/jQsErTQoimUtM27Bcv0QbgPkWJ79NzA0RtpKP7Vxxm2KjGsfeA33FBrgFOpCRwFbKbwVYniJJsAou5UYWDBs3JCBRmIffoGIq5CEANXkFAGvh3xHAyKP/hKjv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pWffvQ0I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pWffvQ0I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0335C4CEDE; Fri, 13 Dec 2024 15:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734103376; bh=dTfzUm/+AiwIm2LTil+sjEdPMycULavutVM5qKOl4BI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWffvQ0IhVCQANAZQD9Jt7/Xj+LoRRlRhuY13jB20lNQujMo0Rk+yOpccpyc4tFRS dHfBcRNT5Eg2wSkgw9YItpXXGcd+C4SNcLUbKgrOYpVnasCO6pwAAti9Nt4shgv9fY XhHXBudsq6SSBmAasfBHt79BnZUPqwLGc1NlA5Vnts5akvxTX1cprMzHCk8f6C2WwW TcfYhC74jOv40RrDD7hTTOysheMqEWwG9c+2wX26zQr+PNRQZ/LRz+y8Y4sTaUBat8 QjGfKY7TfDrpI/5iTqpmNX6cW8Nnn/0Aw+1rmlj9Xjqb+ytBYY4mvKTU2rH7SBXDbh CNmcOkreSV4Lg== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, Jakub Kicinski , shuah@kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net 5/5] selftests: net-drv: stats: sanity check netlink dumps Date: Fri, 13 Dec 2024 07:22:44 -0800 Message-ID: <20241213152244.3080955-6-kuba@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org> References: <20241213152244.3080955-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Sanity check netlink dumps, to make sure dumps don't have repeated entries or gaps in IDs. Signed-off-by: Jakub Kicinski Reviewed-by: Petr Machata --- CC: shuah@kernel.org CC: linux-kselftest@vger.kernel.org --- tools/testing/selftests/drivers/net/stats.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py index 63e3c045a3b2..031ac9def6c0 100755 --- a/tools/testing/selftests/drivers/net/stats.py +++ b/tools/testing/selftests/drivers/net/stats.py @@ -110,6 +110,23 @@ rtnl = RtnlFamily() ksft_ge(triple[1][key], triple[0][key], comment="bad key: " + key) ksft_ge(triple[2][key], triple[1][key], comment="bad key: " + key) + # Sanity check the dumps + queues = NetdevFamily(recv_size=4096).qstats_get({"scope": "queue"}, dump=True) + # Reformat the output into {ifindex: {rx: [id, id, ...], tx: [id, id, ...]}} + parsed = {} + for entry in queues: + ifindex = entry["ifindex"] + if ifindex not in parsed: + parsed[ifindex] = {"rx":[], "tx": []} + parsed[ifindex][entry["queue-type"]].append(entry['queue-id']) + # Now, validate + for ifindex, queues in parsed.items(): + for qtype in ['rx', 'tx']: + ksft_eq(len(queues[qtype]), len(set(queues[qtype])), + comment="repeated queue keys") + ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1, + comment="missing queue keys") + # Test invalid dumps # 0 is invalid with ksft_raises(NlError) as cm: @@ -158,7 +175,7 @@ rtnl = RtnlFamily() def main() -> None: - with NetDrvEnv(__file__) as cfg: + with NetDrvEnv(__file__, queue_count=100) as cfg: ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex, check_down], args=(cfg, ))