Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp635894imm; Wed, 26 Sep 2018 04:35:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV62NZ5qRbQjlepljppZRjWhtihxXtoKIf0rpUAXnTfhIAXT1e6n2/iqb3H/IWRctCSANIR1F X-Received: by 2002:a63:6946:: with SMTP id e67-v6mr5330538pgc.119.1537961741371; Wed, 26 Sep 2018 04:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537961741; cv=none; d=google.com; s=arc-20160816; b=dueqw1WCg6xJbvkh0NlmvzUYh/hC7+ngu73PoIUvlGoVgaY/z7/18AOeGgsA2lx3ew kkOu9Rn7iKoN3D81ynkJKi8MUBzg63BvySrJHPdlEp/OlwIwrMjzYbdP7oSvVnD5wUIQ A6wZdiKK1OAMruKSZUBADFcFucIDxpx7wWdfNbuGgT19xmR7PhqhpIoltRP1c3g7Sdwz mUJsWauXTrFddmV2Qto2WWfCEGUtptblUEUkdBtb33yuVrCo9vftRbfCLvgDpV4C1zgy aUDYUzwJGTY4TxwwR/CcxIGxITO6jpmy4pIi2A/WZTv0exlvBGyKC2zt5AjPEprkuiV/ MrKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=/w5b3orWvsWy2++OOlSq8pw4gThK+WjZyq2YWkREhGo=; b=q1c1pVPu2/BRbfL8AOhvOjvjMWZE+FEWUq6SIQe21dAXsF06HcAxEtqVuKczzZJI57 rapaKyoZDRRra21/6eDSCoN23cHNsE+nWKCTk/HPLKoWOa3IG5jwNYcLKd5VcvjCDBP6 TzycWXzNcFu/Gtm1tLKunSYaRqSBjNW+SJyjiSj3B3A/c5v9oCeZUh2F0NLu6i+tn+By rmHBZov4QeRw9qqv0kW02ddlqtsAAQa5GMexruAtfdSMqtsET4pgcrwRLgsNW3n8e1Jj 4Y05AWY1csD2SOf4lwc+9RYxOe3ODmlvIRs5GB4hnLE+5f40ICSxLfUA1WlLJZC2gkAX qpYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=h6S17Sb6; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b="RP24/nNt"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go11si5279571plb.69.2018.09.26.04.35.26; Wed, 26 Sep 2018 04:35:41 -0700 (PDT) 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; dkim=pass header.i=@fb.com header.s=facebook header.b=h6S17Sb6; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b="RP24/nNt"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728422AbeIZRrZ (ORCPT + 99 others); Wed, 26 Sep 2018 13:47:25 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33136 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728107AbeIZRqy (ORCPT ); Wed, 26 Sep 2018 13:46:54 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8QBQxpn017644; Wed, 26 Sep 2018 04:34:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=/w5b3orWvsWy2++OOlSq8pw4gThK+WjZyq2YWkREhGo=; b=h6S17Sb6DuSQKSNYh7kPLqtb7jIq6HBJ6zV4iXtE6hkhdzch5MP9NSqEjpITQvzrYFB3 ilXcdKB4Or4kpYdZObFMRVjnRUp5usaBx+XbgvD5HIQL75B18R0Uqq6QxYKQeD35Hdsz 19aj8SjCLe4VGcRmziBcBB4isY7CPEJYInc= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0b-00082601.pphosted.com with ESMTP id 2mqxqpsevd-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 26 Sep 2018 04:34:03 -0700 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.30) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 26 Sep 2018 07:34:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/w5b3orWvsWy2++OOlSq8pw4gThK+WjZyq2YWkREhGo=; b=RP24/nNtUFsSsez+9nmUIXPuWbERG8V5V7YVH7jWMJGv9ReUFCklUmsIv1bhK7624+NWDsbRgGjAW9eUMkvHww7c63i2f/WmaA5jpseEUDmqMZ6cmtPkiReci+LUhhKlV2dGfU/egPVcBVkmvr2XJPxt90EbDRD5l+ApfGlsy0g= Received: from castle.thefacebook.com (2620:10d:c092:200::1:15cb) by BLUPR15MB0162.namprd15.prod.outlook.com (2a01:111:e400:5249::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.20; Wed, 26 Sep 2018 11:34:00 +0000 From: Roman Gushchin To: CC: Song Liu , , , Roman Gushchin , Daniel Borkmann , Alexei Starovoitov Subject: [PATCH v3 bpf-next 09/10] samples/bpf: extend test_cgrp2_attach2 test to use per-cpu cgroup storage Date: Wed, 26 Sep 2018 12:33:25 +0100 Message-ID: <20180926113326.29069-10-guro@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926113326.29069-1-guro@fb.com> References: <20180926113326.29069-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:15cb] X-ClientProxiedBy: AM6P193CA0005.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:3e::18) To BLUPR15MB0162.namprd15.prod.outlook.com (2a01:111:e400:5249::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14754331-c858-4422-b096-08d623a3f4b5 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BLUPR15MB0162; X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0162;3:tPHAoJZWd8Fpm42AmGsI0WWNkM0q3OcKskkZUEWss/6SPAkinYXVN+ZRMP3T5HNOPJV0bc8zeLbYXBD/SnLVBLqMSTdBFifpfIm48P9AUZqNFGwUDyM3ksPeG2+/j+KY4p0I/JPnrIEimDQxDlbLmoyFg11HZQGD80AApoQQkE5LSYzNUHRq9c2H2NP4mgJXgUxfQOyBblfDCRpXRI1pexI2fMaLA59L78Q+fOjM+HVj/CHSAzxDxf4fWNXPGWhK;25:VIBOMnrfLf2j0q/Xwrm6eMISTLZ7g4+8WsWP7/PZ40wbTctnUTG//HbYJHYO3t+5ps5tpAVcHHOfJv+yIgpM16GB1OzFbrJGfxXF2QhsAI4yrb2ROh5j+IT4HEIYBggUaULf00WDUzixQG+uF88wUZNOMJnsfR3Ig+8unqmNUb4wsn8lTGIYZwU9IKJyIkBHH8RX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p0AoC9Ik26a7K87lTp6wRKJwf42H/Qvip95ApHf1EwZkn9n5fss9bCFZK9wqi8k2VDKNWnKUWhmyXuU8N3OgNtUhbMNGXMl1RR5rDmgG2QnTb9Pe6yf0FNvPOjQxsYOpNh0Eod7fhUfzKJScaIoF2SNav5ZqE+q0lBflJKJPh6/nW5IhV6+Pw5D1R9w44Ew1dyZ+ZdwidgMek9xrTpcSniJMZjnB3ojxFj0lca2OI/qx+0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823302057)(3002001)(10201501046)(3231355)(11241501184)(944501410)(52105095)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051);SRVR:BLUPR15MB0162;BCL:0;PCL:0;RULEID:;SRVR:BLUPR15MB0162; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(376002)(136003)(366004)(396003)(39860400002)(199004)(189003)(446003)(16526019)(478600001)(8936002)(46003)(186003)(11346002)(36756003)(52116002)(51416003)(52396003)(76176011)(15760500003)(97736004)(2616005)(4326008)(7736002)(50226002)(305945005)(476003)(2906002)(486006)(106356001)(6512007)(2351001)(48376002)(69596002)(6116002)(50466002)(1076002)(53416004)(47776003)(105586002)(53936002)(6506007)(8676002)(16586007)(386003)(54906003)(25786009)(6486002)(2361001)(81166006)(316002)(81156014)(86362001)(14444005)(5024004)(5660300001)(6916009)(6666003)(34290500001)(68736007)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR15MB0162;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted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ascii?Q?bmiLr70LMefCndYntqlRAPl6hra1k6T8O4JgxGT0VYTLOa5HqMhUwGxz2uSJ?= =?us-ascii?Q?ZsKvl2PkF0QJ+ppji/jFQ7JZysGJQle+9Uw2ZWLk3/FxQxtAQ8QwExLW6VEC?= =?us-ascii?Q?vkLVWGxLnygohCLDdfVDqHF0ytHgnHXtHvGTO+cywJEk56ETlOKHilB8+Ie/?= =?us-ascii?Q?CZXfRwxiu3ULeBJAUgxx9z/sCzPLq5YqIMB3GDvCtGxO1jI4jUKw3Sr4Usi4?= =?us-ascii?Q?xguu0pH3zOu8rEgx9xusAgJR5qD2Z6W5pp+9r4cbTqE+aKQsChmHXAkAfULK?= =?us-ascii?Q?daymYX0g7xq5yUTpHXLXX89+ov4MwDoe9+wC9JcOtOETRmEMLDGaLNuANFH6?= =?us-ascii?Q?c51UX8l+UTdNukBYvmctuewW4+Nwr2pVAEC+3b3oItLnXkEELDttV14UJYkn?= =?us-ascii?Q?gbp3b8paaaIicxjiUmVWxG/q/0LzLlwrCGT5VR8PFm5UiBK8c/Zm3e6M0rtQ?= =?us-ascii?Q?G3rsaWRssvhJhFaeVjkBn0NoNwAIX+fEUCwhKEmNCc4RD+2lx3fTkzMQHPKM?= =?us-ascii?Q?3pCoQ=3D=3D?= X-Microsoft-Antispam-Message-Info: Bog4eQTjmyFBCcQjxsy7EqqW37LQTcKBJJLoB0IPscnD9sTvSNKu94grdzCs3LEd67aJhgYBC13QhhlLGa7oda0n1wpItvwlwrT8jVORpLuhQap6H890y7nrFxto8s1f2EJvqyRax3f8PINJcMvlFuQXeDzFZrSAWC7HloKJOX/+4TbiDn7t/A/ooY60A4AOaROeReJDMvbwC7KrczgVkXAXMrzQ9kIuJ/4QdJwyZe5xdzQHlOMnrkGtrCiOEb6WUdOrsihMFztGCi0jES8vNPum7U7woyJWE2rtbI783/Rxb/au+JdOxxfYqsqPBIi2PRq84KZP9vVt8oVcaazHCsbUfDabirib8ZSuXvxlByk= X-Microsoft-Exchange-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XGeP98TtoalAIlZOyERC316oRFLyDEGj4i3BKPAs8gaMfbHOzrFX+irJBQ3zzyiEW2qq+mF+hLdcejnB1eLbZfDNFoN9ufqJUMiv1/efGgsKP54og= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 11:34:00.3016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14754331-c858-4422-b096-08d623a3f4b5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR15MB0162 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-26_06:,, 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 This commit extends the test_cgrp2_attach2 test to cover per-cpu cgroup storage. Bpf program will use shared and per-cpu cgroup storages simultaneously, so a better coverage of corresponding core code will be achieved. Expected output: $ ./test_cgrp2_attach2 Attached DROP prog. This ping in cgroup /foo should fail... ping: sendmsg: Operation not permitted Attached DROP prog. This ping in cgroup /foo/bar should fail... ping: sendmsg: Operation not permitted Attached PASS prog. This ping in cgroup /foo/bar should pass... Detached PASS from /foo/bar while DROP is attached to /foo. This ping in cgroup /foo/bar should fail... ping: sendmsg: Operation not permitted Attached PASS from /foo/bar and detached DROP from /foo. This ping in cgroup /foo/bar should pass... ### override:PASS ### multi:PASS Signed-off-by: Roman Gushchin Acked-by: Song Liu Cc: Daniel Borkmann Cc: Alexei Starovoitov --- samples/bpf/test_cgrp2_attach2.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/samples/bpf/test_cgrp2_attach2.c b/samples/bpf/test_cgrp2_attach2.c index 180f9d813bca..d7b68ef5ba79 100644 --- a/samples/bpf/test_cgrp2_attach2.c +++ b/samples/bpf/test_cgrp2_attach2.c @@ -209,7 +209,7 @@ static int map_fd = -1; static int prog_load_cnt(int verdict, int val) { - int cgroup_storage_fd; + int cgroup_storage_fd, percpu_cgroup_storage_fd; if (map_fd < 0) map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 8, 1, 0); @@ -225,6 +225,14 @@ static int prog_load_cnt(int verdict, int val) return -1; } + percpu_cgroup_storage_fd = bpf_create_map( + BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, + sizeof(struct bpf_cgroup_storage_key), 8, 0, 0); + if (percpu_cgroup_storage_fd < 0) { + printf("failed to create map '%s'\n", strerror(errno)); + return -1; + } + struct bpf_insn prog[] = { BPF_MOV32_IMM(BPF_REG_0, 0), BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_0, -4), /* *(u32 *)(fp - 4) = r0 */ @@ -235,11 +243,20 @@ static int prog_load_cnt(int verdict, int val) BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), BPF_MOV64_IMM(BPF_REG_1, val), /* r1 = 1 */ BPF_RAW_INSN(BPF_STX | BPF_XADD | BPF_DW, BPF_REG_0, BPF_REG_1, 0, 0), /* xadd r0 += r1 */ + BPF_LD_MAP_FD(BPF_REG_1, cgroup_storage_fd), BPF_MOV64_IMM(BPF_REG_2, 0), BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_local_storage), BPF_MOV64_IMM(BPF_REG_1, val), BPF_RAW_INSN(BPF_STX | BPF_XADD | BPF_W, BPF_REG_0, BPF_REG_1, 0, 0), + + BPF_LD_MAP_FD(BPF_REG_1, percpu_cgroup_storage_fd), + BPF_MOV64_IMM(BPF_REG_2, 0), + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_local_storage), + BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 0x1), + BPF_STX_MEM(BPF_W, BPF_REG_0, BPF_REG_3, 0), + BPF_MOV64_IMM(BPF_REG_0, verdict), /* r0 = verdict */ BPF_EXIT_INSN(), }; -- 2.17.1