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 E8C25C433F5 for ; Tue, 4 Jan 2022 08:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234136AbiADILC (ORCPT ); Tue, 4 Jan 2022 03:11:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56138 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233890AbiADIKt (ORCPT ); Tue, 4 Jan 2022 03:10:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641283848; 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=z04l+1thMGEo6+2wn8HMi5HKrAqA7BNf+MRnLwscczA=; b=f+ccUphmbclKoVmjOTIiD0OpsClWH//sQIMDkK6RufQ8ak+elcUpihHifuWp060GzhKjvX VJZTq79uoCZy1CHCPoXas0wL43dvbbDJepFjsK5joDHSqkIg/fCfgDA/f2dFwIe/LzBdV5 1td4yLDB53lOeREAXMGxOS784WYymZQ= 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-616-L_GKyemCO5Wht1zE1B2jVA-1; Tue, 04 Jan 2022 03:10:47 -0500 X-MC-Unique: L_GKyemCO5Wht1zE1B2jVA-1 Received: by mail-ed1-f70.google.com with SMTP id eg23-20020a056402289700b003f80a27ca2bso24655178edb.14 for ; Tue, 04 Jan 2022 00:10:47 -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=z04l+1thMGEo6+2wn8HMi5HKrAqA7BNf+MRnLwscczA=; b=LtMAIBPt98B3lzQMdkRW+KLgZ1cTrlgaDR4VQvrYyeM+KVUDwPn+PHUad5xHuMaeA+ 0JGYz69+JKWvtdphME9DdETOGEpWi7hZzsy3FV3MqR48B5wNPq3dS/h68SFVvjj0LBal w7Wb1+KHML0HTBMgRvR/vT/LBNJ966Z4lzWSn31B5ZrKHoRRyom1BOkaKdqtuyoddG8a 0CrAHmU/uc/dtRqL030iUGRE3jTG6n/LYx7hJQBahj+3h7k9iO0LmI6lL29uJkpb35je P0M7HMih1zQV9EcyUXV2lFAoQw43GgcPRH2GkQ5RHORzWtc6OXRuR+Zxk+XKREd2Kt5l UQNg== X-Gm-Message-State: AOAM531+m4vA6Etf4x0T6E8iaaZ/lwOxKHu1nOftKh4G6tJhIL6MXcZL jX0zzVEyLbZ9hoXLBzZcmGdKffLnXkVNkQHd1dgnm6FWPn8LJCRgel95Zee7COeHZT0lnZuX4HK WcHouor3mUKPZmCPG8Yt0NiBr X-Received: by 2002:aa7:cada:: with SMTP id l26mr48146086edt.376.1641283845535; Tue, 04 Jan 2022 00:10:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFkiq5V/GxTl7wd6cp9nRQDMK16ZHw3L6bqox/Q7gvurc8JFtIApm+yKLHFcDKbqDu4mUuiw== X-Received: by 2002:aa7:cada:: with SMTP id l26mr48146070edt.376.1641283845430; Tue, 04 Jan 2022 00:10:45 -0800 (PST) Received: from krava.redhat.com (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id 21sm11279609ejx.83.2022.01.04.00.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 00:10:45 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" Subject: [PATCH 10/13] libbpf: Add bpf_link_create support for multi kprobes Date: Tue, 4 Jan 2022 09:09:40 +0100 Message-Id: <20220104080943.113249-11-jolsa@kernel.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220104080943.113249-1-jolsa@kernel.org> References: <20220104080943.113249-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding new kprobe struct in bpf_link_create_opts object to pass multi kprobe data to link_create attr API. Signed-off-by: Jiri Olsa --- tools/lib/bpf/bpf.c | 5 +++++ tools/lib/bpf/bpf.h | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 9b64eed2b003..40cad575ad62 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -848,6 +848,11 @@ int bpf_link_create(int prog_fd, int target_fd, if (!OPTS_ZEROED(opts, perf_event)) return libbpf_err(-EINVAL); break; + case BPF_TRACE_RAW_KPROBE: + attr.link_create.kprobe.addrs = OPTS_GET(opts, kprobe.addrs, 0); + attr.link_create.kprobe.cnt = OPTS_GET(opts, kprobe.cnt, 0); + attr.link_create.kprobe.bpf_cookie = OPTS_GET(opts, kprobe.bpf_cookie, 0); + break; default: if (!OPTS_ZEROED(opts, flags)) return libbpf_err(-EINVAL); diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 00619f64a040..9611023138b1 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -298,10 +298,15 @@ struct bpf_link_create_opts { struct { __u64 bpf_cookie; } perf_event; + struct { + __u64 addrs; + __u32 cnt; + __u64 bpf_cookie; + } kprobe; }; size_t :0; }; -#define bpf_link_create_opts__last_field perf_event +#define bpf_link_create_opts__last_field kprobe.bpf_cookie LIBBPF_API int bpf_link_create(int prog_fd, int target_fd, enum bpf_attach_type attach_type, -- 2.33.1