Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf...
authorJakub Kicinski <kuba@kernel.org>
Sat, 28 Jan 2023 07:59:45 +0000 (23:59 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 28 Jan 2023 08:00:14 +0000 (00:00 -0800)
Daniel Borkmann says:

====================
bpf-next 2023-01-28

We've added 124 non-merge commits during the last 22 day(s) which contain
a total of 124 files changed, 6386 insertions(+), 1827 deletions(-).

The main changes are:

1) Implement XDP hints via kfuncs with initial support for RX hash and
   timestamp metadata kfuncs, from Stanislav Fomichev and
   Toke Høiland-Jørgensen.
   Measurements on overhead: https://lore.kernel.org/bpf/875yellcx6.fsf@toke.dk

2) Extend libbpf's bpf_tracing.h support for tracing arguments of
   kprobes/uprobes and syscall as a special case, from Andrii Nakryiko.

3) Significantly reduce the search time for module symbols by livepatch
   and BPF, from Jiri Olsa and Zhen Lei.

4) Enable cpumasks to be used as kptrs, which is useful for tracing
   programs tracking which tasks end up running on which CPUs
   in different time intervals, from David Vernet.

5) Fix several issues in the dynptr processing such as stack slot liveness
   propagation, missing checks for PTR_TO_STACK variable offset, etc,
   from Kumar Kartikeya Dwivedi.

6) Various performance improvements, fixes, and introduction of more
   than just one XDP program to XSK selftests, from Magnus Karlsson.

7) Big batch to BPF samples to reduce deprecated functionality,
   from Daniel T. Lee.

8) Enable struct_ops programs to be sleepable in verifier,
   from David Vernet.

9) Reduce pr_warn() noise on BTF mismatches when they are expected under
   the CONFIG_MODULE_ALLOW_BTF_MISMATCH config anyway, from Connor O'Brien.

10) Describe modulo and division by zero behavior of the BPF runtime
    in BPF's instruction specification document, from Dave Thaler.

11) Several improvements to libbpf API documentation in libbpf.h,
    from Grant Seltzer.

12) Improve resolve_btfids header dependencies related to subcmd and add
    proper support for HOSTCC, from Ian Rogers.

13) Add ipip6 and ip6ip decapsulation support for bpf_skb_adjust_room()
    helper along with BPF selftests, from Ziyang Xuan.

14) Simplify the parsing logic of structure parameters for BPF trampoline
    in the x86-64 JIT compiler, from Pu Lehui.

15) Get BTF working for kernels with CONFIG_RUST enabled by excluding
    Rust compilation units with pahole, from Martin Rodriguez Reboredo.

16) Get bpf_setsockopt() working for kTLS on top of TCP sockets,
    from Kui-Feng Lee.

17) Disable stack protection for BPF objects in bpftool given BPF backends
    don't support it, from Holger Hoffstätte.

* tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (124 commits)
  selftest/bpf: Make crashes more debuggable in test_progs
  libbpf: Add documentation to map pinning API functions
  libbpf: Fix malformed documentation formatting
  selftests/bpf: Properly enable hwtstamp in xdp_hw_metadata
  selftests/bpf: Calls bpf_setsockopt() on a ktls enabled socket.
  bpf: Check the protocol of a sock to agree the calls to bpf_setsockopt().
  bpf/selftests: Verify struct_ops prog sleepable behavior
  bpf: Pass const struct bpf_prog * to .check_member
  libbpf: Support sleepable struct_ops.s section
  bpf: Allow BPF_PROG_TYPE_STRUCT_OPS programs to be sleepable
  selftests/bpf: Fix vmtest static compilation error
  tools/resolve_btfids: Alter how HOSTCC is forced
  tools/resolve_btfids: Install subcmd headers
  bpf/docs: Document the nocast aliasing behavior of ___init
  bpf/docs: Document how nested trusted fields may be defined
  bpf/docs: Document cpumask kfuncs in a new file
  selftests/bpf: Add selftest suite for cpumask kfuncs
  selftests/bpf: Add nested trust selftests suite
  bpf: Enable cpumasks to be queried and used as kptrs
  bpf: Disallow NULLable pointers for trusted kfuncs
  ...
====================

Link: https://lore.kernel.org/r/20230128004827.21371-1-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 files changed:
1  2 
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
include/linux/bpf.h
include/linux/netdevice.h
init/Kconfig
kernel/bpf/offload.c
kernel/bpf/syscall.c
kernel/bpf/verifier.c
kernel/trace/bpf_trace.c
net/core/dev.c
net/core/filter.c

Simple merge
Simple merge
diff --cc init/Kconfig
Simple merge
@@@ -75,20 -74,124 +74,121 @@@ bpf_offload_find_netdev(struct net_devi
        return rhashtable_lookup_fast(&offdevs, &netdev, offdevs_params);
  }
  
- int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr)
+ static int __bpf_offload_dev_netdev_register(struct bpf_offload_dev *offdev,
+                                            struct net_device *netdev)
  {
        struct bpf_offload_netdev *ondev;
-       struct bpf_prog_offload *offload;
        int err;
  
-       if (attr->prog_type != BPF_PROG_TYPE_SCHED_CLS &&
-           attr->prog_type != BPF_PROG_TYPE_XDP)
-               return -EINVAL;
+       ondev = kzalloc(sizeof(*ondev), GFP_KERNEL);
+       if (!ondev)
+               return -ENOMEM;
  
-       if (attr->prog_flags)
-               return -EINVAL;
+       ondev->netdev = netdev;
+       ondev->offdev = offdev;
+       INIT_LIST_HEAD(&ondev->progs);
+       INIT_LIST_HEAD(&ondev->maps);
+       err = rhashtable_insert_fast(&offdevs, &ondev->l, offdevs_params);
+       if (err) {
+               netdev_warn(netdev, "failed to register for BPF offload\n");
+               goto err_free;
+       }
+       if (offdev)
+               list_add(&ondev->offdev_netdevs, &offdev->netdevs);
+       return 0;
+ err_free:
+       kfree(ondev);
+       return err;
+ }
+ static void __bpf_prog_offload_destroy(struct bpf_prog *prog)
+ {
+       struct bpf_prog_offload *offload = prog->aux->offload;
+       if (offload->dev_state)
+               offload->offdev->ops->destroy(prog);
 -      /* Make sure BPF_PROG_GET_NEXT_ID can't find this dead program */
 -      bpf_prog_free_id(prog, true);
 -
+       list_del_init(&offload->offloads);
+       kfree(offload);
+       prog->aux->offload = NULL;
+ }
+ static int bpf_map_offload_ndo(struct bpf_offloaded_map *offmap,
+                              enum bpf_netdev_command cmd)
+ {
+       struct netdev_bpf data = {};
+       struct net_device *netdev;
+       ASSERT_RTNL();
+       data.command = cmd;
+       data.offmap = offmap;
+       /* Caller must make sure netdev is valid */
+       netdev = offmap->netdev;
+       return netdev->netdev_ops->ndo_bpf(netdev, &data);
+ }
+ static void __bpf_map_offload_destroy(struct bpf_offloaded_map *offmap)
+ {
+       WARN_ON(bpf_map_offload_ndo(offmap, BPF_OFFLOAD_MAP_FREE));
+       /* Make sure BPF_MAP_GET_NEXT_ID can't find this dead map */
+       bpf_map_free_id(&offmap->map, true);
+       list_del_init(&offmap->offloads);
+       offmap->netdev = NULL;
+ }
+ static void __bpf_offload_dev_netdev_unregister(struct bpf_offload_dev *offdev,
+                                               struct net_device *netdev)
+ {
+       struct bpf_offload_netdev *ondev, *altdev = NULL;
+       struct bpf_offloaded_map *offmap, *mtmp;
+       struct bpf_prog_offload *offload, *ptmp;
+       ASSERT_RTNL();
+       ondev = rhashtable_lookup_fast(&offdevs, &netdev, offdevs_params);
+       if (WARN_ON(!ondev))
+               return;
+       WARN_ON(rhashtable_remove_fast(&offdevs, &ondev->l, offdevs_params));
+       /* Try to move the objects to another netdev of the device */
+       if (offdev) {
+               list_del(&ondev->offdev_netdevs);
+               altdev = list_first_entry_or_null(&offdev->netdevs,
+                                                 struct bpf_offload_netdev,
+                                                 offdev_netdevs);
+       }
+       if (altdev) {
+               list_for_each_entry(offload, &ondev->progs, offloads)
+                       offload->netdev = altdev->netdev;
+               list_splice_init(&ondev->progs, &altdev->progs);
+               list_for_each_entry(offmap, &ondev->maps, offloads)
+                       offmap->netdev = altdev->netdev;
+               list_splice_init(&ondev->maps, &altdev->maps);
+       } else {
+               list_for_each_entry_safe(offload, ptmp, &ondev->progs, offloads)
+                       __bpf_prog_offload_destroy(offload->prog);
+               list_for_each_entry_safe(offmap, mtmp, &ondev->maps, offloads)
+                       __bpf_map_offload_destroy(offmap);
+       }
+       WARN_ON(!list_empty(&ondev->progs));
+       WARN_ON(!list_empty(&ondev->maps));
+       kfree(ondev);
+ }
+ static int __bpf_prog_dev_bound_init(struct bpf_prog *prog, struct net_device *netdev)
+ {
+       struct bpf_offload_netdev *ondev;
+       struct bpf_prog_offload *offload;
+       int err;
  
        offload = kzalloc(sizeof(*offload), GFP_USER);
        if (!offload)
Simple merge
Simple merge
Simple merge
diff --cc net/core/dev.c
Simple merge
Simple merge