From patchwork Thu Sep 14 08:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 13384816 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F1B1CFBD for ; Thu, 14 Sep 2023 08:43:30 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD4E1FD9; Thu, 14 Sep 2023 01:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694681010; x=1726217010; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=iYC62UtRoejh4gTBR8ZARtuwUYWBWuvoadPJmKvqBHc=; b=PxogW5Hcv9SkjIlLqT2+a8iVdqLSOenOA8AiHhTbVSxdzsc4nNnCnkM1 K3VFWCMxXkrn1JOYZDeWXkY3WajTwphvTAQ3p6qaRXgfbYR4Rl1w/ATvA 2u+4Br/PcsJK7UTVMxiuGAi3oZOq7qXG5N066/ioYgYDjXWjDn9oTP/kW YHy1peoC5GhdiXQWnYC0bpC2yfcJAkfwiVyErkd1qHptE8F+g+uxZLoP8 5wUiRGAEVMeI+isWkrJEcXIt4jf//ETsXZE8mOWQ+NV4OouslDGq0zK42 0Rb/8iROurR5Y3Ew1oImn4n364LCCAVJ95IGkIdioZLk9x3mtuovNMDYR Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="378815020" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="378815020" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 01:43:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="991315995" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="991315995" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga006.fm.intel.com with ESMTP; 14 Sep 2023 01:43:25 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 83FA332CB0; Thu, 14 Sep 2023 09:43:24 +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 Subject: [PATCH bpf-next] bpf: Allow to use kfunc XDP hints and frags together Date: Thu, 14 Sep 2023 10:37:11 +0200 Message-ID: <20230914083716.57443-1-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net 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 conditions. Suggested-by: Stanislav Fomichev Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/ Signed-off-by: Larysa Zaremba Reviewed-by: Maciej Fijalkowski --- kernel/bpf/offload.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index ee35f33a96d1..43aded96c79b 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -232,7 +232,11 @@ 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; + + 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 &&