From nobody Sun Feb 8 10:30:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC71DEB64DC for ; Fri, 14 Jul 2023 14:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235690AbjGNOUU (ORCPT ); Fri, 14 Jul 2023 10:20:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235418AbjGNOUL (ORCPT ); Fri, 14 Jul 2023 10:20:11 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A50E35BB for ; Fri, 14 Jul 2023 07:19:59 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-51e6113437cso2347271a12.2 for ; Fri, 14 Jul 2023 07:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent.com; s=google; t=1689344397; x=1691936397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8qk8T3EVPKdRYf+naU4m+YVtLzpGUKvj2gEOLRZFi7k=; b=fZmmnLinrKMYrKhEK0Ja70FkcaLdJD7wwVXadLH0V3hRFzduwn6n00RysF14lvageo JsAppEggMr42ZWN1aLrpKNzo2qv5GGcBc/1Y/Bp9px2acb1JlEkaYeBmKIbg1OH0tCU3 nECSVyAnpJZ+Ckza0WyWUMs9e7sQ4oz/c7ccFxMH+P1oM85hBV9vtxQGuvFE6kD5lYwf LzO0QciKwgQiKxGjFF2BIeujLoqdIgYuF5SU0iXUABihsf7b8YonSsL7LI1mgQ9XEaGq ZAYTaYQ0qsTJILqkKDA7KIw0ZURDZWhHWAqveJQMjOJbqQDsRC0q55gW+99LAHgoFVQD rg1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689344397; x=1691936397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8qk8T3EVPKdRYf+naU4m+YVtLzpGUKvj2gEOLRZFi7k=; b=FCo44DlIA0C+HgXokxK8ZCzic945VRL+vOhq824UnuN5HoxZDItioexxxQyLazrSPx wN+r/2oE2GFC5K6pPfnkPolS6Htxgk0zrT/9aWNx4jHmldwo8dpVXMmylAZvQR9ZMBrC z0lkSDyK6C/LYc/p90L394glgH2SB58+Boga+GRi4OtyMQXpc2+l4zXRZrcOOpgrMwvC LEmRJ/sWQiI/I2Bc16VkkmbmnhohDccKgKG6Q+36K7in5i77OmE1qS3Jdug+IqKK2Bex m7FSXdUZ7WvqZzKOxuTrXK1soHORcSE5oLpkb7NbFhxaIWmvQ+ntit8xFjQ7C8iIOYY9 pByg== X-Gm-Message-State: ABy/qLYgBe9c2cMZAi2b27pQCHzM1sZikvFiQmMwjnqj0xKs0YNgTFDb g25DLrOMpsBtM2Jk185aoZghIQ== X-Google-Smtp-Source: APBJJlE3dUHsS60CUNmtFflD35N+5SzU2TRu3lWZvljtOkzKkJCtJygfCLn+Ia0YaPigbhKdj9mlEQ== X-Received: by 2002:a17:906:9146:b0:989:450:e585 with SMTP id y6-20020a170906914600b009890450e585mr3728345ejw.45.1689344397549; Fri, 14 Jul 2023 07:19:57 -0700 (PDT) Received: from zh-lab-node-5.home ([2a02:168:f656:0:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id n11-20020a1709061d0b00b00982cfe1fe5dsm5469294ejh.65.2023.07.14.07.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 07:19:57 -0700 (PDT) From: Anton Protopopov To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Hou Tao , Joe Stringer , Anton Protopopov , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 1/3] bpf: consider CONST_PTR_TO_MAP as trusted pointer to struct bpf_map Date: Fri, 14 Jul 2023 14:20:58 +0000 Message-Id: <20230714142100.42265-2-aspsk@isovalent.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714142100.42265-1-aspsk@isovalent.com> References: <20230714141747.41560-1-aspsk@isovalent.com> <20230714142100.42265-1-aspsk@isovalent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Patch verifier to regard values of type CONST_PTR_TO_MAP as trusted pointers to struct bpf_map. This allows kfuncs to work with `struct bpf_map *` arguments. Save some bytes by defining btf_bpf_map_id as BTF_ID_LIST_GLOBAL_SINGLE (which is u32[1]), not as BTF_ID_LIST (which is u32[64]). Signed-off-by: Anton Protopopov --- include/linux/btf_ids.h | 1 + kernel/bpf/map_iter.c | 3 +-- kernel/bpf/verifier.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h index 00950cc03bff..a3462a9b8e18 100644 --- a/include/linux/btf_ids.h +++ b/include/linux/btf_ids.h @@ -267,5 +267,6 @@ MAX_BTF_TRACING_TYPE, extern u32 btf_tracing_ids[]; extern u32 bpf_cgroup_btf_id[]; extern u32 bpf_local_storage_map_btf_id[]; +extern u32 btf_bpf_map_id[]; =20 #endif diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c index d06d3b7150e5..b67996147895 100644 --- a/kernel/bpf/map_iter.c +++ b/kernel/bpf/map_iter.c @@ -78,8 +78,7 @@ static const struct seq_operations bpf_map_seq_ops =3D { .show =3D bpf_map_seq_show, }; =20 -BTF_ID_LIST(btf_bpf_map_id) -BTF_ID(struct, bpf_map) +BTF_ID_LIST_GLOBAL_SINGLE(btf_bpf_map_id, struct, bpf_map) =20 static const struct bpf_iter_seq_info bpf_map_seq_info =3D { .seq_ops =3D &bpf_map_seq_ops, diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 0b9da95331d7..5663f97ef292 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5419,6 +5419,9 @@ static bool is_trusted_reg(const struct bpf_reg_state= *reg) if (reg->ref_obj_id) return true; =20 + if (reg->type =3D=3D CONST_PTR_TO_MAP) + return true; + /* If a register is not referenced, it is trusted if it has the * MEM_ALLOC or PTR_TRUSTED type modifiers, and no others. Some of the * other type modifiers may be safe, but we elect to take an opt-in @@ -10052,13 +10055,13 @@ static bool __btf_type_is_scalar_struct(struct bp= f_verifier_env *env, return true; } =20 - static u32 *reg2btf_ids[__BPF_REG_TYPE_MAX] =3D { #ifdef CONFIG_NET [PTR_TO_SOCKET] =3D &btf_sock_ids[BTF_SOCK_TYPE_SOCK], [PTR_TO_SOCK_COMMON] =3D &btf_sock_ids[BTF_SOCK_TYPE_SOCK_COMMON], [PTR_TO_TCP_SOCK] =3D &btf_sock_ids[BTF_SOCK_TYPE_TCP], #endif + [CONST_PTR_TO_MAP] =3D btf_bpf_map_id, }; =20 enum kfunc_ptr_arg_type { --=20 2.34.1 From nobody Sun Feb 8 10:30:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF562EB64DC for ; Fri, 14 Jul 2023 14:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbjGNOUX (ORCPT ); Fri, 14 Jul 2023 10:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235515AbjGNOUM (ORCPT ); Fri, 14 Jul 2023 10:20:12 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0539035BC for ; Fri, 14 Jul 2023 07:20:00 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9741caaf9d4so252596866b.0 for ; Fri, 14 Jul 2023 07:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent.com; s=google; t=1689344398; x=1691936398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O4zgnqP7ASsB+eUpBj68dhMcY1VzfTyfkf9nUd4K0Yg=; b=TH0mhba8d76c7Ka/TPMFwg664iBScu0zUMrviGBOrnld29U0ezZQ12/r0PR+0/oaHW wxHfKcWtJqqGt0rT8Nh87BExLDIHT4FWrefDnQeTelmuyC+fjSPcVA41NhUb9PLFAaHC 7h+LaS2nyFQFpSFVQDhT/gKp7ShQGXW/08e0nEBaa/IqWeg1OtAFin07xJ3q+c9Wu6VM SGkgBWb1XxwTXtjThxfgKB609GRd8BTw38kPue5yvOJX3O0/fFSZZSd3QJmhqUWczuPe bk96qig+pVvkXD6uMmXXfdwPtsrGDbdKoFLzTi8nHsn8iZStYk7AfRVlxZ1MYZCAK1w/ RpbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689344398; x=1691936398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O4zgnqP7ASsB+eUpBj68dhMcY1VzfTyfkf9nUd4K0Yg=; b=AOET0YJvCnwMZGRyVz3gLiej2SI2xezhyIyXbHz/0vpqIyHx0bXeH7p/gX7zccOo8o ergAjdVPNDgMJm1BVAiAAxq6gzsSiZ/6dHbMslKGqZS43WUg6MGr57mjluARmBF33rM8 ChRFvIOkyH5Hh5E+KChUnajMXdOYYUeVxryx4zq/38LqAzNpDuY1goo6dqjZmth1Cjb/ H5sfePvZ3PNGryT4gVjB+N/cwe3oZAAK/ARpndlT2lpknXXL+Ek++5xvVWAXQqIVAM2U 8WzEnjo8XBSdnqb1bfqfz2uJf5mkWg9G42q2VAYFrKlMXt6OJyarcG27IFndef1QCL3h smAQ== X-Gm-Message-State: ABy/qLaZYIXEJrJFQ+fnCvIESD+/hUJ2hN3Pz1iCUhYOYeCdMIaKd7Uu aVdHOW9HL8ioh9m7aj/P/YPBgA== X-Google-Smtp-Source: APBJJlG6aTI+UM8YICICq6ZGR8uS5qkOUtVH5/T1tGNddtCWDEE72Dhzu9qW4+p9Nb3eFzEA2rgCXw== X-Received: by 2002:a17:906:248:b0:994:569b:61b6 with SMTP id 8-20020a170906024800b00994569b61b6mr484575ejl.40.1689344398399; Fri, 14 Jul 2023 07:19:58 -0700 (PDT) Received: from zh-lab-node-5.home ([2a02:168:f656:0:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id n11-20020a1709061d0b00b00982cfe1fe5dsm5469294ejh.65.2023.07.14.07.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 07:19:58 -0700 (PDT) From: Anton Protopopov To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Hou Tao , Joe Stringer , Anton Protopopov , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 2/3] bpf: make an argument const in the bpf_map_sum_elem_count kfunc Date: Fri, 14 Jul 2023 14:20:59 +0000 Message-Id: <20230714142100.42265-3-aspsk@isovalent.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714142100.42265-1-aspsk@isovalent.com> References: <20230714141747.41560-1-aspsk@isovalent.com> <20230714142100.42265-1-aspsk@isovalent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We use the map pointer only to read the counter values, no locking involved, so mark the argument as const. Signed-off-by: Anton Protopopov --- kernel/bpf/map_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c index b67996147895..011adb41858e 100644 --- a/kernel/bpf/map_iter.c +++ b/kernel/bpf/map_iter.c @@ -197,7 +197,7 @@ __diag_push(); __diag_ignore_all("-Wmissing-prototypes", "Global functions as their definitions will be in vmlinux BTF"); =20 -__bpf_kfunc s64 bpf_map_sum_elem_count(struct bpf_map *map) +__bpf_kfunc s64 bpf_map_sum_elem_count(const struct bpf_map *map) { s64 *pcount; s64 ret =3D 0; --=20 2.34.1 From nobody Sun Feb 8 10:30:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54635EB64DC for ; Fri, 14 Jul 2023 14:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235834AbjGNOU0 (ORCPT ); Fri, 14 Jul 2023 10:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235553AbjGNOUM (ORCPT ); Fri, 14 Jul 2023 10:20:12 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE05312E for ; Fri, 14 Jul 2023 07:20:00 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9939fbb7191so398766166b.0 for ; Fri, 14 Jul 2023 07:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent.com; s=google; t=1689344399; x=1691936399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=TL4iPDnWm7LI7dooTGYVCYljPJYJzbf9kW0UMI/E3E8=; b=fET5mheW2k8XUXyCZgr27r2S9eemW47Zml2RjJmVZyJa6RxgKX38TLREi0uUyQ65yK jSGBL1/GR3mB13uvWizvy6Tx1Co8Sv9uFVxkTHU1HA6DT+PaSInTystxarYkKtyDTgd8 KrL6NGvz/vVSNmANyBpD4E7mcuQSp8VB3UIRBXInlWxCmPxprdUcZ5Q5cRifRqP5FMCY cDoOhltg0/cfN5w2vBvmO3IK4d4YIOVBppyzkcEEMPbbC+uNzVR3BCB+ojAZuDLIGRIV ScLMdhan5tSU1Yww7m2rFz5bIwIdG1kTi5rSEIxRDYLHiHYoTDS0Z48DW7PKBs2QrhRH lLOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689344399; x=1691936399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TL4iPDnWm7LI7dooTGYVCYljPJYJzbf9kW0UMI/E3E8=; b=EWGvA5lhpWXIRZKIjapi8T/dSaX6fk1rVhChXS17PGC4VpP6bWLyIeTGQ5HD3avLsz 6G4bMfF0GJtufiZH0btjSHZoMbpBlUSVzkdPTkh6sQ/GpabMlT+D+gAuiO4mS7+P+zqX a3ZvsJdNmMGJQ1VCznno7RX14ghmcSZsMvEyFah3qBmOYdtXs4g+2kZKfor3Nsc3gqMf BxsqkpBG8HEBwa+WDK0OOu92brF8ZHNu/Bvg74QOGAAwoBs2FMp+TiVsZFmUp/CTm7mb sC9TiNGc5XQBOqSFJ/yxHLcQ32Tt/I07mZfyRIDHo7cXAD5nVbkixO9mxaLP4ULF0xb1 Ox/g== X-Gm-Message-State: ABy/qLYGlRLZ2d2BWkJv8hgTGW4smjrrEKuLF47iNclzq6ehENAbSIEK TrIDJ/HIC/ktzIid0T7qgRV7Tw== X-Google-Smtp-Source: APBJJlEQIvA3n/Prr51crDxtReiG/q/Se2PDT6dKD9tdWOl1w72csMERG1dYfF3M+wYIMbNXDH9elQ== X-Received: by 2002:a17:907:6d19:b0:98d:abd4:4000 with SMTP id sa25-20020a1709076d1900b0098dabd44000mr3312257ejc.35.1689344399312; Fri, 14 Jul 2023 07:19:59 -0700 (PDT) Received: from zh-lab-node-5.home ([2a02:168:f656:0:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id n11-20020a1709061d0b00b00982cfe1fe5dsm5469294ejh.65.2023.07.14.07.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 07:19:58 -0700 (PDT) From: Anton Protopopov To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , Hou Tao , Joe Stringer , Anton Protopopov , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next 3/3] bpf: allow any program to use the bpf_map_sum_elem_count kfunc Date: Fri, 14 Jul 2023 14:21:00 +0000 Message-Id: <20230714142100.42265-4-aspsk@isovalent.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714142100.42265-1-aspsk@isovalent.com> References: <20230714141747.41560-1-aspsk@isovalent.com> <20230714142100.42265-1-aspsk@isovalent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Register the bpf_map_sum_elem_count func for all programs, and update the map_ptr subtest of the test_progs test to test the new functionality. The usage is allowed as long as the pointer to the map is trusted (when using tracing programs) or is a const pointer to map, as in the following example: struct { __uint(type, BPF_MAP_TYPE_HASH); ... } hash SEC(".maps"); ... static inline int some_bpf_prog(void) { struct bpf_map *map =3D (struct bpf_map *)&hash; __s64 count; count =3D bpf_map_sum_elem_count(map); ... } Signed-off-by: Anton Protopopov --- kernel/bpf/map_iter.c | 2 +- tools/testing/selftests/bpf/progs/map_ptr_kern.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c index 011adb41858e..6fc9dae9edc8 100644 --- a/kernel/bpf/map_iter.c +++ b/kernel/bpf/map_iter.c @@ -226,6 +226,6 @@ static const struct btf_kfunc_id_set bpf_map_iter_kfunc= _set =3D { =20 static int init_subsystem(void) { - return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_map_iter_kfu= nc_set); + return register_btf_kfunc_id_set(BPF_PROG_TYPE_UNSPEC, &bpf_map_iter_kfun= c_set); } late_initcall(init_subsystem); diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testi= ng/selftests/bpf/progs/map_ptr_kern.c index db388f593d0a..3325da17ec81 100644 --- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c +++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c @@ -103,6 +103,8 @@ struct { __type(value, __u32); } m_hash SEC(".maps"); =20 +__s64 bpf_map_sum_elem_count(struct bpf_map *map) __ksym; + static inline int check_hash(void) { struct bpf_htab *hash =3D (struct bpf_htab *)&m_hash; @@ -115,6 +117,8 @@ static inline int check_hash(void) VERIFY(hash->elem_size =3D=3D 64); =20 VERIFY(hash->count.counter =3D=3D 0); + VERIFY(bpf_map_sum_elem_count(map) =3D=3D 0); + for (i =3D 0; i < HALF_ENTRIES; ++i) { const __u32 key =3D i; const __u32 val =3D 1; @@ -123,6 +127,7 @@ static inline int check_hash(void) return 0; } VERIFY(hash->count.counter =3D=3D HALF_ENTRIES); + VERIFY(bpf_map_sum_elem_count(map) =3D=3D HALF_ENTRIES); =20 return 1; } --=20 2.34.1