Commit b0c9eb37 authored by Yonghong Song's avatar Yonghong Song Committed by Daniel Borkmann
Browse files

bpf: Make bpf_link_info.iter similar to bpf_iter_link_info



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
parent 661b37cd
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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 {
				struct {
					__u32 map_id;
				} map;
			};
		} iter;
		struct  {
			__u32 netns_ino;
+4 −2
Original line number Diff line number Diff line
@@ -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 {
				struct {
					__u32 map_id;
				} map;
			};
		} iter;
		struct  {
			__u32 netns_ino;