26 Jan, 2020

1 commit

  • commit 451d1dc886b548d6e18c933adca326c1307023c9 upstream.

    Since, the new syntax of BTF-defined map has been introduced,
    the syntax for using maps under samples directory are mixed up.
    For example, some are already using the new syntax, and some are using
    existing syntax by calling them as 'legacy'.

    As stated at commit abd29c931459 ("libbpf: allow specifying map
    definitions using BTF"), the BTF-defined map has more compatablility
    with extending supported map definition features.

    The commit doesn't replace all of the map to new BTF-defined map,
    because some of the samples still use bpf_load instead of libbpf, which
    can't properly create BTF-defined map.

    This will only updates the samples which uses libbpf API for loading bpf
    program. (ex. bpf_prog_load_xattr)

    Signed-off-by: Daniel T. Lee
    Acked-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Daniel T. Lee
     

22 Sep, 2018

1 commit

  • following commit:
    commit d58e468b1112 ("flow_dissector: implements flow dissector BPF hook")
    added struct bpf_flow_keys which conflicts with the struct with
    same name in sockex2_kern.c and sockex3_kern.c

    similar to commit:
    commit 534e0e52bc23 ("samples/bpf: fix a compilation failure")
    we tried the rename it "flow_keys" but it also conflicted with struct
    having same name in include/net/flow_dissector.h. Hence renaming the
    struct to "flow_key_record". Also, this commit doesn't fix the
    compilation error completely because the similar struct is present in
    sockex3_kern.c. Hence renaming it in both files sockex3_user.c and
    sockex3_kern.c

    Signed-off-by: Prashant Bhole
    Acked-by: Song Liu
    Signed-off-by: Daniel Borkmann

    Prashant Bhole
     

25 Nov, 2016

1 commit

  • since llvm commit "Do not expand UNDEF SDNode during insn selection lowering"
    llvm will generate code that uses uninitialized registers for cases
    where C code is actually uses uninitialized data.
    So this sockex2 example is technically broken.
    Fix it by initializing on the stack variable fully.
    Also increase verifier buffer limit, since verifier output
    may not fit in 64k for this sockex2 code depending on llvm version.

    Signed-off-by: Alexei Starovoitov
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Alexei Starovoitov
     

27 Sep, 2016

1 commit


16 Mar, 2015

1 commit


06 Dec, 2014

1 commit

  • sockex2_kern.c is purposefully large eBPF program in C.
    llvm compiles ~200 lines of C code into ~300 eBPF instructions.

    It's similar to __skb_flow_dissect() to demonstrate that complex packet parsing
    can be done by eBPF.
    Then it uses (struct flow_keys)->dst IP address (or hash of ipv6 dst) to keep
    stats of number of packets per IP.
    User space loads eBPF program, attaches it to loopback interface and prints
    dest_ip->#packets stats every second.

    Usage:
    $sudo samples/bpf/sockex2
    ip 127.0.0.1 count 19
    ip 127.0.0.1 count 178115
    ip 127.0.0.1 count 369437
    ip 127.0.0.1 count 559841
    ip 127.0.0.1 count 750539

    Signed-off-by: Alexei Starovoitov
    Signed-off-by: David S. Miller

    Alexei Starovoitov