From patchwork Fri Feb 4 22:58:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12735789 X-Patchwork-Delegate: bpf@iogearbox.net 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 06604C43217 for ; Fri, 4 Feb 2022 22:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359386AbiBDW6c (ORCPT ); Fri, 4 Feb 2022 17:58:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59987 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377736AbiBDW62 (ORCPT ); Fri, 4 Feb 2022 17:58:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644015507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=mbIIMwTtHOK23EwwQeYMceH1azwmVKWfuX9oObuKyeQ=; b=VHDgkptulo/cGYPfID8D2UMrlrYZG9O2zGNfyMRj3ujoZ754gughxyG6p3I3n6UVCegA3D FYEDUr19Dt16a9gqvbFIv573VOkl+3R5A0oQnXabhYFawNUpWDRFDs1Mt8a4UoTlpzdx0K cuRQmb2JS175qGMjx8ihEY/1DtJ46Ms= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-r-0bryZmOJGWclCG21EWog-1; Fri, 04 Feb 2022 17:58:26 -0500 X-MC-Unique: r-0bryZmOJGWclCG21EWog-1 Received: by mail-ed1-f70.google.com with SMTP id s7-20020a508dc7000000b0040f29ccd65aso252070edh.1 for ; Fri, 04 Feb 2022 14:58:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mbIIMwTtHOK23EwwQeYMceH1azwmVKWfuX9oObuKyeQ=; b=U13ri7g8oKaNJiHH+whGtqDSjnI9SU/d+fwBQRLqUtZ2e0d9p/ClRdaFPw4blb+pfB GK/LCss91HJOGFKYn5znqyu/PN88YN4odIZqDDULsdC4uDkCXFS5obdwWEoNoleqY1WC dS63vWGUS/ZBhlcSG1jrpG06a7El8aZvzyXzRFy+Z3Z5ZAIM5+W8KV97rpgz9QqcZdmz bxgu+lHse6EORfzmDS5sTcwpp1ekAU9NIq1DM4ZxCozWKcqbmKtSpmwg5V0wjJ6h8jGV hGq8DY8AzZVvniTXHY5VPjzjFjUv4K/S2kY3AsfAUOUIFIKXtf2iB77ZAqW0YjVMySNT WofQ== X-Gm-Message-State: AOAM532Wh+Ab+YOLzoZmC/arpzstWAo8jbfpwfiKvaX/2IyE3O2BFOF8 9fBN3T4lI3MZhnQCh2P1B/q3kyTAG74ZBgoRosG/oYD5QedTzjid5gVZauPQ+lSc6pPFqfQWoNL 26k8/W9hMj+iNfHD+ X-Received: by 2002:a05:6402:51cd:: with SMTP id r13mr1484386edd.381.1644015505107; Fri, 04 Feb 2022 14:58:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6tau51Apvgacqbwdn4SWF8Jr0PsmIu6xyu/W/a+95B28zPUpQ9oEEbT8VgbdxwucI7AZomQ== X-Received: by 2002:a05:6402:51cd:: with SMTP id r13mr1484378edd.381.1644015504962; Fri, 04 Feb 2022 14:58:24 -0800 (PST) Received: from krava.redhat.com ([83.240.63.12]) by smtp.gmail.com with ESMTPSA id u1sm1064907ejj.215.2022.02.04.14.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 14:58:24 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Jakub Kicinski , Jiri Pirko Subject: [PATCH bpf-next 1/3] libbpf: Add names for auxiliary maps Date: Fri, 4 Feb 2022 23:58:21 +0100 Message-Id: <20220204225823.339548-1-jolsa@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Adding names for maps that bpftool uses for various detections. These maps can appear in final map show output (due to deferred removal in kernel) so some tests (like test_offload.py) needs to filter them out. Signed-off-by: Jiri Olsa --- tools/lib/bpf/libbpf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 904cdf83002b..38294ce935d6 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -4412,7 +4412,7 @@ static int probe_kern_global_data(void) }; int ret, map, insn_cnt = ARRAY_SIZE(insns); - map = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(int), 32, 1, NULL); + map = bpf_map_create(BPF_MAP_TYPE_ARRAY, "global_data", sizeof(int), 32, 1, NULL); if (map < 0) { ret = -errno; cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); @@ -4545,7 +4545,7 @@ static int probe_kern_array_mmap(void) LIBBPF_OPTS(bpf_map_create_opts, opts, .map_flags = BPF_F_MMAPABLE); int fd; - fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(int), sizeof(int), 1, &opts); + fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, "array_mmap", sizeof(int), sizeof(int), 1, &opts); return probe_fd(fd); } @@ -4592,7 +4592,7 @@ static int probe_prog_bind_map(void) }; int ret, map, prog, insn_cnt = ARRAY_SIZE(insns); - map = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(int), 32, 1, NULL); + map = bpf_map_create(BPF_MAP_TYPE_ARRAY, "bind_map_detect", sizeof(int), 32, 1, NULL); if (map < 0) { ret = -errno; cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); From patchwork Fri Feb 4 22:58:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12735791 X-Patchwork-Delegate: bpf@iogearbox.net 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 BB462C4332F for ; Fri, 4 Feb 2022 22:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377531AbiBDW6i (ORCPT ); Fri, 4 Feb 2022 17:58:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30539 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377743AbiBDW6e (ORCPT ); Fri, 4 Feb 2022 17:58:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644015513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+LOflVIKz+gCbrlxQKB68Ohtlehw+OxBW97y22Jm7KQ=; b=ZZRvmnVcQdR2UadNVp5B651Ik4svt9c8iWUqXEO9ELWyXXjPry4AFmHKzKgduMx4s8kzyk nHoX6kIdHTaZgwGzlFR7aRKJY1HWd2YMCDZfNe/FTnEH7V9pd6w0CIoFdjEA8KcIFWHfnY pHpJr2nWmY8eSTYNd/juRsf09fbmekY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648--rabi5v1NkeMpMmbB8Q3ow-1; Fri, 04 Feb 2022 17:58:32 -0500 X-MC-Unique: -rabi5v1NkeMpMmbB8Q3ow-1 Received: by mail-ed1-f72.google.com with SMTP id w23-20020a50d797000000b00406d33c039dso3995284edi.11 for ; Fri, 04 Feb 2022 14:58:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+LOflVIKz+gCbrlxQKB68Ohtlehw+OxBW97y22Jm7KQ=; b=LVZAi3rXh0LKDZEH0upEQ6k13YCD2K2XVzAxULzjSzmqyziUTY7+rt3IGsSPK2wSLi P92Rt/FfMtSYB6jE7h3oyw7DtqKo5Zm2vre9Ej/KRvAQxp2O2X1ko1mxTDnyaR/BqoKP /S+8JnQpTRl/PurH52Gh6QTbS2OljMy5Gs8TO1lsvyAY3zmh2Z8nZCbin73HBaU7cKkb e0PfGcqYpSQLNNzN+h5e439ghn2V9y8J5YjvoK3ItD52SwfqyPlmCQABhY2gZacwkIy0 XDz0YScbpynCzTRom+CVJvi2fuRJz+vlGjYXrNl8udxJhOyIf+FgFC0jx2VDIWA+6rh8 NbkQ== X-Gm-Message-State: AOAM533zfhx079uiXBMB1BQ7po2dwmhzr03FKIu7SBAfcsGiZfnWOXiM z3EYGiXG4QEhcvKbRLlQvrqySTZKgGA0F2EyXCKeLh5ydCrkBpuGFl+0d+U42lxcXxQauSvh2up LjT14dp5KQFlw X-Received: by 2002:a17:906:5d0f:: with SMTP id g15mr937014ejt.751.1644015511280; Fri, 04 Feb 2022 14:58:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6IL8n9tVhuRgQ3jvRArA9AOU5deGUjVMA0DGzi3+xQc/p0kKsKg+8zmN8UUUUXnmf8QAvww== X-Received: by 2002:a17:906:5d0f:: with SMTP id g15mr936998ejt.751.1644015511146; Fri, 04 Feb 2022 14:58:31 -0800 (PST) Received: from krava.redhat.com ([83.240.63.12]) by smtp.gmail.com with ESMTPSA id gh14sm1060169ejb.126.2022.02.04.14.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 14:58:30 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Jakub Kicinski , Jiri Pirko Subject: [PATCH bpf-next 2/3] selftests/bpf/test_offload.py: Add more base maps names Date: Fri, 4 Feb 2022 23:58:22 +0100 Message-Id: <20220204225823.339548-2-jolsa@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204225823.339548-1-jolsa@kernel.org> References: <20220204225823.339548-1-jolsa@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Adding more base maps that can show in bpftool map output, so we can properly filter them out. This fixes for me following test_offload.py failure: Test bpftool bound info reporting (own ns)... FAIL: 3 BPF maps loaded, expected 2 File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1177, in check_dev_info(False, "") File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 645, in check_dev_info maps = bpftool_map_list(expected=2, ns=ns) File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 190, in bpftool_map_list fail(True, "%d BPF maps loaded, expected %d" % File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 86, in fail tb = "".join(traceback.extract_stack().format()) Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/test_offload.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index edaffd43da83..0cf93d246804 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -769,7 +769,11 @@ skip(ret != 0, "bpftool not installed") base_progs = progs _, base_maps = bpftool("map") base_map_names = [ - 'pid_iter.rodata' # created on each bpftool invocation + # created on each bpftool invocation + 'pid_iter.rodata', + 'bind_map_detect', + 'global_data', + 'array_mmap', ] # Check netdevsim From patchwork Fri Feb 4 22:58:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12735803 X-Patchwork-Delegate: bpf@iogearbox.net 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 0E0E9C433EF for ; Fri, 4 Feb 2022 22:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377157AbiBDW7C (ORCPT ); Fri, 4 Feb 2022 17:59:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35577 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377789AbiBDW6k (ORCPT ); Fri, 4 Feb 2022 17:58:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644015520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BuPkY8aF8foCy1xMQ7K88ilNkVFxYvJg6UfhArqX/OE=; b=Uf4GhKQM72VBnj4reaFT9Hh8XiABYb70xUid7/lzJala96fTzzCDu9jGHX2E7phCXwyWnK MMpk0qAizvf61ZufbujqDvD2e7ul0MRkXLTBl0e2+xp2dGR3LO3UN+nCqA6hG/3Yy9WFQI Pvz5pP8cfuf/Sw6PiTyPldcXi2yClXg= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-575-0OhuUFbFMgi2-oot6MyMrw-1; Fri, 04 Feb 2022 17:58:38 -0500 X-MC-Unique: 0OhuUFbFMgi2-oot6MyMrw-1 Received: by mail-ed1-f71.google.com with SMTP id o25-20020a056402039900b0040631c2a67dso3944458edv.19 for ; Fri, 04 Feb 2022 14:58:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BuPkY8aF8foCy1xMQ7K88ilNkVFxYvJg6UfhArqX/OE=; b=yhc7d2d8j62ClmB6sG6EW3aB8rM31a6fayPD6WEnk093krmP6S9zBpYj1jgQFzsdPc 1Gv4X++eW+Vojl9KoZPUyjXdxAJ26uvsULFnHcgutqHcKVkHeGXo48idPB216FNwIlns jhID+cOYG4/qTEsBA2xVl5LQPu991CvXyPC0+V3JhEP0EW3ZyvA7M5uLklt18e20l/ET IPqrhPJPYqlq7JdFTxD2QTRWjnGLqSBS+5uP6NWwBuM3AQnM/1BCBcK1MytGm9gP/o8m YE2d0t0267FpOC9SqmOuwr8Xy+pt6da1vXMrIpSAX8OteXTrn3T2nDCITKQdUqhLtagX 0TaQ== X-Gm-Message-State: AOAM533qu0JraN/m/wqPRy3bJvTlfladrd1xFOoH6JeAPEi6oHvrx5B1 umxk9AqQecEwar9XYujgr1K7QNHeVBsZLU/sFvGTo5jQ8Rl1OPFLbAVXYrFpDIuftjjlqr/NIXk AgOFqPG9VSH9aVpEA X-Received: by 2002:a17:907:8a1a:: with SMTP id sc26mr989589ejc.334.1644015517721; Fri, 04 Feb 2022 14:58:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfMC0jfCBGSPIZgj8KIZhO3L2DqSwEXEGUdXnhN74v25kVKO9x+CidEyZ1jI72iCp5fKT4dw== X-Received: by 2002:a17:907:8a1a:: with SMTP id sc26mr989567ejc.334.1644015517562; Fri, 04 Feb 2022 14:58:37 -0800 (PST) Received: from krava.redhat.com ([83.240.63.12]) by smtp.gmail.com with ESMTPSA id d5sm1388884edz.78.2022.02.04.14.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 14:58:37 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Jakub Kicinski , Jiri Pirko Subject: [PATCH bpf-next 3/3] bpftool: Fix pretty print dump for maps without BTF loaded Date: Fri, 4 Feb 2022 23:58:23 +0100 Message-Id: <20220204225823.339548-3-jolsa@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220204225823.339548-1-jolsa@kernel.org> References: <20220204225823.339548-1-jolsa@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The commit e5043894b21f ("bpftool: Use libbpf_get_error() to check error") forced map dump with pretty print enabled to has BTF loaded, which is not necessarily needed. Keeping the libbpf_get_error call, but setting errno to 0 because get_map_kv_btf does nothing for this case. This fixes test_offload.py for me, which failed because of the pretty print fails with: Test map dump... Traceback (most recent call last): File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1251, in _, entries = bpftool("map dump id %d" % (m["id"])) File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 169, in bpftool return tool("bpftool", args, {"json":"-p"}, JSON=JSON, ns=ns, File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 155, in tool ret, stdout = cmd(ns + name + " " + params + args, File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 109, in cmd return cmd_result(proc, include_stderr=include_stderr, fail=fail) File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 131, in cmd_result raise Exception("Command failed: %s\n%s" % (proc.args, stderr)) Exception: Command failed: bpftool -p map dump id 4325 Fixes: e5043894b21f ("bpftool: Use libbpf_get_error() to check error") Signed-off-by: Jiri Olsa --- tools/bpf/bpftool/map.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c index c66a3c979b7a..2ccf85042e75 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c @@ -862,6 +862,7 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr, prev_key = NULL; if (wtr) { + errno = 0; btf = get_map_kv_btf(info); err = libbpf_get_error(btf); if (err) {