Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4737502rwb; Tue, 20 Sep 2022 19:53:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4D5v67zGbziB5+KDLYBH0gkTdzyzfWF/JBm5xmtSdJLQ6SWd1jSoBdD2Ti8Djkl0zVDFE+ X-Received: by 2002:a17:907:74a:b0:77e:9455:b4e3 with SMTP id xc10-20020a170907074a00b0077e9455b4e3mr19520873ejb.471.1663728820446; Tue, 20 Sep 2022 19:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663728820; cv=none; d=google.com; s=arc-20160816; b=NBzYElSzbA/2LTQyNRUae9Lh9EYzsYnCsSwrK+sR3buCu36wuqkqUXb9DA5EuLucCB Cfpt9N6e/15Kaicb05PCLNMPINcOy39XPed/+qypzvTNPksZO1nblG9bvRVkmTo8c+S9 4v0cHvmkkw/ZrQa9zJoNY1mVYeCvm/EI1noOz8/9Dx4Nom44taFSGl1edmCkIRfTQFlh UcDmYtxsnmbmJkGVy4NUKhMxTE9X67ZPNysLTemoWOioIbsp5gZW4LgNKKWY6hMjufQW fK9V+KYDCmw8RkrzdvNtzNbjFWGKhXovPaqCpV1IamTmlvcY8J5qgZbSbsJlTDyHJD+r AKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zFoR6xBOKBxT4r2jeOdhRqIVnjZmMUpf2r3ri0mwav8=; b=SJwKtjI2worltN56LjfnsHbPS5cNkmg8sDq8Y/WzqEGZ4hqHZiEoSRgmRSVKJpaI6E t1QRlaHtwhdnlZdFSSfzh4oAI+geKxjWltgxxDtZFfdWckCkUV9S+hAjvkN1ZuHSMiGk +q7b4CJYQVtOrY1LCXIvdleU0nnhYi1sZ5Deye2/jVQkRdSAdvUUQb8j5OrT0QXfnlzR bkOC1+8B+hKeX6xkqjjIt+znZ3o1VpcrwL+QvwVTQ06lGDsnVCcCzbtFWI2rA7n/K4Zw uVJocX8aCMYzQy3HAM1bT+1nAxstfUDY76Ozv5LjaWi0y26kLANderzHrV/HN2Zy+hcW VpaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd8-20020a170907968800b0078037cd5c2dsi1350616ejc.715.2022.09.20.19.53.14; Tue, 20 Sep 2022 19:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbiIUCo2 (ORCPT + 99 others); Tue, 20 Sep 2022 22:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230322AbiIUCoM (ORCPT ); Tue, 20 Sep 2022 22:44:12 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C717D784; Tue, 20 Sep 2022 19:44:10 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MXN3l2yJpz6T8t2; Wed, 21 Sep 2022 10:42:11 +0800 (CST) Received: from localhost.localdomain (unknown [10.67.175.61]) by APP1 (Coremail) with SMTP id cCh0CgD3xCh3eipjRFhmBA--.50399S5; Wed, 21 Sep 2022 10:44:09 +0800 (CST) From: Pu Lehui To: Martin KaFai Lau , Stanislav Fomichev , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , Pu Lehui , Pu Lehui Subject: [PATCH bpf v5 3/3] selftests/bpf: Adapt cgroup effective query uapi change Date: Wed, 21 Sep 2022 10:46:04 +0000 Message-Id: <20220921104604.2340580-4-pulehui@huaweicloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921104604.2340580-1-pulehui@huaweicloud.com> References: <20220921104604.2340580-1-pulehui@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgD3xCh3eipjRFhmBA--.50399S5 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyUXw1xJr43ZF47XF48Crg_yoW8uw1kpF ykZ34Ut3WrWr1agF1kA3s2vrWI9FsxW3WIyF4UJrW3ZFy2vr10vr1xKws0vF1rJrWvyw4F va4Yy398XF4UZaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JrWl82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2 z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwACI402YVCY1x02628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCw CI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnI WIevJa73UjIFyTuYvjTRNzVbUUUUU X-CM-SenderInfo: psxovxtxl6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pu Lehui The attach flags is meaningless for effective query and its value will always be set as 0 during effective query. Root cg's effective progs is always its attached progs, so we use non-effective query to get its progs count and attach flags. And we don't need the remain attach flags check. Fixes: b79c9fc9551b ("bpf: implement BPF_PROG_QUERY for BPF_LSM_CGROUP") Signed-off-by: Pu Lehui --- tools/testing/selftests/bpf/prog_tests/cgroup_link.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_link.c b/tools/testing/selftests/bpf/prog_tests/cgroup_link.c index 9e6e6aad347c..15093a69510e 100644 --- a/tools/testing/selftests/bpf/prog_tests/cgroup_link.c +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_link.c @@ -71,10 +71,9 @@ void serial_test_cgroup_link(void) ping_and_check(cg_nr, 0); - /* query the number of effective progs and attach flags in root cg */ + /* query the number of attached progs and attach flags in root cg */ err = bpf_prog_query(cgs[0].fd, BPF_CGROUP_INET_EGRESS, - BPF_F_QUERY_EFFECTIVE, &attach_flags, NULL, - &prog_cnt); + 0, &attach_flags, NULL, &prog_cnt); CHECK_FAIL(err); CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI); if (CHECK(prog_cnt != 1, "effect_cnt", "exp %d, got %d\n", 1, prog_cnt)) @@ -85,17 +84,15 @@ void serial_test_cgroup_link(void) BPF_F_QUERY_EFFECTIVE, NULL, NULL, &prog_cnt); CHECK_FAIL(err); - CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI); if (CHECK(prog_cnt != cg_nr, "effect_cnt", "exp %d, got %d\n", cg_nr, prog_cnt)) goto cleanup; /* query the effective prog IDs in last cg */ err = bpf_prog_query(cgs[last_cg].fd, BPF_CGROUP_INET_EGRESS, - BPF_F_QUERY_EFFECTIVE, &attach_flags, - prog_ids, &prog_cnt); + BPF_F_QUERY_EFFECTIVE, NULL, prog_ids, + &prog_cnt); CHECK_FAIL(err); - CHECK_FAIL(attach_flags != BPF_F_ALLOW_MULTI); if (CHECK(prog_cnt != cg_nr, "effect_cnt", "exp %d, got %d\n", cg_nr, prog_cnt)) goto cleanup; -- 2.25.1