From patchwork Tue Jun 14 23:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Delyan Kratunov X-Patchwork-Id: 12881693 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 A3A8EC43334 for ; Tue, 14 Jun 2022 23:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiFNXKw (ORCPT ); Tue, 14 Jun 2022 19:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239660AbiFNXKv (ORCPT ); Tue, 14 Jun 2022 19:10:51 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9543352E55 for ; Tue, 14 Jun 2022 16:10:47 -0700 (PDT) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25EMd1rW002772 for ; Tue, 14 Jun 2022 16:10:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=facebook; bh=GMdUAw8wuRykvY/1Ylxh/osEmvf28cBu/w57NOBRb3U=; b=PmzP1iAhB+zSznDvQmP/SyE76apOyHWT9rcoBB2t2RgXjEujPwoec74N3/UqU+q+mU3X Mqqbzwp5T1xFH0oQPR8urwb1rbuOopsozMLHlT1C6DAFXmnAE+gQhHXkObkv+O7uuNkA Ui90oyO6y3/t1+xuNKhV1sQfHUQ5lB8jmnQ= Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3gp8aw1uet-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 14 Jun 2022 16:10:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVzhhyHykRk2QYyGf+maUPIvAS/yPyJKMqDH3J4DbZdkK1SqM2XawH9OYxNKMV3nI8ZWg8JGGhfCpD/9aMGg7fKU8Wyx78b96IHYrqzZM/Vvv3hD/QzFhv8613HcdGHEr4xcqAKQWbriIdofvd1ip6yTBsBMxSB5eX7iMDakWNcT96J9g+ifFFxdwPGiCG7EAgMoaLRE1BzIO+4nuJXCAbfZxGJqsApfRt4i3sLlxw+/84P9f9oKZLyO58F/nPwL1Upd0OVxHmPJNnMOJaw+tql724Yf/all6XhVWC8zEr53b8YQhRWTM+5N74W88XKUarMXRjcbJSsg/VXluxf5Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GMdUAw8wuRykvY/1Ylxh/osEmvf28cBu/w57NOBRb3U=; b=hUOfbDLEtiCXao04pCFuqt0usk1Nw//5rn95+dSGSLsq6ciNpUs5O0xVsrYDYTxCShii/BX5S5Cj9FE2Yir7tBW9NL8kg2//SPVq/t4wf9KNIOzlpAHdYQnj9Pvh2eE0IDo2JT5kDtZ7Qdtl7Z9NFlHY0FDE76+CSYfdnEe0vsA1aJV7hT2OtSN6cPnuAg75yvuPjPYqwizolT5ozgh0f1I4N/fHx7BRMU5T54tWHlQ2us1tB/J5oy3SgZzk35wqA+u3YHodRc5v7FBRLQnezKYgQ44sWpB8TfYkl9hCMNCxswTM0U/d3wVLHGFAMqvIfRRtYsUVFnfre7V4tf0CcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fb.com; dmarc=pass action=none header.from=fb.com; dkim=pass header.d=fb.com; arc=none Received: from SJ0PR15MB5154.namprd15.prod.outlook.com (2603:10b6:a03:423::6) by MW5PR15MB5220.namprd15.prod.outlook.com (2603:10b6:303:1a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.20; Tue, 14 Jun 2022 23:10:43 +0000 Received: from SJ0PR15MB5154.namprd15.prod.outlook.com ([fe80::8910:e73d:9868:600b]) by SJ0PR15MB5154.namprd15.prod.outlook.com ([fe80::8910:e73d:9868:600b%9]) with mapi id 15.20.5332.016; Tue, 14 Jun 2022 23:10:42 +0000 From: Delyan Kratunov To: "daniel@iogearbox.net" , "ast@kernel.org" , "andrii@kernel.org" , "bpf@vger.kernel.org" Subject: [PATCH bpf-next v4 1/5] bpf: move bpf_prog to bpf.h Thread-Topic: [PATCH bpf-next v4 1/5] bpf: move bpf_prog to bpf.h Thread-Index: AQHYgEP46wQKNvzaCkWGNLX/L1XEsA== Date: Tue, 14 Jun 2022 23:10:42 +0000 Message-ID: <3ed7824e3948f22d84583649ccac0ff0d38b6b58.1655248076.git.delyank@fb.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 193da1b8-9bc9-4792-792a-08da4e5b1afe x-ms-traffictypediagnostic: MW5PR15MB5220:EE_ x-microsoft-antispam-prvs: x-fb-source: Internal x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: p4vEF2ETX5UtbxxZTmqe0Y/RdPxDFGqbIdjGnihq20F5jdJD3DrVfGReCvJo/6l100CUve8i0Urt+L5V4ncjaHexZWyyFFrFiOu3AFf34oVd9PfNeCbh6yR7GbHv5D2WaBthEuPjYHeM6LNQIEm+5N+QVrSVxMNmKqJhAVj2uXAtCfDyBu6k3fFPMLxfFA70qVLGnaNurS/Vu1iSHxxw4V9NcOS4SdDEJZjLfCYBn+VbDlrxbEnkbBRuhumikViFSAUqk6YosYX+lUIxP+TZZ5gHsvxDJE1X8PSSB1UrHqeNaRQcibpQoDz1M4cRUSjvCn3WrrJtYk4KmSpsEUuk0O0f75ftWp4tRgxfyCdV4PrS1CYYGlZ9NgVJvuX52c0xJ0TaHjiLrXFIk7qqYaWOYvQIdhiaN3SMfwcYb++/JT89XUJpPhboMeS+TIZzzwoyN3nxJKqzw6IdLtvhXfmfJ1tbPxqhtsXzmF4bLpxLYgeW5Qzfr2Q1WGly/kzrvsy8Vu7lu020GXvvsGnzWzpqH6h5LNmcVqlGx+yzE8dmSOJAj7Vm8OA1pusQJbbZXb1KaF8DtZA+CChui1DfbW3drnnmCcST2GJt7f2Hb1D+Qj6dT3UjkHLXs1d9dIFJEhYhT5ovKgXozCk6YY/5LhLLhjnrFfuJadSTxS1yKiRxPeELH4kSD8oQX7O/lQ5qYx8hg9lpeR+6r63pE1awB+wVDg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR15MB5154.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(186003)(8936002)(5660300002)(122000001)(38100700002)(83380400001)(6506007)(6486002)(36756003)(508600001)(38070700005)(6512007)(71200400001)(66946007)(316002)(66476007)(2616005)(2906002)(64756008)(66446008)(76116006)(8676002)(91956017)(66556008)(86362001)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?Ef/wOsMeJ6BrtU2PUZxlOiC?= =?iso-8859-1?q?2pnxSyFYxM3k10urEpvPCLwRRbo2oCL1X8HdOoiiozYVGWMKblUk1MdvQkos?= =?iso-8859-1?q?AVZOhTtM/QrOSZRGPnqGjSrpBw4S0AnC9ecscBlweKD9PNfeavFILd/76vyY?= =?iso-8859-1?q?3Jl3fTBTwTTiKpbY3lsfufDFAn1VH50tnKvp8T06/K7caefzSCqtgtxzrjQy?= =?iso-8859-1?q?zd6LfGAA2hv8N1ta6soRz6tPOX5JRKWehWm29FNww0Gdv3WhLXq+T50KOEyM?= =?iso-8859-1?q?9lgA+l9gGLgm4bMkTRHZhyJkRB7dvAT3cK57nH/pDsvDm7fWU70Pcl6sl2rk?= =?iso-8859-1?q?73d0AlwfrvTSh0gX/6pczCS1SoWXnVMFaeKhi01GW13JA9yldwiBAxnrtEEM?= =?iso-8859-1?q?cNLUr2jF2vWjXOQIO0rscs67AHGb5VPW0bfHFct3y7XMk7lSABKKn5Nt6Uwl?= =?iso-8859-1?q?udCYijWnoUFNvoLL7rNOh1Ju+FLXQRcsCo92KcMXrz7UsJuq2UYDLR6Fe9wN?= =?iso-8859-1?q?jvst9WCBjKyQkB96XAeAFnbNBH93UGDRNWVcSh3oODL6pKx0Vh6/FO4S2BqI?= =?iso-8859-1?q?MT3RHJ3SzNHKlrhvHoxBSGJwgZyppSIWNpMqe1lx8H+6a+9FppW//qtCQ7qa?= =?iso-8859-1?q?GuKesWRznFVlsGvH0s1KB/d7x1UY4TrgI1curLezk5qN6+ZOo76dBH6Lx0a/?= =?iso-8859-1?q?UACtXzcV9HfA6ABn/haklUXrczo6QPXRMnOm/GCilwAXacQe4q2NuHhXZxb/?= =?iso-8859-1?q?hwmbPIlK58EhdOj25Mm2yZwE2D1fHT9BoUq/mM6KV5vsqLkbh/DhKnz3lxMG?= =?iso-8859-1?q?9lAUFQwgITWpEHsJ1NMgkR2rssWXLQPZQEFqPK5XKS9lT4WAGkGyUYTfBGXB?= =?iso-8859-1?q?z+fhcweOznOOONycj8x6oWzWBH1ow9iGOXJm/EW8192SBaHc2+pK71H+8Tm6?= =?iso-8859-1?q?FBTqDfBSDDTxbsLcT6wuxyc5f+Tb5oBipqXnDJPqFqjFqjA9MWrNNJpRgEn3?= =?iso-8859-1?q?1MkcB0TmOTq1rWXmhegTcKS5JxleGcMzT0PPhQxfyJFD85jCxeLeHm44AI71?= =?iso-8859-1?q?wrQawYK0H6G2xhUgcneUlvZfuMgll2nEqn6bHGCfao7L4c2HmnQR7ffcJDvp?= =?iso-8859-1?q?3nsb06qjqy3N1czuJ8J1WIo8S1TQUkdAbFk4IrEu0Yk/TF+pNqXKlhbkue55?= =?iso-8859-1?q?FQMLzuCDBRzK0OKsi4LZwM10/8uMRytIO/bA231glJr2oC64rxvv7wmUsxZ1?= =?iso-8859-1?q?Ii54lCHTc4LrggF9EcWA/98UZujGouSawKglHww05fQDxKi/gFwdpfsnj4Yr?= =?iso-8859-1?q?ICvZbd46tSTtvIWTYhoe+kaMabFQLPA3SbLbNZRzC5elJVG9Bolx5l07DtUB?= =?iso-8859-1?q?d7gcuB7aR3YQTMAkt0ONEdRh/krqKAFIhWIt1L1Ky+5A9Lg+fKb5RAvDx1v1?= =?iso-8859-1?q?FevNia69xiFZqe35lp3NaA462PvovOvat6GiHd+NgKPmYctxGPZivq0lef33?= =?iso-8859-1?q?GhUe8pJozvtLSvMYiW7EzbrB/mOdOBbpT2DFUdlb/SNYlmiO10nC0BfA3Tvv?= =?iso-8859-1?q?u4T/AfmER/wbVcpvGDIEbS5Nmqc+egPQpHd5Nqy9oSCxoCrxbSkBOSWE4A6y?= =?iso-8859-1?q?z/Gqc0brWnwjdRJZLStSqWJ/+Z4XmCeJxo/wgCV7fxLjVP+VVGpZi8XaJkD6?= =?iso-8859-1?q?KZzKeofPjK3rpPabVeznEwWbnPZCVyKqtxkGza+VXy8h0f4cMoywPNT6vhR4?= =?iso-8859-1?q?HnqEitQTjVGZ6m5XD8sb64gfAIsdp8su7R9B5LsIYsyt7IOaxEkyQbqDwzv8?= =?iso-8859-1?q?noDtQXH1TBkfv0GZN8Mleki6PJRLX?= MIME-Version: 1.0 X-OriginatorOrg: fb.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR15MB5154.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 193da1b8-9bc9-4792-792a-08da4e5b1afe X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jun 2022 23:10:42.7909 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6hG/mL60f6L97dO7RRMu1AjmPjiyIost7br9tLKCUtPNGkuG69bOxx58yfu6DWql X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR15MB5220 X-Proofpoint-GUID: 07wj0KUjo4ZkBvokf6IWrD5VBr9F81Zp X-Proofpoint-ORIG-GUID: 07wj0KUjo4ZkBvokf6IWrD5VBr9F81Zp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-14_10,2022-06-13_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net In order to add a version of bpf_prog_run_array which accesses the bpf_prog->aux member, bpf_prog needs to be more than a forward declaration inside bpf.h. Given that filter.h already includes bpf.h, this merely reorders the type declarations for filter.h users. bpf.h users now have access to bpf_prog internals. Signed-off-by: Delyan Kratunov --- include/linux/bpf.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/filter.h | 34 ---------------------------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 8e6092d0ea95..69106ae46464 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -5,6 +5,7 @@ #define _LINUX_BPF_H 1 #include +#include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include @@ -1084,6 +1086,40 @@ struct bpf_prog_aux { }; }; +struct bpf_prog { + u16 pages; /* Number of allocated pages */ + u16 jited:1, /* Is our filter JIT'ed? */ + jit_requested:1,/* archs need to JIT the prog */ + gpl_compatible:1, /* Is filter GPL compatible? */ + cb_access:1, /* Is control block accessed? */ + dst_needed:1, /* Do we need dst entry? */ + blinding_requested:1, /* needs constant blinding */ + blinded:1, /* Was blinded */ + is_func:1, /* program is a bpf function */ + kprobe_override:1, /* Do we override a kprobe? */ + has_callchain_buf:1, /* callchain buffer allocated? */ + enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */ + call_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */ + call_get_func_ip:1, /* Do we call get_func_ip() */ + tstamp_type_access:1; /* Accessed __sk_buff->tstamp_type */ + enum bpf_prog_type type; /* Type of BPF program */ + enum bpf_attach_type expected_attach_type; /* For some prog types */ + u32 len; /* Number of filter blocks */ + u32 jited_len; /* Size of jited insns in bytes */ + u8 tag[BPF_TAG_SIZE]; + struct bpf_prog_stats __percpu *stats; + int __percpu *active; + unsigned int (*bpf_func)(const void *ctx, + const struct bpf_insn *insn); + struct bpf_prog_aux *aux; /* Auxiliary fields */ + struct sock_fprog_kern *orig_prog; /* Original BPF program */ + /* Instructions for interpreter */ + union { + DECLARE_FLEX_ARRAY(struct sock_filter, insns); + DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); + }; +}; + struct bpf_array_aux { /* Programs with direct jumps into programs part of this array. */ struct list_head poke_progs; diff --git a/include/linux/filter.h b/include/linux/filter.h index ed0c0ff42ad5..d0cbb31b1b4d 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -559,40 +559,6 @@ struct bpf_prog_stats { struct u64_stats_sync syncp; } __aligned(2 * sizeof(u64)); -struct bpf_prog { - u16 pages; /* Number of allocated pages */ - u16 jited:1, /* Is our filter JIT'ed? */ - jit_requested:1,/* archs need to JIT the prog */ - gpl_compatible:1, /* Is filter GPL compatible? */ - cb_access:1, /* Is control block accessed? */ - dst_needed:1, /* Do we need dst entry? */ - blinding_requested:1, /* needs constant blinding */ - blinded:1, /* Was blinded */ - is_func:1, /* program is a bpf function */ - kprobe_override:1, /* Do we override a kprobe? */ - has_callchain_buf:1, /* callchain buffer allocated? */ - enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */ - call_get_stack:1, /* Do we call bpf_get_stack() or bpf_get_stackid() */ - call_get_func_ip:1, /* Do we call get_func_ip() */ - tstamp_type_access:1; /* Accessed __sk_buff->tstamp_type */ - enum bpf_prog_type type; /* Type of BPF program */ - enum bpf_attach_type expected_attach_type; /* For some prog types */ - u32 len; /* Number of filter blocks */ - u32 jited_len; /* Size of jited insns in bytes */ - u8 tag[BPF_TAG_SIZE]; - struct bpf_prog_stats __percpu *stats; - int __percpu *active; - unsigned int (*bpf_func)(const void *ctx, - const struct bpf_insn *insn); - struct bpf_prog_aux *aux; /* Auxiliary fields */ - struct sock_fprog_kern *orig_prog; /* Original BPF program */ - /* Instructions for interpreter */ - union { - DECLARE_FLEX_ARRAY(struct sock_filter, insns); - DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); - }; -}; - struct sk_filter { refcount_t refcnt; struct rcu_head rcu;