From patchwork Tue Aug 10 09:28:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iwashima, Kuniyuki" X-Patchwork-Id: 12428437 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=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 41C42C4338F for ; Tue, 10 Aug 2021 09:28:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2104160EE9 for ; Tue, 10 Aug 2021 09:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239027AbhHJJ27 (ORCPT ); Tue, 10 Aug 2021 05:28:59 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:51658 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238989AbhHJJ24 (ORCPT ); Tue, 10 Aug 2021 05:28:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.jp; i=@amazon.co.jp; q=dns/txt; s=amazon201209; t=1628587715; x=1660123715; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9Bxh8ry/x1tZrHm+L6QtJtWoPAnis2YRJ0zchf9s+fA=; b=S5K6eAC1eiUuFUvSSVj6UHDcq8kutwGRuFtuocHxKzX0/a7kgIkhT4WO uYf3PVY5HTHz5btKRyLyex77xlFBP59MDxLUdwW9CPRoO72TCocFJBVdd DV6xxzvWUUECjcgGyPdbnAfj/aMQ32mYgQDzsCCYosMcLIjHTFiNCCrro w=; X-IronPort-AV: E=Sophos;i="5.84,310,1620691200"; d="scan'208";a="131372390" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP; 10 Aug 2021 09:28:34 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-2c665b5d.us-east-1.amazon.com (Postfix) with ESMTPS id 271D2A0507; Tue, 10 Aug 2021 09:28:30 +0000 (UTC) Received: from EX13D04ANC001.ant.amazon.com (10.43.157.89) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 10 Aug 2021 09:28:30 +0000 Received: from 88665a182662.ant.amazon.com (10.43.160.189) by EX13D04ANC001.ant.amazon.com (10.43.157.89) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 10 Aug 2021 09:28:25 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , "Song Liu" , Yonghong Song , John Fastabend , KP Singh CC: Benjamin Herrenschmidt , Kuniyuki Iwashima , Kuniyuki Iwashima , , Subject: [PATCH v4 bpf-next 0/3] BPF iterator for UNIX domain socket. Date: Tue, 10 Aug 2021 18:28:04 +0900 Message-ID: <20210810092807.13190-1-kuniyu@amazon.co.jp> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Originating-IP: [10.43.160.189] X-ClientProxiedBy: EX13D08UWC001.ant.amazon.com (10.43.162.110) To EX13D04ANC001.ant.amazon.com (10.43.157.89) Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net This patch set adds BPF iterator support for UNIX domain socket. The first patch implements it, the second adds "%c" support for BPF_SEQ_PRINTF(), and the third adds a selftest. Changelog: v4: - Check IS_BUILTIN(CONFIG_UNIX) - Support "%c" in BPF_SEQ_PRINTF() - Uncomment the code to print the name of the abstract socket - Mention the LLVM fix in README.rst - Remove the 'aligned' attribute in bpf_iter.h - Keep the format string on a single line v3: https://lore.kernel.org/netdev/20210804070851.97834-1-kuniyu@amazon.co.jp/ - Export some functions for CONFIG_UNIX=m v2: https://lore.kernel.org/netdev/20210803011110.21205-1-kuniyu@amazon.co.jp/ - Implement bpf_iter specific seq_ops->stop() - Add bpf_iter__unix in bpf_iter.h - Move common definitions in selftest to bpf_tracing_net.h - Include the code for abstract UNIX domain socket as comment in selftest - Use ASSERT_OK_PTR() instead of CHECK() - Make ternary operators on single line v1: https://lore.kernel.org/netdev/20210729233645.4869-1-kuniyu@amazon.co.jp/ Kuniyuki Iwashima (3): bpf: af_unix: Implement BPF iterator for UNIX domain socket. bpf: Support "%c" in bpf_bprintf_prepare(). selftest/bpf: Implement sample UNIX domain socket iterator program. include/linux/btf_ids.h | 3 +- kernel/bpf/helpers.c | 14 +++ net/unix/af_unix.c | 93 +++++++++++++++++++ tools/testing/selftests/bpf/README.rst | 38 ++++++++ .../selftests/bpf/prog_tests/bpf_iter.c | 16 ++++ tools/testing/selftests/bpf/progs/bpf_iter.h | 8 ++ .../selftests/bpf/progs/bpf_iter_unix.c | 77 +++++++++++++++ .../selftests/bpf/progs/bpf_tracing_net.h | 4 + 8 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_unix.c