From patchwork Thu Dec 3 21:35:18 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: 1410654 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jSH7fD+p; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LV6CD4z9sVJ for ; Fri, 4 Dec 2020 08:37:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387744AbgLCVgu (ORCPT ); Thu, 3 Dec 2020 16:36:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35799 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729174AbgLCVgu (ORCPT ); Thu, 3 Dec 2020 16:36:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031323; 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=FOEQOBhWSpjeYwgvm7jnVQdC9SysAGqDTxCGYu9Ii/E=; b=jSH7fD+pJkTC8PTOp9itHXATXXi2Azh2wzdUA8vaJAa34eZsWBdO6g+G3Mb+VDcRpybQlE bhF6hrulhxBqmlSiZ5AiiaanJHcz4jR26mr+PHNEWFuR0nYK70i1l5SkqF7sUy1htK0BWI 3uIykZJVH11XigVeJJ+eF8oT6jmqD5M= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-vbawK2wdMaCJ0qUukZUgzA-1; Thu, 03 Dec 2020 16:35:21 -0500 X-MC-Unique: vbawK2wdMaCJ0qUukZUgzA-1 Received: by mail-qv1-f69.google.com with SMTP id cu18so2806491qvb.17 for ; Thu, 03 Dec 2020 13:35:21 -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=FOEQOBhWSpjeYwgvm7jnVQdC9SysAGqDTxCGYu9Ii/E=; b=kZcFePeGczeNDartuWoQwwuPDbvkZ0mmkXDbOG906xwAdA7qsDX1A9VYKiI6Oy1Fz5 JxnDvU19ACVt6B/sfxAU5XVIqa7YORu9NPwJBFN5eILeoKxm7jVG32VINIeAzH/OFsLz sE7qF2dFOa2l1g31SWHMmWcpBIhWVqfZ9fZq3JQBqX5/W405ZTWjgGZVQ6xUP2vxmvGb W8ve0Ul/X3y4Wg+v7hyQ69m3b0OFzbQ9kFl6+W+Lgs2o2iTDOUYUQky0t4qo+rjYXObo qYV2JSpMilC4Qdy0AItBv9Ft6P7SvjH1YFoqaq0eRQKcsOL2rQLTcuPq2/y+e287YdM1 q2JQ== X-Gm-Message-State: AOAM532PaavasGXtQfV8tTfdVUzOU/njKfl35iBRTtRrOvTz/AglD/cd 4FqpQnRYCeA1IJtPtvDJiTSA1NdCoB0+09P0yubUCNmbMhlgV7LYeM4umHdhQL7cA+SSKv3F6Y2 gmc60exBkqnZwUG9S X-Received: by 2002:a37:a88f:: with SMTP id r137mr5123201qke.437.1607031320987; Thu, 03 Dec 2020 13:35:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJx00VOq0ClX50AjGWa467GOWc3rLaYOdNTf+KrH8xHZ6cY5kBzdnkH7aaycznfV49wVXoyP+A== X-Received: by 2002:a37:a88f:: with SMTP id r137mr5123158qke.437.1607031320769; Thu, 03 Dec 2020 13:35:20 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id 64sm2795037qko.2.2020.12.03.13.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:20 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 43E051843EB; Thu, 3 Dec 2020 22:35:18 +0100 (CET) Subject: [PATCH bpf 1/7] xdp: remove the xdp_attachment_flags_ok() callback 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: Thu, 03 Dec 2020 22:35:18 +0100 Message-ID: <160703131819.162669.2776807312730670823.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Toke Høiland-Jørgensen Since commit 7f0a838254bd ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device"), the XDP program attachment info is now maintained in the core code. This interacts badly with the xdp_attachment_flags_ok() check that prevents unloading an XDP program with different load flags than it was loaded with. In practice, two kinds of failures are seen: - An XDP program loaded without specifying a mode (and which then ends up in driver mode) cannot be unloaded if the program mode is specified on unload. - The dev_xdp_uninstall() hook always calls the driver callback with the mode set to the type of the program but an empty flags argument, which means the flags_ok() check prevents the program from being removed, leading to bpf prog reference leaks. Since we offloaded and non-offloaded programs can co-exist there doesn't really seem to be any reason for the check anyway, and it's only used in three drivers so let's just get rid of the callback entirely. Signed-off-by: Toke Høiland-Jørgensen --- .../net/ethernet/netronome/nfp/nfp_net_common.c | 6 ------ drivers/net/ethernet/ti/cpsw_priv.c | 3 --- drivers/net/netdevsim/bpf.c | 3 --- include/net/xdp.h | 2 -- net/core/xdp.c | 12 ------------ 5 files changed, 26 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index b150da43adb2..437226866ce8 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3562,9 +3562,6 @@ static int nfp_net_xdp_setup_drv(struct nfp_net *nn, struct netdev_bpf *bpf) struct nfp_net_dp *dp; int err; - if (!xdp_attachment_flags_ok(&nn->xdp, bpf)) - return -EBUSY; - if (!prog == !nn->dp.xdp_prog) { WRITE_ONCE(nn->dp.xdp_prog, prog); xdp_attachment_setup(&nn->xdp, bpf); @@ -3593,9 +3590,6 @@ static int nfp_net_xdp_setup_hw(struct nfp_net *nn, struct netdev_bpf *bpf) { int err; - if (!xdp_attachment_flags_ok(&nn->xdp_hw, bpf)) - return -EBUSY; - err = nfp_app_xdp_offload(nn->app, nn, bpf->prog, bpf->extack); if (err) return err; diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 31c5e36ff706..424e644724e4 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -1265,9 +1265,6 @@ static int cpsw_xdp_prog_setup(struct cpsw_priv *priv, struct netdev_bpf *bpf) if (!priv->xdpi.prog && !prog) return 0; - if (!xdp_attachment_flags_ok(&priv->xdpi, bpf)) - return -EBUSY; - WRITE_ONCE(priv->xdp_prog, prog); xdp_attachment_setup(&priv->xdpi, bpf); diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c index 2e90512f3bbe..85546664bdd5 100644 --- a/drivers/net/netdevsim/bpf.c +++ b/drivers/net/netdevsim/bpf.c @@ -190,9 +190,6 @@ nsim_xdp_set_prog(struct netdevsim *ns, struct netdev_bpf *bpf, { int err; - if (!xdp_attachment_flags_ok(xdp, bpf)) - return -EBUSY; - if (bpf->command == XDP_SETUP_PROG && !ns->bpf_xdpdrv_accept) { NSIM_EA(bpf->extack, "driver XDP disabled in DebugFS"); return -EOPNOTSUPP; diff --git a/include/net/xdp.h b/include/net/xdp.h index 3814fb631d52..9dab2bc6f187 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -240,8 +240,6 @@ struct xdp_attachment_info { }; struct netdev_bpf; -bool xdp_attachment_flags_ok(struct xdp_attachment_info *info, - struct netdev_bpf *bpf); void xdp_attachment_setup(struct xdp_attachment_info *info, struct netdev_bpf *bpf); diff --git a/net/core/xdp.c b/net/core/xdp.c index 491ad569a79c..d900cebc0acd 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -403,18 +403,6 @@ void __xdp_release_frame(void *data, struct xdp_mem_info *mem) } EXPORT_SYMBOL_GPL(__xdp_release_frame); -bool xdp_attachment_flags_ok(struct xdp_attachment_info *info, - struct netdev_bpf *bpf) -{ - if (info->prog && (bpf->flags ^ info->flags) & XDP_FLAGS_MODES) { - NL_SET_ERR_MSG(bpf->extack, - "program loaded with different flags"); - return false; - } - return true; -} -EXPORT_SYMBOL_GPL(xdp_attachment_flags_ok); - void xdp_attachment_setup(struct xdp_attachment_info *info, struct netdev_bpf *bpf) { From patchwork Thu Dec 3 21:35:19 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: 1410656 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Kl6Uc3SL; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LW6Fh8z9sVJ for ; Fri, 4 Dec 2020 08:37:07 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389302AbgLCVgy (ORCPT ); Thu, 3 Dec 2020 16:36:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32510 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387799AbgLCVgx (ORCPT ); Thu, 3 Dec 2020 16:36:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031326; 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=6Bq9B1pIhYYZLlciYIdpPVKZPo9SS6y4k1LZd1EeU0w=; b=Kl6Uc3SLlD+fYn9wL0Ur2Kp2pV94UsphYSQK9mrLAr4eX9YVWxz1/mfY7T83I4AFD0zc+T 83kzyW7fT9NLduXdUrR5Xf8L3xnwqQYwSNCZNGYU89HtXRAOHA9ILndJ7fZcjcJtA6emeW 6HqY1ynZFzEMFrmP9FrkhtcYdITZ5Zs= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-KVAnkHwhMPWar7a_1Jdjmg-1; Thu, 03 Dec 2020 16:35:24 -0500 X-MC-Unique: KVAnkHwhMPWar7a_1Jdjmg-1 Received: by mail-qk1-f198.google.com with SMTP id r124so3184859qkd.8 for ; Thu, 03 Dec 2020 13:35:24 -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=6Bq9B1pIhYYZLlciYIdpPVKZPo9SS6y4k1LZd1EeU0w=; b=ZnM9lm+duEXV4XqmHAFXZPXGaYX+r6ife1AnNhI+tdWBVChu7IShQ0r7XOWOjwQ3nh Likvcl5jUKvlTcSYK0Ly8jvueykcTHbTAgR91s47ENWCJdWVp6X+z6cLoZWLFFfMgxV7 BfAdgpwgDTPxALR7iixHrTDksbhjLpYF6DbPIn7XdEDpNvFv8J5mhibGv20agaVSid2G OE/xb48TW3Lwu+s0Dj3XSgQdpYLNeeIJB9TzgRH5Z1wix9+Aj2vMql1j9toHdoU3LGM3 dFu1MTNuYzz0VjjCOw8oyNUn8LJ4/k8q8odV8p5TGMSSHZ7W74l6OdTbJVjeJdOIOuep ouWg== X-Gm-Message-State: AOAM532kx39vEzNGOC8Tb7nCVo4mwrwNrPHc+0z3jTH37CiE6htgCv4a FK4P0Z0q8l2n3ur0FgY+9CnLcVXXNzu/SIzmO9noadtc/dDUb3ByO80D0vFQQn/bUFA45KY9wkb To2YnfRtsRhz//ZTv X-Received: by 2002:ac8:4998:: with SMTP id f24mr5574531qtq.30.1607031324220; Thu, 03 Dec 2020 13:35:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3x4fFB+vOzBIHHzH7WpznYoXedCpBDcNWaY/1TcEuwaAipgK4HGjehaqTvmfAcgpZIMeerw== X-Received: by 2002:ac8:4998:: with SMTP id f24mr5574494qtq.30.1607031323844; Thu, 03 Dec 2020 13:35:23 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id c68sm2888642qkb.17.2020.12.03.13.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:21 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 58A981843EC; Thu, 3 Dec 2020 22:35:19 +0100 (CET) Subject: [PATCH bpf 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: Thu, 03 Dec 2020 22:35:19 +0100 Message-ID: <160703131928.162669.17738060161862930826.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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 Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 43c9cda199b8..7afe259c785f 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -716,14 +716,6 @@ 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) - sim.unset_xdp("offload") xdp = sim.ip_link_show(xdp=True)["xdp"] offloaded = sim.dfs_read("bpf_offloaded_id") @@ -1001,16 +993,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 Thu Dec 3 21:35:20 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: 1410657 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BKkrKtAk; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LX1p7xz9sVH for ; Fri, 4 Dec 2020 08:37:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389375AbgLCVgz (ORCPT ); Thu, 3 Dec 2020 16:36:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49979 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388162AbgLCVgz (ORCPT ); Thu, 3 Dec 2020 16:36:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031328; 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=XeW+PrSGPFwf4qXKThBzV62+oNUX7du8v4rO75iY9HM=; b=BKkrKtAkmrQ/1UpvQyArUWeYe1PBzlE+Eqo+5btBdz5yvKtu/hWiQv/lCYNghy9yjmvl74 AxSmblaD3jQnDrU59liZxgbGjDEm71SS6AmdqiNefJKq9e/AEndOrgN14akgeqsgB5MHdQ C+XF4moZCu9zjPd4HX6oa4tLxkCPn/o= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-TZy5klGbMNuSkKzKB3TyKw-1; Thu, 03 Dec 2020 16:35:26 -0500 X-MC-Unique: TZy5klGbMNuSkKzKB3TyKw-1 Received: by mail-qk1-f198.google.com with SMTP id q21so3175518qkq.11 for ; Thu, 03 Dec 2020 13:35:26 -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=XeW+PrSGPFwf4qXKThBzV62+oNUX7du8v4rO75iY9HM=; b=iLhxrASwXoO60LE9JuAMo9vng31xzcunJcyx+gVVSAwGo7b8F8rvX6kzFwE3C7hCWE buE9Nd/Phi8OrOo6Ttkct4dfZqazkzohvRzb1HZGwhn7+TrkRL5LZBRsddDrIXFr3Yy4 QWNOapuR32k3I1w0w14tl9UPkTZcb5Pxki2B0wKT1rGTJsWeK+L3nSa1ILGvoPorXzvP fztruFf+G9lBDqnEr7rtKO0uWRNHXI9cBcozHEfGTe0SVWbb9kzzsX0GBDnc0ycwy7/P XXj+QNX35lpRgFdQCW8GVKG6yv0wzJlx0SozS/xaWqOdPwMV6YU68XL8pwDdIutsSn5k MQHQ== X-Gm-Message-State: AOAM531neM4OAk48KzDsh3cpkNdp3DgDTu2Y2nYUUppbwXa6oWrG9m7V Lce/a7k6FQpEjCDxSCXJn/l7ZuyGFWpjU4CnRtSyB33/qvqhrbKW382x4+2qOthUhgpA9HkK/+P UijJvKUDxpe4pL6gC X-Received: by 2002:aed:3051:: with SMTP id 75mr5555394qte.64.1607031325028; Thu, 03 Dec 2020 13:35:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLduMaDaXPxJJZ7ytN1sVff2d9qoJUfQZ3hechVdcfKxQXqe9hByEvz/Mk4RWvgPMwMl8Z1g== X-Received: by 2002:aed:3051:: with SMTP id 75mr5555379qte.64.1607031324842; Thu, 03 Dec 2020 13:35:24 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id z73sm2822101qkb.112.2020.12.03.13.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:23 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 711DC181CF8; Thu, 3 Dec 2020 22:35:20 +0100 (CET) Subject: [PATCH bpf 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: Thu, 03 Dec 2020 22:35:20 +0100 Message-ID: <160703132036.162669.7719186299991611592.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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. Signed-off-by: Toke Høiland-Jørgensen Acked-by: Jakub Kicinski --- 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..d1d329af3e61 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -190,6 +190,7 @@ struct nsim_dev { struct bpf_offload_dev *bpf_dev; bool bpf_bind_accept; u32 bpf_bind_verifier_delay; + bool bpf_bind_verifier_accept; struct dentry *ddir_bpf_bound_progs; u32 prog_id_gen; struct list_head bpf_bound_progs; From patchwork Thu Dec 3 21:35:21 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: 1410660 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BByMk8Af; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LY3pfJz9sVH for ; Fri, 4 Dec 2020 08:37:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389415AbgLCVhA (ORCPT ); Thu, 3 Dec 2020 16:37:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57509 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389408AbgLCVg7 (ORCPT ); Thu, 3 Dec 2020 16:36:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031333; 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=OspxR8nxroXzKoAByQKtvrhTzOZb9bKKpD2rIyWg0Bw=; b=BByMk8AfHOInUmpC98evpOS21m1Gm5sIyTkYlpO2ufHhNeHWwvsN+QKrOTZ5wfzUfHmgR8 +XpCQoDv2AtSoNJx+QG3WsOJMJZOjDPBNy9tallrCB6GnM0giqlUBM6/pvc4JcwPAVTxNL vKihrvGZHLzKVgSAg6XFvdU3gVkRgss= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-JNpeVbGrOf-aAmMi0mzD1g-1; Thu, 03 Dec 2020 16:35:29 -0500 X-MC-Unique: JNpeVbGrOf-aAmMi0mzD1g-1 Received: by mail-qv1-f72.google.com with SMTP id b15so2817471qvm.10 for ; Thu, 03 Dec 2020 13:35:29 -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=OspxR8nxroXzKoAByQKtvrhTzOZb9bKKpD2rIyWg0Bw=; b=YWsbPogBhli+3gqNJjHuL07sfgqYIkWkAIScmvcfbSqLRXNYnAPClc4yzkYEyJFITR z/TLHKF4B86o5cG3eLvM6lfhmiXWFsDTE6rxRjwmrHvIUYt8EuRWUy0XAayoDgm4Sg17 /zBX5MeAruHe2mfWI+Ixz9fxmBaFXr+LpQPpAsyEhPzvDSzqjWifwVwrgHDYKy4MRb6i XsA9DkQfyWM4w6RwhVFZIeraR+E+AqQelZZnWeRIGKblUPZ1e40xAiVfh2GyO058TIVw I5pj/ayVeKFiJ6mdw4nzrmM4y7DKrLahAnYvPnl9WEqqVSS0a5e61PAuk39GACG7uZuA yfhw== X-Gm-Message-State: AOAM531nryuqgmy7tDt/TC+z75uJOzz0vILuOvIfV1drWHsH3jdWH2SM PSD07WeJcg+MaTlADtUVUqgBrV3ko7mHoWqVYpOVKdeYPi1Ei/iKcmQ8NEsfRnzb8BgMqR8Ti+E sqprEUOAnsRlF8XHI X-Received: by 2002:a37:4854:: with SMTP id v81mr5204183qka.20.1607031328686; Thu, 03 Dec 2020 13:35:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/SJA9fM5UcB2THmOJfZjkHU1sPRMmEkRZN3cfIodhNnsPMKTfttELv6baAorjBowVQySTyw== X-Received: by 2002:a37:4854:: with SMTP id v81mr5204152qka.20.1607031328232; Thu, 03 Dec 2020 13:35:28 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id i3sm2468015qtv.23.2020.12.03.13.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:24 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 8744B1843EB; Thu, 3 Dec 2020 22:35:21 +0100 (CET) Subject: [PATCH bpf 4/7] selftests/bpf/test_offload.py: only check verifier log on verification fails 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: Thu, 03 Dec 2020 22:35:21 +0100 Message-ID: <160703132146.162669.15903502405321937636.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Toke Høiland-Jørgensen Since 6f8a57ccf85 ("bpf: Make verifier log more relevant by default"), the verifier discards log messages for successfully-verified programs. This broke test_offload.py which is looking for a verification message from the driver callback. Change test_offload.py to use the toggle in netdevsim to make the verification fail before looking for the verification message. Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 7afe259c785f..6f8ff2f27027 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -905,11 +905,18 @@ try: sim.tc_flush_filters() + start_test("Test TC offloads failure...") + sim.dfs["dev/bpf_bind_verifier_accept"] = 0 + ret, _, err = sim.cls_bpf_add_filter(obj, verbose=True, skip_sw=True, + fail=False, include_stderr=True) + fail(ret == 0, "TC filter did not reject with TC offloads enabled") + check_verifier_log(err, "[netdevsim] Hello from netdevsim!") + sim.dfs["dev/bpf_bind_verifier_accept"] = 1 + start_test("Test TC offloads work...") ret, _, err = sim.cls_bpf_add_filter(obj, verbose=True, skip_sw=True, fail=False, include_stderr=True) fail(ret != 0, "TC filter did not load with TC offloads enabled") - check_verifier_log(err, "[netdevsim] Hello from netdevsim!") start_test("Test TC offload basics...") dfs = simdev.dfs_get_bound_progs(expected=1) @@ -1026,6 +1033,15 @@ try: rm("/sys/fs/bpf/offload") sim.wait_for_flush() + start_test("Test XDP load failure...") + sim.dfs["dev/bpf_bind_verifier_accept"] = 0 + ret, _, err = bpftool_prog_load("sample_ret0.o", "/sys/fs/bpf/offload", + dev=sim['ifname'], fail=False, include_stderr=True) + fail(ret == 0, "verifier should fail on load") + check_verifier_log(err, "[netdevsim] Hello from netdevsim!") + sim.dfs["dev/bpf_bind_verifier_accept"] = 1 + sim.wait_for_flush() + start_test("Test XDP offload...") _, _, err = sim.set_xdp(obj, "offload", verbose=True, include_stderr=True) ipl = sim.ip_link_show(xdp=True) @@ -1033,7 +1049,6 @@ try: progs = bpftool_prog_list(expected=1) prog = progs[0] fail(link_xdp["id"] != prog["id"], "Loaded program has wrong ID") - check_verifier_log(err, "[netdevsim] Hello from netdevsim!") start_test("Test XDP offload is device bound...") dfs = simdev.dfs_get_bound_progs(expected=1) From patchwork Thu Dec 3 21:35:22 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: 1410658 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EWyEmez1; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LX4NPnz9sVM for ; Fri, 4 Dec 2020 08:37:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389398AbgLCVg5 (ORCPT ); Thu, 3 Dec 2020 16:36:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41954 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389318AbgLCVgz (ORCPT ); Thu, 3 Dec 2020 16:36:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031329; 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=PTgt64JimZPJAfS0azcJyT5Hi69osAbP/LoiBoFsy8w=; b=EWyEmez1lx5rriV7kYf10JqW85m5bWGex25IG6d9swHhBXlbFpxHmj0mor5ZtrdVQGaJuE y9adem4HEq3BlHdS2EeuqOyDlk0aiiqucX9TD6Kgud2qiu8x+CYP6aDXnMeEbAoXjQ+7Pi PU4OdgrnoVjSRCtoKnDhrWZtoiLY6wg= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530--OkRdJHuPkCgYv-xLUm6Ng-1; Thu, 03 Dec 2020 16:35:27 -0500 X-MC-Unique: -OkRdJHuPkCgYv-xLUm6Ng-1 Received: by mail-qv1-f72.google.com with SMTP id t3so2817380qvp.13 for ; Thu, 03 Dec 2020 13:35:26 -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=PTgt64JimZPJAfS0azcJyT5Hi69osAbP/LoiBoFsy8w=; b=kskhFbHHLIB5wi9YF9NjmGRGFAObOWf/zSju8zZYqyUxQcwPMZ5+f32M8iFuzpFdX3 mP1clM4Wn882d/AZhHgtDW21LO0le7hOS2yYCS2W3pQ1v1EtFjGcRmp6pNr02MXwrqT/ iflJCO4Zbxh9+bmPcGSJEyjQZp76TzpnOb+EkAqJF1CwLkOXYUMlGxwkZfE7OZjNvwn7 MwvuLXSipE++uy+LAf+fNWCKOWLXwXQaWQAGq9033NqGYhhQmd8hjXuYXJzk74FAsIZD u9rJcegR+J0YMnXApCkb8Y8I3A0rDxs4zp6t3awf/n7AXUaJtB+Sk1OoixFPVfNp2pXP ck6A== X-Gm-Message-State: AOAM532q9l7g5x3CS4CdACEqK5YZqtc2LIS0bWTiOrvFhE7lBn+kCyle p/Rv5iAgNLL/nIjAdCWAiO068/fN8js2i5Ww0STQf7S39xptuQ3pVy4OUkZ1fKcaO4a+CUc12tU b57DoCu8SXsXlN7CZ X-Received: by 2002:a05:620a:10a3:: with SMTP id h3mr5238087qkk.459.1607031326258; Thu, 03 Dec 2020 13:35:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzy9GQDy+cijqSCW+9W5nUJfm+RHoN1wNqylY2fwJyS9UHaqVAcN4FgNBoHUM9SzN0bMGGmUA== X-Received: by 2002:a05:620a:10a3:: with SMTP id h3mr5238025qkk.459.1607031325675; Thu, 03 Dec 2020 13:35:25 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id f8sm2339143qtp.91.2020.12.03.13.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:24 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 9ED7D1843EF; Thu, 3 Dec 2020 22:35:22 +0100 (CET) Subject: [PATCH bpf 5/7] selftests/bpf/test_offload.py: fix expected case of extack messages 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: Thu, 03 Dec 2020 22:35:22 +0100 Message-ID: <160703132255.162669.6025526680043801946.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Toke Høiland-Jørgensen Commit 7f0a838254bd ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device") changed the case of some of the extack messages being returned when attaching of XDP programs failed. This broke test_offload.py, so let's fix the test to reflect this. Signed-off-by: Toke Høiland-Jørgensen --- tools/testing/selftests/bpf/test_offload.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/test_offload.py b/tools/testing/selftests/bpf/test_offload.py index 6f8ff2f27027..5b0fe8e0b2d2 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -998,7 +998,7 @@ try: fail=False, include_stderr=True) fail(ret == 0, "Replaced XDP program with a program in different mode") check_extack(err, - "native and generic XDP can't be active at the same time.", + "Native and generic XDP can't be active at the same time.", args) start_test("Test MTU restrictions...") @@ -1029,7 +1029,7 @@ try: offload = bpf_pinned("/sys/fs/bpf/offload") ret, _, err = sim.set_xdp(offload, "drv", fail=False, include_stderr=True) fail(ret == 0, "attached offloaded XDP program to drv") - check_extack(err, "using device-bound program without HW_MODE flag is not supported.", args) + check_extack(err, "Using device-bound program without HW_MODE flag is not supported.", args) rm("/sys/fs/bpf/offload") sim.wait_for_flush() From patchwork Thu Dec 3 21:35:23 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: 1410659 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FM/HHnmR; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8LY0cTwz9sVJ for ; Fri, 4 Dec 2020 08:37:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389412AbgLCVg6 (ORCPT ); Thu, 3 Dec 2020 16:36:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21800 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389400AbgLCVg6 (ORCPT ); Thu, 3 Dec 2020 16:36:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031331; 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=DI29VqJzS72LXaEV13zDjLKn6lqs69y45EkLgkg/Hr4=; b=FM/HHnmRx9JERGtKBdgRlHXPOAw81NsNpJfdR0MpxwzWy6+pTmrld67W6QqW710EsToGj+ fEtXZiyJe+AKauJfUCDdhC5XOBHrA8MKjG+HcQjo/G2+xLJqAVW6MxM0ztCxK/I0/bhjum ccMbOK6yArsbmK8rjb1H320/p4kJhwE= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-0EoWOD1HPyywC5UPcbItMg-1; Thu, 03 Dec 2020 16:35:30 -0500 X-MC-Unique: 0EoWOD1HPyywC5UPcbItMg-1 Received: by mail-qk1-f199.google.com with SMTP id x196so3178477qkb.12 for ; Thu, 03 Dec 2020 13:35:30 -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=DI29VqJzS72LXaEV13zDjLKn6lqs69y45EkLgkg/Hr4=; b=DsrPjjz7kOHpMEo5JI4GFK1On6SRnHuWpygUC9rQbXsdu1tb3ROZ/L1NK6aggsy9rU dd/WdZjnFagTk+s/EDfjOjvLDunX7hr0q8h3cwjczjj2b06GDagK2Jgog7Vz8ZBpgZal HgKCfzmCmq1PVTVFII4BJaguP6rH4lvaZTUzpzXIsNLiPzxDEFjK+RwXiuxfUd7Gc1C9 s9sUnm9OaEqtr4qAKNtO1SZ9Cf9dB5AyUhkwG8YJVCplqPIkVwzPvceZ4jxSrwRL5Xmm tZMz6rXLLhla3OMXR+5/zMCBBBdqfZPkVrLfIbfzVJbHMCBuWLs1aP1Gv9hVauIMk9mL QoAQ== X-Gm-Message-State: AOAM532cmmb3sG3TkXxmxW8L1/wzKcrzRjI8LSYzym29S0wtZhPN3NRS W+cfDEp9kGlRc9ieTofUyiWh/wfUKfFeDgl6OtjXLTQ9vrYqyYOVey5YQL4rFv9+WQxJ/Z0RXqG w84COzMJbF/0I5+1D X-Received: by 2002:a05:620a:55b:: with SMTP id o27mr5033789qko.226.1607031329437; Thu, 03 Dec 2020 13:35:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfRbExoNkCbGd9OYQ3RciN25NTK0UbfbhfIQFCsxLV947DkzuxS3TC6F6RTtAe0QwlSNHrmg== X-Received: by 2002:a05:620a:55b:: with SMTP id o27mr5033743qko.226.1607031329039; Thu, 03 Dec 2020 13:35:29 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id j124sm2913011qkf.113.2020.12.03.13.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:35:25 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id B23311843F0; Thu, 3 Dec 2020 22:35:23 +0100 (CET) Subject: [PATCH bpf 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: Thu, 03 Dec 2020 22:35:23 +0100 Message-ID: <160703132365.162669.12565799511526821110.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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 5b0fe8e0b2d2..f861503433c9 100755 --- a/tools/testing/selftests/bpf/test_offload.py +++ b/tools/testing/selftests/bpf/test_offload.py @@ -940,6 +940,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 Thu Dec 3 21:35:24 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: 1410661 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=M3QACRJo; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cn8Y425B0z9sSf for ; Fri, 4 Dec 2020 08:46:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbgLCVpz (ORCPT ); Thu, 3 Dec 2020 16:45:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22283 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbgLCVpy (ORCPT ); Thu, 3 Dec 2020 16:45:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607031868; 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=ZFBdM3j73KJlJPyM9dITVEEIkfrsFpAKD2VpIUN73oI=; b=M3QACRJonSQFQsRbVkyLlr0ZDmg1/SjAGRZdz/4Aql/7i1vQDH2vISwYV/jYH5h/s8YEJw lbcNWWhbtvhbfznfVvHoQx4OxWrp2OY8jIwuqkCaDoA7DpowrjqKe9VoSsg0NjAPiDHQfo ClYkqWNBA7XOgR6JAOjVzAO+JQ82GoQ= 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-342-VT9myripOLeptq4yu0OspQ-1; Thu, 03 Dec 2020 16:44:26 -0500 X-MC-Unique: VT9myripOLeptq4yu0OspQ-1 Received: by mail-ej1-f69.google.com with SMTP id z10so1296490eje.5 for ; Thu, 03 Dec 2020 13:44:25 -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=ZFBdM3j73KJlJPyM9dITVEEIkfrsFpAKD2VpIUN73oI=; b=RR12GN9Bsv7aYQduOtu7KhNo63gXJ61UOroijx9L5bVCHSm8JnypUkcVepFs1oT90I MMwFq8TVldyv7etcibaQGdlvW/g+s01bwJ6T04aUiTuksJeYR3Olcgn0gTS4EOJt0WnH TKdSoDkmhYjCdQkBf4vVE1Bxb5qdx09zMsit/LVc+rKD68Uzf81sTSNsGCa6pNg13QmO K2IDoXW8KCaTIk3KsgpBdnQn/dQ+MXzq7yB/JhAjRmH+matrxtlKX2tn7vy/m/Ul+HkF 2O75GIc+zmG29XPlXpopToLrE5NHTZMWEDK2omGpOBEbUWBk7QZ4DC2HTskIKvz+pIrB GWPg== X-Gm-Message-State: AOAM5315/miEgw6Ct6nBbBf5tw/NQ776qZ8E51zEY1/eofZliRCfolxf 8bzb5ZVvADasxMfgpfO8bn3msgUfRmiDPVlQ+9k/gTLyjwVpnyNdf84CyESp+7bsSVed3WqAZ+S BdUTZFCpp9YAKomFQ X-Received: by 2002:a17:906:17d9:: with SMTP id u25mr4495633eje.34.1607031864630; Thu, 03 Dec 2020 13:44:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyAUSoCcFBxGYA901oiYO8Zd1bujjZOi0w7vxH6KOq/I+aubewMo+Rplg2pAC8w3lRC9GabQ== X-Received: by 2002:a17:906:17d9:: with SMTP id u25mr4495604eje.34.1607031864244; Thu, 03 Dec 2020 13:44:24 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id z19sm1567256ejj.101.2020.12.03.13.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 13:44:23 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id CA1CD1843EC; Thu, 3 Dec 2020 22:35:24 +0100 (CET) Subject: [PATCH bpf 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: Thu, 03 Dec 2020 22:35:24 +0100 Message-ID: <160703132473.162669.16627304955343580502.stgit@toke.dk> In-Reply-To: <160703131710.162669.9632344967082582016.stgit@toke.dk> References: <160703131710.162669.9632344967082582016.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@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 f861503433c9..be2c7e3f57c4 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" % @@ -764,6 +762,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)