From patchwork Fri Dec 4 11:52:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 338088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D06A4C433FE for ; Fri, 4 Dec 2020 12:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75FA52251F for ; Fri, 4 Dec 2020 12:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727100AbgLDMA5 (ORCPT ); Fri, 4 Dec 2020 07:00:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53964 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbgLDMA4 (ORCPT ); Fri, 4 Dec 2020 07:00:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607083170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fo4CkmHc3jtGL0IOPisn+w0CsTqAMCL3b0L5UdSE4ls=; b=biV+3dzoNJavgCvo1zJhHYpTe+Ij59fP+EghJaQAaxx539hcWVJc5GCloIqnkUxsBrd995 ki2+LG3VQLkWAxA5HQnp4lQ5A3Jm/Bf6mzkqdWl1rTIfkFbVMThStNB+dDmy5CuhbO6ycq hLdAZM+QC68VTxcPx5M+L2mELj3Fc1U= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-Vkqr1ZUyOEqPK3yivcjQ8g-1; Fri, 04 Dec 2020 06:59:28 -0500 X-MC-Unique: Vkqr1ZUyOEqPK3yivcjQ8g-1 Received: by mail-ej1-f69.google.com with SMTP id f21so1982695ejf.11 for ; Fri, 04 Dec 2020 03:59:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=fo4CkmHc3jtGL0IOPisn+w0CsTqAMCL3b0L5UdSE4ls=; b=HysC6kltePkQBRbTyegbE0aLUSSVtRBDX7TcHOgXqj1VWa5vemZMTyx3zEmHZd671R 6waC4cHaWFUH/Dbxz0P1W81Gq9sz97BallRj7VzTkYMS0fTFjaM7hDq22QJ6cOG+BrJO 7MqoU8IIW/Xh0WU7O3uqy83UHNRKAO4ScpYTGcMskh+Q+4E55frDIuALmkedltsrI8yC WPdYCpnU3PMCuolBk36+YjY/jtBqJZfgJJoD1afTwkic3tgV0wWchM4b/UY61iRxVK89 ZDhVKRt0bG/hImxCPG1ZduazqMIQFF8/xitMScUfyliGzOUi0cTKkx68UondR6Nkj8qh 8qMw== X-Gm-Message-State: AOAM531M4VqoLxm1PGZfStIOzcVcFILjA35HCy8v0FO6xl2iN5f3VoEm diz8ukDnG/if/HIlXmsHsrSDA2Kxcl2O8rFqrrJpXaQEzuHyd0Olz0DpI1ISw4GM5ljpksgchKI QbjW2pNSzhfTok5AGYI2qcw== X-Received: by 2002:a17:906:4016:: with SMTP id v22mr6890787ejj.266.1607083166795; Fri, 04 Dec 2020 03:59:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJywrOY+L6uvg7IiDMqj6/eVEC18v1AA+ShmEGuxMXdvUnzdfACpA0kSCLjZwLRBvQn0LMGt5w== X-Received: by 2002:a17:906:4016:: with SMTP id v22mr6890759ejj.266.1607083166302; Fri, 04 Dec 2020 03:59:26 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id gl2sm2878911ejb.29.2020.12.04.03.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 03:59:25 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 6FF4E182EEA; Fri, 4 Dec 2020 12:52:04 +0100 (CET) Subject: [PATCH bpf v2 2/7] selftests/bpf/test_offload.py: Remove check for program load flags match From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Jakub Kicinski Cc: "David S. Miller" , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jesper Dangaard Brouer , "Michael S. Tsirkin" , Romain Perier , Allen Pais , Grygorii Strashko , Simon Horman , "Gustavo A. R. Silva" , Lorenzo Bianconi , Wei Yongjun , Jiri Benc , oss-drivers@netronome.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Date: Fri, 04 Dec 2020 12:52:04 +0100 Message-ID: <160708272436.192754.11519287849839028664.stgit@toke.dk> In-Reply-To: <160708272217.192754.14019805999368221369.stgit@toke.dk> References: <160708272217.192754.14019805999368221369.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Toke Høiland-Jørgensen Since we just removed the xdp_attachment_flags_ok() callback, also remove the check for it in test_offload.py, and replace it with a test for the new ambiguity-avoid check when multiple programs are loaded. Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 43c9cda199b8..becd27b2f4ba 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -716,13 +716,11 @@ def test_multi_prog(simdev, sim, obj, modename, modeid): fail(ret == 0, "Replaced one of programs without -force") check_extack(err, "XDP program already attached.", args) - if modename == "" or modename == "drv": - othermode = "" if modename == "drv" else "drv" - start_test("Test multi-attachment XDP - detach...") - ret, _, err = sim.unset_xdp(othermode, force=True, - fail=False, include_stderr=True) - fail(ret == 0, "Removed program with a bad mode") - check_extack(err, "program loaded with different flags.", args) + start_test("Test multi-attachment XDP - remove without mode...") + ret, _, err = sim.unset_xdp("", force=True, + fail=False, include_stderr=True) + fail(ret == 0, "Removed program without a mode flag") + check_extack(err, "More than one program loaded, unset mode is ambiguous.", args) sim.unset_xdp("offload") xdp = sim.ip_link_show(xdp=True)["xdp"] @@ -1001,16 +999,6 @@ try: check_extack(err, "native and generic XDP can't be active at the same time.", args) - ret, _, err = sim.set_xdp(obj, "", force=True, - fail=False, include_stderr=True) - fail(ret == 0, "Replaced XDP program with a program in different mode") - check_extack(err, "program loaded with different flags.", args) - - start_test("Test XDP prog remove with bad flags...") - ret, _, err = sim.unset_xdp("", force=True, - fail=False, include_stderr=True) - fail(ret == 0, "Removed program with a bad mode") - check_extack(err, "program loaded with different flags.", args) start_test("Test MTU restrictions...") ret, _ = sim.set_mtu(9000, fail=False) From patchwork Fri Dec 4 11:52:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 338091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6714C1B0D9 for ; Fri, 4 Dec 2020 11:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 840D222482 for ; Fri, 4 Dec 2020 11:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387778AbgLDLxi (ORCPT ); Fri, 4 Dec 2020 06:53:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46002 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730106AbgLDLxh (ORCPT ); Fri, 4 Dec 2020 06:53:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607082730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zcUyCpLjDCll9Y1/aRPnij3wIkLUo17xw68D8racrjQ=; b=jD1AwDVFyyYt1H51xp8v9YSB2emkASH+WXcgSRJNSP70gOsUgwQMeSY4AzFAxgWdizz2N2 VS1XfkySghH9U4Qyd5uaxrEfEbqpUl4uK/j5dY06hlGlvxmNY6TDYJuUDjbqheMvg3WLmO /FA0ea6jIpicxgISMHg4amQdukPQdPk= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-YVJ1YeKlPXu9RN3rF79U2w-1; Fri, 04 Dec 2020 06:52:09 -0500 X-MC-Unique: YVJ1YeKlPXu9RN3rF79U2w-1 Received: by mail-ed1-f71.google.com with SMTP id z20so2230797edl.21 for ; Fri, 04 Dec 2020 03:52:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=zcUyCpLjDCll9Y1/aRPnij3wIkLUo17xw68D8racrjQ=; b=lcZtgqXVl7PECIYHTYddhneLRTQgrF6/fa42+WFlYW1KkuBKwfp8hgFUBqXjzOyweI YZFdpzqE22XHZOCnL3NH2iRMFCPK4tWB1eWDKD5VlUTRQejpNE3lm0Dkc2mqtiEbjCGQ IThFcAvhK+UDTKzwf9pTnMtWz0XVSpb/P2BoS4wvIUYLt/KKxBILDN/ZIBMEsSivxTV+ c9lODwl/oP7MuLN6jg0smcHWakEfPtgWu0D8M3Nk2UyLTEnCG1CZ6Ao0UKjdQMvJ6MbC ABQeqsIizJFWFV+zVN0v9k94kqTeC4TQ/MvFsVsrgs0A8KoiaN+SWLneu6Tw8JDkRWvJ /INg== X-Gm-Message-State: AOAM531q2zlCZg0+pHKj363v2fGurlx0RAtZuHywfD7JeGgCTyFSYJUq UPU4k3ijG5i1FlbVzddDPhZmVJpLE5wQT8w0U9E9mNuNo/wC+hfoS4uqs8qyTU/nCJdy8FKPiEf b1JuSlLP2t48tCssx6UrxDA== X-Received: by 2002:a17:906:c087:: with SMTP id f7mr867465ejz.492.1607082727622; Fri, 04 Dec 2020 03:52:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyEu66EqzxOKKZOgHPeEZHy0BRghOA3Syefi21Q3iNsPa4ViPa5k+lx+HXAso5qKcEfAQ7TQ== X-Received: by 2002:a17:906:c087:: with SMTP id f7mr867421ejz.492.1607082727090; Fri, 04 Dec 2020 03:52:07 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id k18sm3200968edx.18.2020.12.04.03.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 03:52:06 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 845291843EB; Fri, 4 Dec 2020 12:52:05 +0100 (CET) Subject: [PATCH bpf v2 3/7] netdevsim: Add debugfs toggle to reject BPF programs in verifier From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Jakub Kicinski Cc: "David S. Miller" , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jesper Dangaard Brouer , "Michael S. Tsirkin" , Romain Perier , Allen Pais , Grygorii Strashko , Simon Horman , "Gustavo A. R. Silva" , Lorenzo Bianconi , Wei Yongjun , Jiri Benc , oss-drivers@netronome.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Date: Fri, 04 Dec 2020 12:52:05 +0100 Message-ID: <160708272546.192754.15754148712783914808.stgit@toke.dk> In-Reply-To: <160708272217.192754.14019805999368221369.stgit@toke.dk> References: <160708272217.192754.14019805999368221369.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Toke Høiland-Jørgensen This adds a new debugfs toggle ('bpf_bind_verifier_accept') that can be used to make netdevsim reject BPF programs from being accepted by the verifier. If this toggle (which defaults to true) is set to false, nsim_bpf_verify_insn() will return EOPNOTSUPP on the last instruction (after outputting the 'Hello from netdevsim' verifier message). This makes it possible to check the verification callback in the driver from test_offload.py in selftests, since the verifier now clears the verifier log on a successful load, hiding the message from the driver. Acked-by: Jakub Kicinski Signed-off-by: Toke Høiland-Jørgensen --- drivers/net/netdevsim/bpf.c | 12 ++++++++++-- drivers/net/netdevsim/netdevsim.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index 85546664bdd5..90aafb56f140 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c @@ -63,15 +63,20 @@ static int nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn) { struct nsim_bpf_bound_prog *state; + int ret = 0; state = env->prog->aux->offload->dev_priv; if (state->nsim_dev->bpf_bind_verifier_delay && !insn_idx) msleep(state->nsim_dev->bpf_bind_verifier_delay); - if (insn_idx == env->prog->len - 1) + if (insn_idx == env->prog->len - 1) { pr_vlog(env, "Hello from netdevsim!\n"); - return 0; + if (!state->nsim_dev->bpf_bind_verifier_accept) + ret = -EOPNOTSUPP; + } + + return ret; } static int nsim_bpf_finalize(struct bpf_verifier_env *env) @@ -595,6 +600,9 @@ int nsim_bpf_dev_init(struct nsim_dev *nsim_dev) &nsim_dev->bpf_bind_accept); debugfs_create_u32("bpf_bind_verifier_delay", 0600, nsim_dev->ddir, &nsim_dev->bpf_bind_verifier_delay); + nsim_dev->bpf_bind_verifier_accept = true; + debugfs_create_bool("bpf_bind_verifier_accept", 0600, nsim_dev->ddir, + &nsim_dev->bpf_bind_verifier_accept); return 0; } diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 827fc80f50a0..c4e7ad2a1964 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -189,6 +189,7 @@ struct nsim_dev { struct dentry *take_snapshot; struct bpf_offload_dev *bpf_dev; bool bpf_bind_accept; + bool bpf_bind_verifier_accept; u32 bpf_bind_verifier_delay; struct dentry *ddir_bpf_bound_progs; u32 prog_id_gen; From patchwork Fri Dec 4 11:52:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 338090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9818C4361A for ; Fri, 4 Dec 2020 11:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78A3C22482 for ; Fri, 4 Dec 2020 11:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbgLDLxm (ORCPT ); Fri, 4 Dec 2020 06:53:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48711 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730138AbgLDLxl (ORCPT ); Fri, 4 Dec 2020 06:53:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607082734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IK/QJ/mwWf6qYNme1m53SvUyoc+tECiyzDRKMtRU8jo=; b=Sjlujd57bh8FzQpguB/8lHFDAidt/KIjok2eG5p2vtn4wRmKtomTcciZ0+avcoPvNXukJP l+zXMtSgy6ll+hHlMkXCFOOLRyqf2sb+S6nODUrk+zjsUSs3K4temFmD5LeFvsMUNP4pDG 8dD+jSGMZ8NAJpJgDIzFPufVDLt9RtM= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-pEFvoreUNgKvMcd6fNVpcQ-1; Fri, 04 Dec 2020 06:52:13 -0500 X-MC-Unique: pEFvoreUNgKvMcd6fNVpcQ-1 Received: by mail-ed1-f69.google.com with SMTP id c23so2249623edr.4 for ; Fri, 04 Dec 2020 03:52:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=IK/QJ/mwWf6qYNme1m53SvUyoc+tECiyzDRKMtRU8jo=; b=ZKhEfrKgeuUkSYNaZhhfCZmGuGKGYCgEFtMc15v5WSIA/apt56tbXO3XyiugWyjsl5 Oe+fd+nIxAtApmql+Ju7xALQU0eNIdvsTzQH4OpLI+xYqDiCPJbWIPUfdJjaP/SvI0+T uUWr2v1qHo+fSnvav1vYS8c2j042gXiWiSiyLfw4zQrfGLX2P/16dkKgB7qO1Wtw94wk Cg81gVP4p8kIp930uVhJ15Wp8qZVcHkMjTEGe6eMVsgGg0QdpA+iZGPohYSXOwMvh2cr oS348iGGqBfeiKXR3e4OYRJrOtpVaBmTC9JIhN6DQpepD9tvIHogY2D/KBOo1g2TZdt0 E6Pg== X-Gm-Message-State: AOAM533zHPC9vEyAtx0f1FqGS4RRLJxqwpfIUli71gt6jgCo5aTTIjio mT84XYBdet/mil425N19Hq4g68qrXj3/5A4oX0HszVilWS6CgSif1xfJc7BYnH7gPZgSZPGkMk9 sjxWRm5ZjKu35cPEfcLKbNg== X-Received: by 2002:a17:906:e082:: with SMTP id gh2mr6434427ejb.406.1607082731593; Fri, 04 Dec 2020 03:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJnmnrQQFUZtCpPBo0okVYdCn+4YqUFrQtfBWBO5pOeK9MIHcNI5YMcL0nBkzararsSM8lqA== X-Received: by 2002:a17:906:e082:: with SMTP id gh2mr6434391ejb.406.1607082731155; Fri, 04 Dec 2020 03:52:11 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id e12sm3344289edm.48.2020.12.04.03.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 03:52:10 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C9F751843EC; Fri, 4 Dec 2020 12:52:08 +0100 (CET) Subject: [PATCH bpf v2 6/7] selftests/bpf/test_offload.py: reset ethtool features after failed setting From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Jakub Kicinski Cc: "David S. Miller" , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jesper Dangaard Brouer , "Michael S. Tsirkin" , Romain Perier , Allen Pais , Grygorii Strashko , Simon Horman , "Gustavo A. R. Silva" , Lorenzo Bianconi , Wei Yongjun , Jiri Benc , oss-drivers@netronome.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Date: Fri, 04 Dec 2020 12:52:08 +0100 Message-ID: <160708272873.192754.13552481233579004069.stgit@toke.dk> In-Reply-To: <160708272217.192754.14019805999368221369.stgit@toke.dk> References: <160708272217.192754.14019805999368221369.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Toke Høiland-Jørgensen When setting the ethtool feature flag fails (as expected for the test), the kernel now tracks that the feature was requested to be 'off' and refuses to subsequently disable it again. So reset it back to 'on' so a subsequent disable (that's not supposed to fail) can succeed. Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 51a5e4d939cc..2128fbd8414b 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -946,6 +946,7 @@ try: start_test("Test disabling TC offloads is rejected while filters installed...") ret, _ = sim.set_ethtool_tc_offloads(False, fail=False) fail(ret == 0, "Driver should refuse to disable TC offloads with filters installed...") + sim.set_ethtool_tc_offloads(True) start_test("Test qdisc removal frees things...") sim.tc_flush_filters() From patchwork Fri Dec 4 11:52:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 338089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B04DC2BB40 for ; Fri, 4 Dec 2020 11:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57A8422A84 for ; Fri, 4 Dec 2020 11:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387828AbgLDLxl (ORCPT ); Fri, 4 Dec 2020 06:53:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41692 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730124AbgLDLxl (ORCPT ); Fri, 4 Dec 2020 06:53:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607082734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4z8KXODqjwtErk41YpHMDb+O7Bt3e78Uq4SI4fcpBVc=; b=ZxfA/AkZA0Re0qKTLXV7NaDJ42+phaX5Ez3YCEZrHTnYqnpy/ZKufX3dJ2abKLgzAkaADa 7ivvogPCRLo5wczW9u+/zAsnBd8wLtJ06d++0HSYnmbvc5oXNBfw/YTiX2wDf1eyUf4unn v03Y5xpkeJf1WPzVZjc3fsxZdENThf0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-n8ucuLl4PyafbAyyzHgofQ-1; Fri, 04 Dec 2020 06:52:13 -0500 X-MC-Unique: n8ucuLl4PyafbAyyzHgofQ-1 Received: by mail-ed1-f72.google.com with SMTP id s7so2250775eds.17 for ; Fri, 04 Dec 2020 03:52:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=4z8KXODqjwtErk41YpHMDb+O7Bt3e78Uq4SI4fcpBVc=; b=CET8JRLeEezbbzUuac9ewO5QmUElqn0f6lCC1cutl0XNcstmocPr1hKwkkTbMwBLPl RSuPN6XCTt7Lglj6lTgs/d8EcNWmqxCUSsB/HosrRDWbQyFY79qO1NiqulUs1ABKKVYG ElNXIZ9bymKKigX3davrIlfGGdQY16nt6ye75LcxTJMSV4mcy9ZD/Lmqse+2cgxjb19o qVRiJ50Cs7bny0Mf8SQZCXNNACwW2mOIdWtU+ZNrVPu+A3J3aP99uwZg4lbZrOGPGU69 hlXpYasnX5yRn2qu9jw0UGHFlpj6s/FY8xAMNhcpUHffP0wnamQ26TCLiS9+87wKSNgN juEw== X-Gm-Message-State: AOAM533EdMqnwikxB7NkBl5Fpxjn8kAHLh5ejaZJ0ZX6nUfb9mvxlH83 zGr1ad8rZXK9FukfxrKZe1G/4F8RQVSqp7qnF5MuOHjZ5QR9TuM/cAV3geLuffac5lwtovFNLce jbN25RAdlYKFuvF1BC3RfCA== X-Received: by 2002:a17:906:8042:: with SMTP id x2mr7188292ejw.79.1607082731756; Fri, 04 Dec 2020 03:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrtWb6FuuLro5ty8zueEEvZOWwhg6p8KPWy4h8kxmLPsduHpi83CLwjqt251LWSV2eebcO4A== X-Received: by 2002:a17:906:8042:: with SMTP id x2mr7188267ejw.79.1607082731598; Fri, 04 Dec 2020 03:52:11 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id n16sm3284713edq.62.2020.12.04.03.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 03:52:10 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id E1EBE1843EF; Fri, 4 Dec 2020 12:52:09 +0100 (CET) Subject: [PATCH bpf v2 7/7] selftests/bpf/test_offload.py: filter bpftool internal map when counting maps From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Jakub Kicinski Cc: "David S. Miller" , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jesper Dangaard Brouer , "Michael S. Tsirkin" , Romain Perier , Allen Pais , Grygorii Strashko , Simon Horman , "Gustavo A. R. Silva" , Lorenzo Bianconi , Wei Yongjun , Jiri Benc , oss-drivers@netronome.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Date: Fri, 04 Dec 2020 12:52:09 +0100 Message-ID: <160708272983.192754.10060052789845857257.stgit@toke.dk> In-Reply-To: <160708272217.192754.14019805999368221369.stgit@toke.dk> References: <160708272217.192754.14019805999368221369.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Toke Høiland-Jørgensen A few of the tests in test_offload.py expects to see a certain number of maps created, and checks this by counting the number of maps returned by bpftool. There is already a filter that will remove any maps already there at the beginning of the test, but bpftool now creates a map for the PID iterator rodata on each invocation, which makes the map count wrong. Fix this by also filtering the pid_iter.rodata map by name when counting. Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 2128fbd8414b..b99bb8ed3ed4 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -184,9 +184,7 @@ def bpftool_prog_list(expected=None, ns=""): def bpftool_map_list(expected=None, ns=""): _, maps = bpftool("map show", JSON=True, ns=ns, fail=True) # Remove the base maps - for m in base_maps: - if m in maps: - maps.remove(m) + maps = [m for m in maps if m not in base_maps and m.get('name') not in base_map_names] if expected is not None: if len(maps) != expected: fail(True, "%d BPF maps loaded, expected %d" % @@ -770,6 +768,9 @@ ret, progs = bpftool("prog", fail=False) skip(ret != 0, "bpftool not installed") base_progs = progs _, base_maps = bpftool("map") +base_map_names = [ + 'pid_iter.rodata' # created on each bpftool invocation +] # Check netdevsim ret, out = cmd("modprobe netdevsim", fail=False)