Skip to content

Commit 76c43ae

Browse files
yonghong-songborkmann
authored andcommitted
bpf: log struct/union attribute for forward type
Current btf internal verbose logger logs fwd type as [2] FWD A type_id=0 where A is the type name. Commit 9d5f9f7 ("bpf: btf: fix struct/union/fwd types with kind_flag") introduced kind_flag which can be used to distinguish whether a forward type is a struct or union. Also, "type_id=0" does not carry any meaningful information for fwd type as btf_type.type = 0 is simply enforced during btf verification and is not used anywhere else. This commit changed the log to [2] FWD A struct if kind_flag = 0, or [2] FWD A union if kind_flag = 1. Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent dd4bfda commit 76c43ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kernel/bpf/btf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,12 +1595,18 @@ static s32 btf_fwd_check_meta(struct btf_verifier_env *env,
15951595
return 0;
15961596
}
15971597

1598+
static void btf_fwd_type_log(struct btf_verifier_env *env,
1599+
const struct btf_type *t)
1600+
{
1601+
btf_verifier_log(env, "%s", btf_type_kflag(t) ? "union" : "struct");
1602+
}
1603+
15981604
static struct btf_kind_operations fwd_ops = {
15991605
.check_meta = btf_fwd_check_meta,
16001606
.resolve = btf_df_resolve,
16011607
.check_member = btf_df_check_member,
16021608
.check_kflag_member = btf_df_check_kflag_member,
1603-
.log_details = btf_ref_type_log,
1609+
.log_details = btf_fwd_type_log,
16041610
.seq_show = btf_df_seq_show,
16051611
};
16061612

0 commit comments

Comments
 (0)