From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3CA7C282C8 for ; Mon, 28 Jan 2019 17:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AB9020989 for ; Mon, 28 Jan 2019 17:21:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JrL8DAr3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731823AbfA1RVX (ORCPT ); Mon, 28 Jan 2019 12:21:23 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:52887 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbfA1RVW (ORCPT ); Mon, 28 Jan 2019 12:21:22 -0500 Received: by mail-qt1-f202.google.com with SMTP id w15so21393079qtk.19 for ; Mon, 28 Jan 2019 09:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=h2rOYk2ykSjcwTUKkgpJgQIO+LZn79UIHdro90qbeNI=; b=JrL8DAr34nm83tkCWaWCTiTQvqUK6/S+5EXtANxrpDHjTKCrRyKKjy2nDpypw0gfwx zALXCkqDH2dkY7i9hB26BG9h/FDcAFnAQWXrSd9I5op3bBAx6Su8MyabOmok4YBIWzO2 plCQzX3O/FfcVJ6Y++yz+5t4mINJ/gd1wZUcOSNtJZlCOv1LWwL84UF2B2iDbPhlRNTW HqnCD6dlWPg1smk92tS+lVB2oujuo3rWlvlM+JdiEWmgYEX06iweQ5+NtAuRariLpKdg kVUb+Jvn6tXem2ltsWGpDHuxn7t1QB06vWI9VlqfLiuk5K5Ncd1TiecT51jwMDZqRfhY A0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=h2rOYk2ykSjcwTUKkgpJgQIO+LZn79UIHdro90qbeNI=; b=N95pK4P12tAOEhRCttseqFXag9XphGYCPh3kYTNRI6+naBs2NEd9dGPypFxPvtt8A4 nQTocgU/aDOpGeWeE+Qxa0p1vhWPPghVgO85PdwhKBoWKSw5yLlXQS2ZaP2eRB9oZGdb cUIKSnLt1DQg4BdArNHzwMZUgGPgKE7q/7qkWGwExPR7mni/IklbNn9RkYJc7PJtRy6X g/5U8B147F32F0Pxn1OQLy+eHL9ZdVAENaOifwUGT1wqWMLgXcvH0w8jzbd8pJVxc7Fv YE5D9CYKFkthgpkEorJTyhOfrQWlomyfyR/7LJzTjZbjF3DjS+Xlsv+ziX4/0B3YNmk6 tsyA== X-Gm-Message-State: AHQUAuaLOhRQdaU8txYRFv6cYiJXDQ09JfwWvgtCu4OM5W5KmODs8qlh q6G226KX5pn3qH9nR8fKrKj1AMOBXfhTgxfLVz60kne1ApQDdQVKyJoV1jJF4CVM+cr4XbSM4Z0 HrHZHlci4xldvncXDwrX8a4H8ascg0nup29/e4lxLYg3WPTP/WBHXAA== X-Google-Smtp-Source: ALg8bN5hUSB3S03jFMwyZhJDXha0nrcN5LpiITXD7xxNx1cvwMbJn8hiko5iUqEq8X2DRw0+mcikm2A= X-Received: by 2002:ac8:292a:: with SMTP id y39mr504857qty.4.1548696081639; Mon, 28 Jan 2019 09:21:21 -0800 (PST) Date: Mon, 28 Jan 2019 09:21:14 -0800 Message-Id: <20190128172119.12105-1-sdf@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog Subject: [PATCH bpf-next v3 0/5] skip verifier/map tests if kernel support is missing From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, Stanislav Fomichev Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If test_maps/test_verifier is running against the kernel which doesn't have _all_ BPF features enabled, it fails with an error. This patch series tries to probe kernel support for each failed test and skip it instead. This lets users run BPF selftests in the not-all-bpf-yes environments and received correct PASS/NON-PASS result. See https://www.spinics.net/lists/netdev/msg539331.html for more context. The series goes like this: * patch #1 skips sockmap tests in test_maps.c if BPF_MAP_TYPE_SOCKMAP map is not supported (if bpf_create_map fails, we probe the kernel for support) * patch #2 skips verifier tests if test->prog_type is not supported (if bpf_verify_program fails, we probe the kernel for support) * patch #3 skips verifier tests if test fixup map is not supported (if create_map fails, we probe the kernel for support) * next patches fix various small issues that arise from the first four: * patch #4 sets "unknown func bpf_trace_printk#6" prog_type to BPF_PROG_TYPE_TRACEPOINT so it is correctly skipped in CONFIG_BPF_EVENTS=n case * patch #5 exposes BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} only when CONFIG_CGROUP_BPF=y, this makes verifier correctly skip appropriate tests v3 changes: * rebased on top of Quentin's series which adds probes to libbpf v2 changes: * don't sprinkle "ifdef CONFIG_CGROUP_BPF" all around net/core/filter.c, doing it only in the bpf_types.h is enough to disable BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} prog types for non-cgroup enabled kernels Stanislav Fomichev (5): selftests/bpf: skip sockmap in test_maps if kernel doesn't have support selftests/bpf: skip verifier tests for unsupported program types selftests/bpf: skip verifier tests for unsupported map types selftests/bpf: mark verifier test that uses bpf_trace_printk as BPF_PROG_TYPE_TRACEPOINT bpf: BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} require cgroups enabled include/linux/bpf_types.h | 2 + tools/testing/selftests/bpf/test_maps.c | 13 +++++- tools/testing/selftests/bpf/test_verifier.c | 45 +++++++++++++++++-- tools/testing/selftests/bpf/verifier/unpriv.c | 1 + 4 files changed, 56 insertions(+), 5 deletions(-) -- 2.20.1.495.gaa96b0ce6b-goog