Received: by 10.223.185.116 with SMTP id b49csp6980433wrg; Wed, 28 Feb 2018 20:22:17 -0800 (PST) X-Google-Smtp-Source: AG47ELuHU96rI3fXWywbrhxrapgZ/7My6uXd/1b+vPjOCgCNM9O3Ib4gqFnVXDTEkPYP8s73wfjV X-Received: by 2002:a17:902:a985:: with SMTP id bh5-v6mr597430plb.230.1519878137022; Wed, 28 Feb 2018 20:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519878136; cv=none; d=google.com; s=arc-20160816; b=UpDVSW3QVMn0fr2oIahsyNAybyHWkQfee3Yz+1H/CAsvJoPlP+Gk0YuDagl6SNgL53 vr7Ugneu6RjQwQsYcYe/i0xPZEzvhiGc5oO7+4nd54492HA4YdQrFUcbgTf7D3SsKHbm z7/75DKL0JJ19Z3C0VE9begbstp5PYrADD7rvwP6CQb5L0QzEGd27OT9KAjbkGscY9nb iwmtORrus+iNBEc3oXmh3ksy1hGwyW6hxTpbUPXnOJpR6leAQybcdOBz9817DAq9mHFT LwKCRIEyW4INfMc9Py9CYvnyHqdcBXkoBx009bwJmzt1+Jo0trXU0RnGpkVjeYqE+lK4 /rQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix :arc-authentication-results; bh=bbw3U7F0s9WD5uVCINqYt9RmEud5CaoVDQztBARdzvY=; b=DNtmz4PtyTuF0JQ/yEQygGWA/2m4ZeRfzDL+2Nd4rWF+CAQudgkifKw4pAUkTocPJq gQ/OpV09MdcYIePSbFuLHZeWBRGz6p7uNPKj49wsB0A6lQx/KBaC2Wey7wXn6RfsVBWR w/5v4nD875bpy2tOq6smDSXhGr5cXzPE4i3NvrrFlnNTDpiVlGIs3oh6te3ntKqrP9yr cbUB6xOvfxeDdkU6E5R520EA91IUNQ6fXjtP+HNy0l1XRL1HPhBLwoVDBqOj3tp6NRU/ mDvieHLmm59/ucV93NlxNogCq/YcGGPJyUn2wx6Xeb0kqo2TsEJBeQLPyclq8hKmQGhK B8bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si1964022pgn.488.2018.02.28.20.22.02; Wed, 28 Feb 2018 20:22:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965923AbeCAEUe (ORCPT + 99 others); Wed, 28 Feb 2018 23:20:34 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:42396 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965848AbeCAET7 (ORCPT ); Wed, 28 Feb 2018 23:19:59 -0500 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w214EuFS008281 for ; Wed, 28 Feb 2018 20:19:59 -0800 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2gea1dr1qa-5 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 20:19:59 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB01.TheFacebook.com (192.168.16.11) with Microsoft SMTP Server id 14.3.361.1; Wed, 28 Feb 2018 20:19:57 -0800 Received: by devbig500.prn1.facebook.com (Postfix, from userid 572438) id 68BC721813BE; Wed, 28 Feb 2018 20:19:57 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Alexei Starovoitov Smtp-Origin-Hostname: devbig500.prn1.facebook.com To: CC: , , , , , , , , Smtp-Origin-Cluster: prn1c29 Subject: [PATCH bpf-next 4/5] libbpf: add bpf_raw_tracepoint_open helper Date: Wed, 28 Feb 2018 20:19:56 -0800 Message-ID: <20180301041957.399230-5-ast@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180301041957.399230-1-ast@kernel.org> References: <20180301041957.399230-1-ast@kernel.org> X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-01_02:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 11 +++++++++++ tools/lib/bpf/bpf.c | 10 ++++++++++ tools/lib/bpf/bpf.h | 1 + 3 files changed, 22 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index db6bdc375126..50bf5f9054da 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -94,6 +94,7 @@ enum bpf_cmd { BPF_MAP_GET_FD_BY_ID, BPF_OBJ_GET_INFO_BY_FD, BPF_PROG_QUERY, + BPF_RAW_TRACEPOINT_OPEN, }; enum bpf_map_type { @@ -133,6 +134,7 @@ enum bpf_prog_type { BPF_PROG_TYPE_SOCK_OPS, BPF_PROG_TYPE_SK_SKB, BPF_PROG_TYPE_CGROUP_DEVICE, + BPF_PROG_TYPE_RAW_TRACEPOINT, }; enum bpf_attach_type { @@ -143,6 +145,7 @@ enum bpf_attach_type { BPF_SK_SKB_STREAM_PARSER, BPF_SK_SKB_STREAM_VERDICT, BPF_CGROUP_DEVICE, + BPF_RAW_TRACEPOINT, __MAX_BPF_ATTACH_TYPE }; @@ -320,6 +323,10 @@ union bpf_attr { __aligned_u64 prog_ids; __u32 prog_cnt; } query; + + struct { + __u64 name; + } raw_tracepoint; } __attribute__((aligned(8))); /* BPF helper function descriptions: @@ -1106,4 +1113,8 @@ struct bpf_cgroup_dev_ctx { __u32 minor; }; +struct bpf_raw_tracepoint_args { + __u64 args[0]; +}; + #endif /* _UAPI__LINUX_BPF_H__ */ diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 592a58a2b681..4cbe7b6afcc0 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -428,6 +428,16 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len) return err; } +int bpf_raw_tracepoint_open(const char *name) +{ + union bpf_attr attr; + + bzero(&attr, sizeof(attr)); + attr.raw_tracepoint.name = ptr_to_u64(name); + + return sys_bpf(BPF_RAW_TRACEPOINT_OPEN, &attr, sizeof(attr)); +} + int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) { struct sockaddr_nl sa; diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 8d18fb73d7fb..f672d39bd9fa 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -79,4 +79,5 @@ int bpf_map_get_fd_by_id(__u32 id); int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt); +int bpf_raw_tracepoint_open(const char *name); #endif -- 2.9.5