Skip to content

Commit

Permalink
bpf: Make bpf_link_info.iter similar to bpf_iter_link_info
Browse files Browse the repository at this point in the history
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: 6b0a249 ("bpf: Implement link_query for bpf iterators")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200828051922.758950-1-yhs@fb.com
  • Loading branch information
yonghong-song authored and borkmann committed Aug 28, 2020
1 parent 661b37c commit b0c9eb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4251,8 +4251,10 @@ struct bpf_link_info {
__aligned_u64 target_name; /* in/out: target_name buffer ptr */
__u32 target_name_len; /* in/out: target_name buffer len */
union {
__u32 map_id;
} map;
struct {
__u32 map_id;
} map;
};
} iter;
struct {
__u32 netns_ino;
Expand Down
6 changes: 4 additions & 2 deletions tools/include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4251,8 +4251,10 @@ struct bpf_link_info {
__aligned_u64 target_name; /* in/out: target_name buffer ptr */
__u32 target_name_len; /* in/out: target_name buffer len */
union {
__u32 map_id;
} map;
struct {
__u32 map_id;
} map;
};
} iter;
struct {
__u32 netns_ino;
Expand Down

0 comments on commit b0c9eb3

Please sign in to comment.