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: 851165 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: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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: 850612 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: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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: 851164 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: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sanity check netlink dumps, to make sure dumps don't have repeated entries or gaps in IDs. Signed-off-by: Jakub Kicinski --- 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, ))