1. 16 8月, 2019 10 次提交
  2. 15 8月, 2019 1 次提交
  3. 14 8月, 2019 18 次提交
  4. 13 8月, 2019 11 次提交
    • P
      selftests/bpf: fix race in flow dissector tests · 9840a4ff
      Petar Penkov 提交于
      Since the "last_dissection" map holds only the flow keys for the most
      recent packet, there is a small race in the skb-less flow dissector
      tests if a new packet comes between transmitting the test packet, and
      reading its keys from the map. If this happens, the test packet keys
      will be overwritten and the test will fail.
      
      Changing the "last_dissection" map to a hash map, keyed on the
      source/dest port pair resolves this issue. Additionally, let's clear the
      last test results from the map between tests to prevent previous test
      cases from interfering with the following test cases.
      
      Fixes: 0905beec ("selftests/bpf: run flow dissector tests in skb-less mode")
      Signed-off-by: NPetar Penkov <ppenkov@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      9840a4ff
    • P
      tools: bpftool: add feature check for zlib · d66fa3c7
      Peter Wu 提交于
      bpftool requires libelf, and zlib for decompressing /proc/config.gz.
      zlib is a transitive dependency via libelf, and became mandatory since
      elfutils 0.165 (Jan 2016). The feature check of libelf is already done
      in the elfdep target of tools/lib/bpf/Makefile, pulled in by bpftool via
      a dependency on libbpf.a. Add a similar feature check for zlib.
      Suggested-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NPeter Wu <peter@lekensteyn.nl>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      d66fa3c7
    • A
      btf: expose BTF info through sysfs · 341dfcf8
      Andrii Nakryiko 提交于
      Make .BTF section allocated and expose its contents through sysfs.
      
      /sys/kernel/btf directory is created to contain all the BTFs present
      inside kernel. Currently there is only kernel's main BTF, represented as
      /sys/kernel/btf/kernel file. Once kernel modules' BTFs are supported,
      each module will expose its BTF as /sys/kernel/btf/<module-name> file.
      
      Current approach relies on a few pieces coming together:
      1. pahole is used to take almost final vmlinux image (modulo .BTF and
         kallsyms) and generate .BTF section by converting DWARF info into
         BTF. This section is not allocated and not mapped to any segment,
         though, so is not yet accessible from inside kernel at runtime.
      2. objcopy dumps .BTF contents into binary file and subsequently
         convert binary file into linkable object file with automatically
         generated symbols _binary__btf_kernel_bin_start and
         _binary__btf_kernel_bin_end, pointing to start and end, respectively,
         of BTF raw data.
      3. final vmlinux image is generated by linking this object file (and
         kallsyms, if necessary). sysfs_btf.c then creates
         /sys/kernel/btf/kernel file and exposes embedded BTF contents through
         it. This allows, e.g., libbpf and bpftool access BTF info at
         well-known location, without resorting to searching for vmlinux image
         on disk (location of which is not standardized and vmlinux image
         might not be even available in some scenarios, e.g., inside qemu
         during testing).
      
      Alternative approach using .incbin assembler directive to embed BTF
      contents directly was attempted but didn't work, because sysfs_proc.o is
      not re-compiled during link-vmlinux.sh stage. This is required, though,
      to update embedded BTF data (initially empty data is embedded, then
      pahole generates BTF info and we need to regenerate sysfs_btf.o with
      updated contents, but it's too late at that point).
      
      If BTF couldn't be generated due to missing or too old pahole,
      sysfs_btf.c handles that gracefully by detecting that
      _binary__btf_kernel_bin_start (weak symbol) is 0 and not creating
      /sys/kernel/btf at all.
      
      v2->v3:
      - added Documentation/ABI/testing/sysfs-kernel-btf (Greg K-H);
      - created proper kobject (btf_kobj) for btf directory (Greg K-H);
      - undo v2 change of reusing vmlinux, as it causes extra kallsyms pass
        due to initially missing  __binary__btf_kernel_bin_{start/end} symbols;
      
      v1->v2:
      - allow kallsyms stage to re-use vmlinux generated by gen_btf();
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      341dfcf8
    • F
      netfilter: connlabels: prefer static lock initialiser · 10533343
      Florian Westphal 提交于
      seen during boot:
      BUG: spinlock bad magic on CPU#2, swapper/0/1
       lock: nf_connlabels_lock+0x0/0x60, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
      Call Trace:
       do_raw_spin_lock+0x14e/0x1b0
       nf_connlabels_get+0x15/0x40
       ct_init_net+0xc4/0x270
       ops_init+0x56/0x1c0
       register_pernet_operations+0x1c8/0x350
       register_pernet_subsys+0x1f/0x40
       tcf_register_action+0x7c/0x1a0
       do_one_initcall+0x13d/0x2d9
      
      Problem is that ct action init function can run before
      connlabels_init().  Lock has not been initialised yet.
      
      Fix it by using a static initialiser.
      
      Fixes: b57dc7c1 ("net/sched: Introduce action ct")
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      10533343
    • V
      netfilter: nf_nat_proto: make tables static · 0a30ba50
      Valdis Klētnieks 提交于
      Sparse warns about two tables not being declared.
      
        CHECK   net/netfilter/nf_nat_proto.c
      net/netfilter/nf_nat_proto.c:725:26: warning: symbol 'nf_nat_ipv4_ops' was not declared. Should it be static?
      net/netfilter/nf_nat_proto.c:964:26: warning: symbol 'nf_nat_ipv6_ops' was not declared. Should it be static?
      
      And in fact they can indeed be static.
      Signed-off-by: NValdis Kletnieks <valdis.kletnieks@vt.edu>
      Acked-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0a30ba50
    • V
      netfilter: nf_tables: add missing prototypes. · 5785cf15
      Valdis Klētnieks 提交于
      Sparse rightly complains about undeclared symbols.
      
        CHECK   net/netfilter/nft_set_hash.c
      net/netfilter/nft_set_hash.c:647:21: warning: symbol 'nft_set_rhash_type' was not declared. Should it be static?
      net/netfilter/nft_set_hash.c:670:21: warning: symbol 'nft_set_hash_type' was not declared. Should it be static?
      net/netfilter/nft_set_hash.c:690:21: warning: symbol 'nft_set_hash_fast_type' was not declared. Should it be static?
        CHECK   net/netfilter/nft_set_bitmap.c
      net/netfilter/nft_set_bitmap.c:296:21: warning: symbol 'nft_set_bitmap_type' was not declared. Should it be static?
        CHECK   net/netfilter/nft_set_rbtree.c
      net/netfilter/nft_set_rbtree.c:470:21: warning: symbol 'nft_set_rbtree_type' was not declared. Should it be static?
      
      Include nf_tables_core.h rather than nf_tables.h to pick up the additional definitions.
      Signed-off-by: NValdis Kletnieks <valdis.kletnieks@vt.edu>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      5785cf15
    • J
      kbuild: remove all netfilter headers from header-test blacklist. · 2a475c40
      Jeremy Sowden 提交于
      All the blacklisted NF headers can now be compiled stand-alone, so
      removed them from the blacklist.
      
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      2a475c40
    • J
      netfilter: remove "#ifdef __KERNEL__" guards from some headers. · 20a9379d
      Jeremy Sowden 提交于
      A number of non-UAPI Netfilter header-files contained superfluous
      "#ifdef __KERNEL__" guards.  Removed them.
      Signed-off-by: NJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      20a9379d
    • J
      netfilter: add missing IS_ENABLED(CONFIG_NETFILTER) checks to some header-files. · 78458e3e
      Jeremy Sowden 提交于
      linux/netfilter.h defines a number of struct and inline function
      definitions which are only available is CONFIG_NETFILTER is enabled.
      These structs and functions are used in declarations and definitions in
      other header-files.  Added preprocessor checks to make sure these
      headers will compile if CONFIG_NETFILTER is disabled.
      Signed-off-by: NJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      78458e3e
    • J
      netfilter: add missing IS_ENABLED(CONFIG_NF_CONNTRACK) checks to some header-files. · 0abc8bf4
      Jeremy Sowden 提交于
      struct nf_conn contains a "struct nf_conntrack ct_general" member and
      struct net contains a "struct netns_ct ct" member which are both only
      defined in CONFIG_NF_CONNTRACK is enabled.  These members are used in a
      number of inline functions defined in other header-files.  Added
      preprocessor checks to make sure the headers will compile if
      CONFIG_NF_CONNTRACK is disabled.
      Signed-off-by: NJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0abc8bf4
    • J
      netfilter: add missing IS_ENABLED(CONFIG_NF_TABLES) check to header-file. · 47e640af
      Jeremy Sowden 提交于
      nf_tables.h defines an API comprising several inline functions and
      macros that depend on the nft member of struct net.  However, this is
      only defined is CONFIG_NF_TABLES is enabled.  Added preprocessor checks
      to ensure that nf_tables.h will compile if CONFIG_NF_TABLES is disabled.
      Signed-off-by: NJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      47e640af