21 Jan, 2020

1 commit

  • Fix all files in samples/bpf to include libbpf header files with the bpf/
    prefix, to be consistent with external users of the library. Also ensure
    that all includes of exported libbpf header files (those that are exported
    on 'make install' of the library) use bracketed includes instead of quoted.

    To make sure no new files are introduced that doesn't include the bpf/
    prefix in its include, remove tools/lib/bpf from the include path entirely,
    and use tools/lib instead.

    Fixes: 6910d7d3867a ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157952560911.1683545.8795966751309534150.stgit@toke.dk

    Toke Høiland-Jørgensen
     

16 Dec, 2019

1 commit

  • When attaching XDP programs, userspace can set flags to request the attach
    mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
    are requested, the kernel will attempt to attach in driver mode, and then
    silently fall back to SKB mode if this fails.

    The silent fallback is a major source of user confusion, as users will try
    to load a program on a device without XDP support, and instead of an error
    they will get the silent fallback behaviour, not notice, and then wonder
    why performance is not what they were expecting.

    In an attempt to combat this, let's switch all the samples to default to
    explicitly requesting driver-mode attach. As part of this, ensure that all
    the userspace utilities have a switch to enable SKB mode. For those that
    have a switch to request driver mode, keep it but turn it into a no-op.

    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Acked-by: David Ahern
    Link: https://lore.kernel.org/bpf/20191216110742.364456-1-toke@redhat.com

    Toke Høiland-Jørgensen
     

26 Jun, 2019

1 commit

  • Currently, each xdp samples are inconsistent in the use.
    Most of the samples fetch the interface with it's name.
    (ex. xdp1, xdp2skb, xdp_redirect_cpu, xdp_sample_pkts, etc.)

    But some of the xdp samples are fetching the interface with
    ifindex by command argument.

    This commit enables xdp samples to fetch interface with it's name
    without changing the original index interface fetching.
    ( fetching in the same way as xdp_sample_pkts_user.c does.)

    Signed-off-by: Daniel T. Lee
    Acked-by: Toke Høiland-Jørgensen
    Acked-by: Jesper Dangaard Brouer
    Acked-by: Song Liu
    Signed-off-by: Daniel Borkmann

    Daniel T. Lee
     

20 Jun, 2019

1 commit

  • Alexei Starovoitov says:

    ====================
    pull-request: bpf-next 2019-06-19

    The following pull-request contains BPF updates for your *net-next* tree.

    The main changes are:

    1) new SO_REUSEPORT_DETACH_BPF setsocktopt, from Martin.

    2) BTF based map definition, from Andrii.

    3) support bpf_map_lookup_elem for xskmap, from Jonathan.

    4) bounded loops and scalar precision logic in the verifier, from Alexei.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

18 Jun, 2019

1 commit

  • Currently, header inclusion in each file is inconsistent.
    For example, "libbpf.h" header is included as multiple ways.

    #include "bpf/libbpf.h"
    #include "libbpf.h"

    Due to commit b552d33c80a9 ("samples/bpf: fix include path
    in Makefile"), $(srctree)/tools/lib/bpf/ path had been included
    during build, path "bpf/" in header isn't necessary anymore.

    This commit removes path "bpf/" in header inclusion.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann

    Daniel T. Lee
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of version 2 of the gnu general public license as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 64 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141901.894819585@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

22 Feb, 2019

1 commit

  • The xdp_redirect and xdp_redirect_map sample programs both load a dummy
    program onto the egress interfaces. However, the unload code checks these
    programs against the wrong id number, and thus refuses to unload them. Fix
    the comparison to avoid this.

    Fixes: 3b7a8ec2dec3 ("samples/bpf: Check the prog id before exiting")
    Signed-off-by: Toke Høiland-Jørgensen
    Acked-by: Maciej Fijalkowski
    Acked-by: Martin KaFai Lau
    Signed-off-by: Daniel Borkmann

    Toke Høiland-Jørgensen
     

02 Feb, 2019

3 commits

  • Check the program id within the signal handler on polling xdp samples
    that were previously converted to libbpf usage. Avoid the situation of
    unloading the program that was not attached by sample that is exiting.
    Handle also the case where bpf_get_link_xdp_id didn't exit with an error
    but the xdp program was not found on an interface.

    Reported-by: Michal Papaj
    Reported-by: Jakub Spizewski
    Signed-off-by: Maciej Fijalkowski
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Maciej Fijalkowski
     
  • Make xdp samples consistent with iproute2 behavior and set the
    XDP_FLAGS_UPDATE_IF_NOEXIST by default when setting the xdp program on
    interface. Provide an option for user to force the program loading,
    which as a result will not include the mentioned flag in
    bpf_set_link_xdp_fd call.

    Signed-off-by: Maciej Fijalkowski
    Reviewed-by: Jakub Kicinski
    Acked-by: John Fastabend
    Signed-off-by: Daniel Borkmann

    Maciej Fijalkowski
     
  • Some of XDP samples that are attaching the bpf program to the interface
    via libbpf's bpf_set_link_xdp_fd are still using the bpf_load.c for
    loading and manipulating the ebpf program and maps. Convert them to do
    this through libbpf usage and remove bpf_load from the picture.

    While at it remove what looks like debug leftover in
    xdp_redirect_map_user.c

    In xdp_redirect_cpu, change the way that the program to be loaded onto
    interface is chosen - user now needs to pass the program's section name
    instead of the relative number. In case of typo print out the section
    names to choose from.

    Signed-off-by: Maciej Fijalkowski
    Reviewed-by: Jakub Kicinski
    Acked-by: Jesper Dangaard Brouer
    Signed-off-by: Daniel Borkmann

    Maciej Fijalkowski
     

15 May, 2018

1 commit


03 Feb, 2018

1 commit


29 Oct, 2017

1 commit


30 Aug, 2017

1 commit

  • For supporting XDP_REDIRECT, a device driver must (obviously)
    implement the "TX" function ndo_xdp_xmit(). An additional requirement
    is you cannot TX out a device, unless it also have a xdp bpf program
    attached. This dependency is caused by the driver code need to setup
    XDP resources before it can ndo_xdp_xmit.

    Update bpf samples xdp_redirect and xdp_redirect_map to automatically
    attach a dummy XDP program to the configured ifindex_out device. Use
    the XDP flag XDP_FLAGS_UPDATE_IF_NOEXIST on the dummy load, to avoid
    overriding an existing XDP prog on the device.

    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: David S. Miller

    Jesper Dangaard Brouer
     

18 Jul, 2017

2 commits

  • When testing with a driver that has both native and generic redirect support:

    $ sudo ./samples/bpf/xdp_redirect -N 5 6
    input: 5 output: 6
    ifindex 6: 4961879 pkt/s
    ifindex 6: 6391319 pkt/s
    ifindex 6: 6419468 pkt/s

    $ sudo ./samples/bpf/xdp_redirect -S 5 6
    input: 5 output: 6
    ifindex 6: 1845435 pkt/s
    ifindex 6: 3882850 pkt/s
    ifindex 6: 3893974 pkt/s

    $ sudo ./samples/bpf/xdp_redirect_map -N 5 6
    input: 5 output: 6
    map[0] (vports) = 4, map[1] (map) = 5, map[2] (count) = 0
    ifindex 6: 2207374 pkt/s
    ifindex 6: 6212869 pkt/s
    ifindex 6: 6286515 pkt/s

    $ sudo ./samples/bpf/xdp_redirect_map -S 5 6
    input: 5 output: 6
    map[0] (vports) = 4, map[1] (map) = 5, map[2] (count) = 0
    ifindex 6: 5052528 pkt/s
    ifindex 6: 5736631 pkt/s
    ifindex 6: 5739962 pkt/s

    Signed-off-by: Andy Gospodarek
    Acked-by: John Fastabend
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Andy Gospodarek
     
  • Signed-off-by: John Fastabend
    Tested-by: Andy Gospodarek
    Acked-by: Daniel Borkmann
    Acked-by: Jesper Dangaard Brouer
    Signed-off-by: David S. Miller

    John Fastabend