bpf: make bpf_link_info.iter similar to bpf_iter_link_info
Subsystems (3)
PATCH 1/1 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 asbpf_iter_link_info.
--- 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/[email protected]/
I now sent this separately as it is largely independent and my immediate follow-ups does not depend on this any more.
include/uapi/linux/bpf.h +4 -2
@@ -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;
tools/include/uapi/linux/bpf.h +4 -2
@@ -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;
Signature · 1 line
2.24.1
Quoted 20 lines · Yonghong Song
bpf_link_info.iter is used by
link_queryto returnbpf_iter_link_infoto user space. Fields may be different ,e.g.,map_fdvs.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 */ }; }; };
Quoted 7 lines
};
so the structure is extensible the same way asbpf_iter_link_info.Fixes 6b0a249a301e ("bpf: Implement link_query for bpf iterators")Acked-by Andrii Nakryiko <[email protected]>Signed-off-by Yonghong Song <[email protected]>
Applied, thanks!