Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpftool: btf: Support dumping a single type from file #4758

Open
wants to merge 4 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: bpftool: btf: Support dumping a single type from file
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=915544

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d6212d8
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=915544
version: 1

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d6212d8
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=915643
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 442bc81
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=915643
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=915643 expired. Closing PR.

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 4d33dc1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=916148
version: 3

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 6e8ba49
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=916148
version: 3

The command description was missing the optional argument. Add it there
for consistency with the rest of the commands.

Signed-off-by: Daniel Xu <[email protected]>
Handle invalid root_type_ids early, as an invalid ID will cause dumpers
to half-emit valid boilerplate and then bail with an unclean exit. This
is ugly and possibly confusing for users, so preemptively handle the
common error case before any dumping begins.

Signed-off-by: Daniel Xu <[email protected]>
Some projects, for example xdp-tools [0], prefer to check in a minimized
vmlinux.h rather than the complete file which can get rather large.

However, when you try to add a minimized version of a complex struct (eg
struct xfrm_state), things can get quite complex if you're trying to
manually untangle and deduplicate the dependencies.

This commit teaches bpftool to do a minimized dump of a single type by
providing an optional root_id argument.

Example usage:

    $ ./bpftool btf dump file ~/dev/linux/vmlinux | rg "STRUCT 'xfrm_state'"
    [12643] STRUCT 'xfrm_state' size=912 vlen=58

    $ ./bpftool btf dump file ~/dev/linux/vmlinux root_id 12643 format c
    #ifndef __VMLINUX_H__
    #define __VMLINUX_H__

    [..]

    struct xfrm_type_offload;

    struct xfrm_sec_ctx;

    struct xfrm_state {
            possible_net_t xs_net;
            union {
                    struct hlist_node gclist;
                    struct hlist_node bydst;
            };
            union {
                    struct hlist_node dev_gclist;
                    struct hlist_node bysrc;
            };
            struct hlist_node byspi;
    [..]

[0]: https://github.com/xdp-project/xdp-tools/blob/master/headers/bpf/vmlinux.h

Signed-off-by: Daniel Xu <[email protected]>
This commit updates the bash completion script with the new root_id
argument.

Signed-off-by: Daniel Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant