Skip to content
  1. Aug 28, 2020
    • Martin KaFai Lau's avatar
      bpf: Add map_meta_equal map ops · f4d05259
      Martin KaFai Lau authored
      Some properties of the inner map is used in the verification time.
      When an inner map is inserted to an outer map at runtime,
      bpf_map_meta_equal() is currently used to ensure those properties
      of the inserting inner map stays the same as the verification
      time.
      
      In particular, the current bpf_map_meta_equal() checks max_entries which
      turns out to be too restrictive for most of the maps which do not use
      max_entries during the verification time.  It limits the use case that
      wants to replace a smaller inner map with a larger inner map.  There are
      some maps do use max_entries during verification though.  For example,
      the map_gen_lookup in array_map_ops uses the max_entries to generate
      the inline lookup code.
      
      To accommodate differences between maps, the map_meta_equal is added
      to bpf_map_ops.  Each map-type can decide what to check when its
      map is used as an inner map during runtime.
      
      Also, some map types cannot be used as an inner map and they are
      currently black listed in bpf_map_meta_alloc() in map_in_map.c.
      It is not unusual that the new map types may not aware that such
      blacklist exists.  This patch enforces an explicit opt-in
      and only allows a map to be used as an inner map if it has
      implemented the map_meta_equal ops.  It is based on the
      discussion in [1].
      
      All maps that support inner map has its map_meta_equal points
      to bpf_map_meta_equal in this patch.  A later patch will
      relax the max_entries check for most maps.  bpf_types.h
      counts 28 map types.  This patch adds 23 ".map_meta_equal"
      by using coccinelle.  -5 for
      	BPF_MAP_TYPE_PROG_ARRAY
      	BPF_MAP_TYPE_(PERCPU)_CGROUP_STORAGE
      	BPF_MAP_TYPE_STRUCT_OPS
      	BPF_MAP_TYPE_ARRAY_OF_MAPS
      	BPF_MAP_TYPE_HASH_OF_MAPS
      
      The "if (inner_map->inner_map_meta)" check in bpf_map_meta_alloc()
      is moved such that the same error is returned.
      
      [1]: https://lore.kernel.org/bpf/20200522022342.899756-1-kafai@fb.com/
      
      
      
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20200828011806.1970400-1-kafai@fb.com
      f4d05259
    • Yonghong Song's avatar
      bpf: Make bpf_link_info.iter similar to bpf_iter_link_info · b0c9eb37
      Yonghong Song authored
      bpf_link_info.iter is used by link_query to return bpf_iter_link_info
      to user space. Fields may be different, e.g., map_fd vs. map_id, so
      we cannot reuse the exact structure. But make them similar, e.g.,
      
        struct bpf_link_info {
           /* common fields */
           union {
      	struct { ... } raw_tracepoint;
      	struct { ... } tracing;
      	...
      	struct {
      	    /* common fields for iter */
      	    union {
      		struct {
      		    __u32 map_id;
      		} map;
      		/* other structs for other targets */
      	    };
      	};
          };
       };
      
      so the structure is extensible the same way as bpf_iter_link_info.
      
      Fixes: 6b0a249a
      
       ("bpf: Implement link_query for bpf iterators")
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20200828051922.758950-1-yhs@fb.com
      b0c9eb37
    • Jesper Dangaard Brouer's avatar
      tools, bpf/build: Cleanup feature files on make clean · 661b37cd
      Jesper Dangaard Brouer authored
      The system for "Auto-detecting system features" located under
      tools/build/ are (currently) used by perf, libbpf and bpftool. It can
      contain stalled feature detection files, which are not cleaned up by
      libbpf and bpftool on make clean (side-note: perf tool is correct).
      
      Fix this by making the users invoke the make clean target.
      
      Some details about the changes. The libbpf Makefile already had a
      clean-config target (which seems to be copy-pasted from perf), but this
      target was not "connected" (a make dependency) to clean target. Choose
      not to rename target as someone might be using it. Did change the output
      from "CLEAN config" to "CLEAN feature-detect", to make it more clear
      what happens.
      
      This is related to the complaint and troubleshooting in the following
      link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/
      
      
      
      Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/
      Link: https://lore.kernel.org/bpf/159851841661.1072907.13770213104521805592.stgit@firesoul
      661b37cd
  2. Aug 27, 2020
  3. Aug 26, 2020
  4. Aug 25, 2020