diff mbox series

[bpf-next] bpf: make bpf_link_info.iter similar to bpf_iter_link_info

Message ID 20200828051922.758950-1-yhs@fb.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] bpf: make bpf_link_info.iter similar to bpf_iter_link_info | expand

Commit Message

Yonghong Song Aug. 28, 2020, 5:19 a.m. UTC
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: 6b0a249a301e ("bpf: Implement link_query for bpf iterators")
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
 include/uapi/linux/bpf.h       | 6 ++++--
 tools/include/uapi/linux/bpf.h | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

This patch was the first patch in
  https://lore.kernel.org/bpf/20200827000618.2711826-1-yhs@fb.com/
I now sent this separately as it is largely independent and my
immediate follow-ups does not depend on this any more.

Comments

Daniel Borkmann Aug. 28, 2020, 12:36 p.m. UTC | #1
On 8/28/20 7:19 AM, Yonghong Song wrote:
> 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: 6b0a249a301e ("bpf: Implement link_query for bpf iterators")
> Acked-by: Andrii Nakryiko <andriin@fb.com>
> Signed-off-by: Yonghong Song <yhs@fb.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 0388bc0200b0..ef7af384f5ee 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -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;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 0388bc0200b0..ef7af384f5ee 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -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;