From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC46FC3F6B0 for ; Mon, 22 Aug 2022 23:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238269AbiHVX5Z (ORCPT ); Mon, 22 Aug 2022 19:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbiHVX5X (ORCPT ); Mon, 22 Aug 2022 19:57:23 -0400 Received: from 66-220-155-178.mail-mxout.facebook.com (66-220-155-178.mail-mxout.facebook.com [66.220.155.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225DB56B91 for ; Mon, 22 Aug 2022 16:57:23 -0700 (PDT) Received: by devbig010.atn6.facebook.com (Postfix, from userid 115148) id 0DE8210CFE9EF; Mon, 22 Aug 2022 16:57:09 -0700 (PDT) From: Joanne Koong To: bpf@vger.kernel.org Cc: andrii@kernel.org, daniel@iogearbox.net, ast@kernel.org, kafai@fb.com, kuba@kernel.org, netdev@vger.kernel.org, Joanne Koong Subject: [PATCH bpf-next v4 0/3] Add skb + xdp dynptrs Date: Mon, 22 Aug 2022 16:56:46 -0700 Message-Id: <20220822235649.2218031-1-joannelkoong@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patchset is the 2nd in the dynptr series. The 1st can be found here = [0]. This patchset adds skb and xdp type dynptrs, which have two main benefits= for packet parsing: * allowing operations on sizes that are not statically known at compile-time (eg variable-sized accesses). * more ergonomic and less brittle iteration through data (eg does not= need manual if checking for being within bounds of data_end) When comparing the differences in runtime for packet parsing without dynp= trs vs. with dynptrs for the more simple cases, there is no noticeable differ= ence. For the more complex cases where lengths are non-statically known at comp= ile time, there can be a significant speed-up when using dynptrs (eg a 2x spe= ed up for cls redirection). Patch 3 contains more details as well as examples o= f how to use skb and xdp dynptrs. [0] https://lore.kernel.org/bpf/20220523210712.3641569-1-joannelkoong@gma= il.com/ -- Changelog: v3 =3D https://lore.kernel.org/bpf/20220822193442.657638-1-joannelkoong@g= mail.com/ v3 -> v4 * Forgot to commit --amend the kernel test robot error fixups v2 =3D https://lore.kernel.org/bpf/20220811230501.2632393-1-joannelkoong@= gmail.com/ v2 -> v3 * Fix kernel test robot build test errors v1 =3D https://lore.kernel.org/bpf/20220726184706.954822-1-joannelkoong@g= mail.com/ v1 -> v2 * Return data slices to rd-only skb dynptrs (Martin) * bpf_dynptr_write allows writes to frags for skb dynptrs, but always invalidates associated data slices (Martin) * Use switch casing instead of ifs (Andrii) * Use 0xFD for experimental kind number in the selftest (Zvi) * Put selftest conversions w/ dynptrs into new files (Alexei) * Add new selftest "test_cls_redirect_dynptr.c"=20 Joanne Koong (3): bpf: Add skb dynptrs bpf: Add xdp dynptrs selftests/bpf: tests for using dynptrs to parse skb and xdp buffers include/linux/bpf.h | 87 +- include/linux/filter.h | 7 + include/uapi/linux/bpf.h | 59 +- kernel/bpf/helpers.c | 93 +- kernel/bpf/verifier.c | 105 +- net/core/filter.c | 99 +- tools/include/uapi/linux/bpf.h | 59 +- .../selftests/bpf/prog_tests/cls_redirect.c | 25 + .../testing/selftests/bpf/prog_tests/dynptr.c | 132 ++- .../selftests/bpf/prog_tests/l4lb_all.c | 2 + .../bpf/prog_tests/parse_tcp_hdr_opt.c | 85 ++ .../selftests/bpf/prog_tests/xdp_attach.c | 9 +- .../testing/selftests/bpf/progs/dynptr_fail.c | 111 ++ .../selftests/bpf/progs/dynptr_success.c | 29 + .../bpf/progs/test_cls_redirect_dynptr.c | 968 ++++++++++++++++++ .../bpf/progs/test_l4lb_noinline_dynptr.c | 468 +++++++++ .../bpf/progs/test_parse_tcp_hdr_opt.c | 119 +++ .../bpf/progs/test_parse_tcp_hdr_opt_dynptr.c | 110 ++ .../selftests/bpf/progs/test_xdp_dynptr.c | 240 +++++ .../selftests/bpf/test_tcp_hdr_options.h | 1 + 20 files changed, 2693 insertions(+), 115 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/parse_tcp_hdr_= opt.c create mode 100644 tools/testing/selftests/bpf/progs/test_cls_redirect_d= ynptr.c create mode 100644 tools/testing/selftests/bpf/progs/test_l4lb_noinline_= dynptr.c create mode 100644 tools/testing/selftests/bpf/progs/test_parse_tcp_hdr_= opt.c create mode 100644 tools/testing/selftests/bpf/progs/test_parse_tcp_hdr_= opt_dynptr.c create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_dynptr.c --=20 2.30.2