Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4577733rdb; Fri, 15 Sep 2023 06:33:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPqPwFePMMQOPjLY4T+CGHxBd12/Iqy7OYf/nSH26GpsCANs/nlJwiKrGRRF9fTX4JG5Be X-Received: by 2002:a92:de11:0:b0:349:7663:566c with SMTP id x17-20020a92de11000000b003497663566cmr1764415ilm.30.1694784794847; Fri, 15 Sep 2023 06:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694784794; cv=none; d=google.com; s=arc-20160816; b=fQMBsH4N4l1dileyPnaepiGrJGlm91tGraojhgNu/v23gKG9FTh2YhZAyQgEjytrYs 8VcCqBqlubxEWKzdhGspKWNH6+5555dcMhA+NFPxx8EalUH6QGz+ExFZTTwJRXFWPrWg CgjtQGtPOb4KtsbFcB9TQgUZYXvLyEVvKzS5Hp2Ycx3c3taBppAWiBIZuVBXlGc8mMmZ kgE4MxeLKY4QaebwBTZRPWJDll9qy4LhxGQeRhEuXS1YIJFmqNMh20Mqr7b/+g4WeC3K EaEqttaY3VLKPAoV3o8S7osQSwQwFjzIwMnF8krIM97HYDokRuk8da6kzCL1rO9K28ck cA0w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=693HESCDNWLf7IFif5nGmnO5yZ/1cMI//siqjqMxuAM=; fh=HV79/dBx9GHxLPq/p4kkxqIji0Fzvj2rnn8hNUn5izE=; b=ZU47MUnFUPE5yjlOrFUBL2WsbW/MFSQ8JCALRBiOXuUtmfAt8aKO+U6prG2Q3fk0KI tTpw6wThSLFXDHsCp09kyH5x3P2LbOKzuqjDmlQ57ZJa9S8QIpSDyz2yWIm/Ws0Ys2yc NU9IZMwmrwu2CZp1m0I/89n0AgxpqEGY3KVzYgq3+GbInsHUcc+8mOsPCA/1w5zt8D7j Qzjp3Oo/zxQfKepoli7U92AJf+G/+KXhUcd+bT/nQv+F35bwGjA7lAHonrXIMmBM5KRd 3/jFPq0p8huso0wrLRYD6ULV6XyhCS4o21XCLDclrqY9t9EK6NIseeW80XoUFEXe+S6u fP3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dgfcs0BJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bx25-20020a056a02051900b00573fc12065csi3559285pgb.242.2023.09.15.06.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 06:33:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dgfcs0BJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E654382A6753; Fri, 15 Sep 2023 01:45:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233060AbjIOIpv (ORCPT + 99 others); Fri, 15 Sep 2023 04:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232242AbjIOIpu (ORCPT ); Fri, 15 Sep 2023 04:45:50 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC132710; Fri, 15 Sep 2023 01:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694767545; x=1726303545; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Qjyaj6/vHYjlTgH8HsMMy0BE05DoiU6MR8cgOG0PfUI=; b=dgfcs0BJrGpl1Jz5lBgaP7jz1ysMyaPP7FJnEp0Uc4/V+RW3cYpTudyl ld59ajUuWRm6VIG9WaPMTJjHPW6s56ZejnSvJ44AiXrhDhmTS9rEHtCwU 7O/B+4WXjFqvH6UW6iwbQHp8wyBtUaDI99APXaVQBl1zOjLOs57ZCa/Hq 8MH5FjqSm0kcJ3Vc1jGNAlrtYRQ9IwA5TQuMqOxL8J8OCjLSmO30SnFm6 m50A5b8DJoOHZmfy+dt9SzXbClvMusNalGiYIXo4MdjaBzd7O6V5HM1Xe XtRm9yi3q60WY8wJ+q8raZl6XcCh9q3GVYCzkd+0EgvbGOjibo3NhZTpp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="445657287" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="445657287" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 01:45:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="748122728" X-IronPort-AV: E=Sophos;i="6.02,148,1688454000"; d="scan'208";a="748122728" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga007.fm.intel.com with ESMTP; 15 Sep 2023 01:45:40 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 21E7F33E80; Fri, 15 Sep 2023 09:45:39 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Cc: Larysa Zaremba , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , linux-kernel@vger.kernel.org, Maciej Fijalkowski Subject: [PATCH bpf-next v2] bpf: Allow to use kfunc XDP hints and frags together Date: Fri, 15 Sep 2023 10:39:10 +0200 Message-ID: <20230915083914.65538-1-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 01:45:56 -0700 (PDT) There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints cannot coexist in a single program. Allow those features to be used together by modifying the flags condition for dev-bound-only programs, segments are still prohibited for fully offloaded programs, hence additional check. Suggested-by: Stanislav Fomichev Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/ Reviewed-by: Maciej Fijalkowski Signed-off-by: Larysa Zaremba --- kernel/bpf/offload.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index ee35f33a96d1..9d8e508c9b86 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -232,7 +232,14 @@ int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr) attr->prog_type != BPF_PROG_TYPE_XDP) return -EINVAL; - if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY) + if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS)) + return -EINVAL; + + /* Frags are allowed only if program is dev-bound-only, but not + * if it is requesting bpf offload. + */ + if (attr->prog_flags & BPF_F_XDP_HAS_FRAGS && + !(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY)) return -EINVAL; if (attr->prog_type == BPF_PROG_TYPE_SCHED_CLS && -- 2.41.0