1. Aug 22, 2023
  2. Aug 19, 2023
    • Yonghong Song's avatar
      selftests/bpf: Fix a selftest compilation error · 0a55264c
      Yonghong Song authored
      When building the kernel and selftest with clang compiler (llvm17 or llvm18),
      I hit the following compilation failure:
        In file included from progs/test_lwt_redirect.c:3:
        In file included from /usr/include/linux/ip.h:21:
        In file included from /usr/include/asm/byteorder.h:5:
        In file included from /usr/include/linux/byteorder/little_endian.h:13:
        /usr/include/linux/swab.h:136:8: error: unknown type name '__always_inline'
          136 | static __always_inline unsigned long __swab(const unsigned long y)
              |        ^
        /usr/include/linux/swab.h:171:8: error: unknown type name '__always_inline'
          171 | static __always_inline __u16 __swab16p(const __u16 *p)
        ...
      
      bpf_helpers.h file provided a definition for __always_inline.
      Putting 'ip.h' after 'bpf_helpers.h' fixed the issue.
      
      Fixes: 43a7c3ef
      
       ("selftests/bpf: Add lwt_xmit tests for BPF_REDIRECT")
      Signed-off-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Link: https://lore.kernel.org/r/20230818174312.1883381-1-yonghong.song@linux.dev
      
      
      Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
      0a55264c
    • Dave Marchevsky's avatar
      selftests/bpf: Add CO-RE relocs kfunc flavors tests · 63ae8eb2
      Dave Marchevsky authored
      
      
      This patch adds selftests that exercise kfunc flavor relocation
      functionality added in the previous patch. The actual kfunc defined
      in kernel/bpf/helpers.c is:
      
        struct task_struct *bpf_task_acquire(struct task_struct *p)
      
      The following relocation behaviors are checked:
      
        struct task_struct *bpf_task_acquire___one(struct task_struct *name)
          * Should succeed despite differing param name
      
        struct task_struct *bpf_task_acquire___two(struct task_struct *p, void *ctx)
          * Should fail because there is no two-param bpf_task_acquire
      
        struct task_struct *bpf_task_acquire___three(void *ctx)
          * Should fail because, despite vmlinux's bpf_task_acquire having one param,
            the types don't match
      
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarDavid Vernet <void@manifault.com>
      Link: https://lore.kernel.org/bpf/20230817225353.2570845-2-davemarchevsky@fb.com
      63ae8eb2
    • Dave Marchevsky's avatar
      libbpf: Support triple-underscore flavors for kfunc relocation · 5964a223
      Dave Marchevsky authored
      
      
      The function signature of kfuncs can change at any time due to their
      intentional lack of stability guarantees. As kfuncs become more widely
      used, BPF program writers will need facilities to support calling
      different versions of a kfunc from a single BPF object. Consider this
      simplified example based on a real scenario we ran into at Meta:
      
        /* initial kfunc signature */
        int some_kfunc(void *ptr)
      
        /* Oops, we need to add some flag to modify behavior. No problem,
          change the kfunc. flags = 0 retains original behavior */
        int some_kfunc(void *ptr, long flags)
      
      If the initial version of the kfunc is deployed on some portion of the
      fleet and the new version on the rest, a fleetwide service that uses
      some_kfunc will currently need to load different BPF programs depending
      on which some_kfunc is available.
      
      Luckily CO-RE provides a facility to solve a very similar problem,
      struct definition changes, by allowing program writers to declare
      my_struct___old and my_struct___new, with ___suffix being considered a
      'flavor' of the non-suffixed name and being ignored by
      bpf_core_type_exists and similar calls.
      
      This patch extends the 'flavor' facility to the kfunc extern
      relocation process. BPF program writers can now declare
      
        extern int some_kfunc___old(void *ptr)
        extern int some_kfunc___new(void *ptr, int flags)
      
      then test which version of the kfunc exists with bpf_ksym_exists.
      Relocation and verifier's dead code elimination will work in concert as
      expected, allowing this pattern:
      
        if (bpf_ksym_exists(some_kfunc___old))
          some_kfunc___old(ptr);
        else
          some_kfunc___new(ptr, 0);
      
      Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarDavid Vernet <void@manifault.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Link: https://lore.kernel.org/bpf/20230817225353.2570845-1-davemarchevsky@fb.com
      5964a223
  3. Aug 18, 2023
  4. Aug 17, 2023
    • Jakub Kicinski's avatar
      Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · f54a2a13
      Jakub Kicinski authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf-next 2023-08-16
      
      We've added 17 non-merge commits during the last 6 day(s) which contain
      a total of 20 files changed, 1179 insertions(+), 37 deletions(-).
      
      The main changes are:
      
      1) Add a BPF hook in sys_socket() to change the protocol ID
         from IPPROTO_TCP to IPPROTO_MPTCP to cover migration for legacy
         applications, from Geliang Tang.
      
      2) Follow-up/fallout fix from the SO_REUSEPORT + bpf_sk_assign work
         to fix a splat on non-fullsock sks in inet[6]_steal_sock,
         from Lorenz Bauer.
      
      3) Improvements to struct_ops links to avoid forcing presence of
         update/validate callbacks. Also add bpf_struct_ops fields documentation,
         from David Vernet.
      
      4) Ensure libbpf sets close-on-exec flag on gzopen, from Marco Vedovati.
      
      5) Several new tcx selftest additions and bpftool link show support for
         tcx and xdp links, from Daniel Borkmann.
      
      6) Fix a smatch warning on uninitialized symbol in
         bpf_perf_link_fill_kprobe, from Yafang Shao.
      
      7) BPF selftest fixes e.g. misplaced break in kfunc_call test,
         from Yipeng Zou.
      
      8) Small cleanup to remove unused declaration bpf_link_new_file,
         from Yue Haibing.
      
      9) Small typo fix to bpftool's perf help message, from Daniel T. Lee.
      
      * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next:
        selftests/bpf: Add mptcpify test
        selftests/bpf: Fix error checks of mptcp open_and_load
        selftests/bpf: Add two mptcp netns helpers
        bpf: Add update_socket_protocol hook
        bpftool: Implement link show support for xdp
        bpftool: Implement link show support for tcx
        selftests/bpf: Add selftest for fill_link_info
        bpf: Fix uninitialized symbol in bpf_perf_link_fill_kprobe()
        net: Fix slab-out-of-bounds in inet[6]_steal_sock
        bpf: Document struct bpf_struct_ops fields
        bpf: Support default .validate() and .update() behavior for struct_ops links
        selftests/bpf: Add various more tcx test cases
        selftests/bpf: Clean up fmod_ret in bench_rename test script
        selftests/bpf: Fix repeat option when kfunc_call verification fails
        libbpf: Set close-on-exec flag on gzopen
        bpftool: fix perf help message
        bpf: Remove unused declaration bpf_link_new_file()
      ====================
      
      Link: https://lore.kernel.org/r/20230816212840.1539-1-daniel@iogearbox.net
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f54a2a13
    • Jakub Kicinski's avatar
      Revert "net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode" · 42b118c9
      Jakub Kicinski authored
      This reverts commit 90bc21aa.
      
      Patch was merged too hastily, Vladimir requested changes in:
      https://lore.kernel.org/all/20230816121305.5dio5tk3chge2ndh@skbuf/
      
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      42b118c9