]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpftool: Support 24-bit vlen
authorAlan Maguire <alan.maguire@oracle.com>
Fri, 17 Apr 2026 14:30:20 +0000 (15:30 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 21 Apr 2026 00:52:48 +0000 (17:52 -0700)
Adjust btf_vlen() usage to handle 24-bit vlen.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/r/20260417143023.1551481-4-alan.maguire@oracle.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/btf.c
tools/bpf/bpftool/btf_dumper.c
tools/bpf/bpftool/gen.c

index 2e899e940034108b1ea362d091056700ab70be5a..6ef908adf3a4a59a618c194d76b8bf45b490ea03 100644 (file)
@@ -179,8 +179,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
        case BTF_KIND_STRUCT:
        case BTF_KIND_UNION: {
                const struct btf_member *m = (const void *)(t + 1);
-               __u16 vlen = BTF_INFO_VLEN(t->info);
-               int i;
+               __u32 i, vlen = BTF_INFO_VLEN(t->info);
 
                if (json_output) {
                        jsonw_uint_field(w, "size", t->size);
@@ -225,9 +224,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
        }
        case BTF_KIND_ENUM: {
                const struct btf_enum *v = (const void *)(t + 1);
-               __u16 vlen = BTF_INFO_VLEN(t->info);
+               __u32 i, vlen = BTF_INFO_VLEN(t->info);
                const char *encoding;
-               int i;
 
                encoding = btf_kflag(t) ? "SIGNED" : "UNSIGNED";
                if (json_output) {
@@ -263,9 +261,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
        }
        case BTF_KIND_ENUM64: {
                const struct btf_enum64 *v = btf_enum64(t);
-               __u16 vlen = btf_vlen(t);
+               __u32 i, vlen = btf_vlen(t);
                const char *encoding;
-               int i;
 
                encoding = btf_kflag(t) ? "SIGNED" : "UNSIGNED";
                if (json_output) {
@@ -325,8 +322,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
        }
        case BTF_KIND_FUNC_PROTO: {
                const struct btf_param *p = (const void *)(t + 1);
-               __u16 vlen = BTF_INFO_VLEN(t->info);
-               int i;
+               __u32 i, vlen = BTF_INFO_VLEN(t->info);
 
                if (json_output) {
                        jsonw_uint_field(w, "ret_type_id", t->type);
@@ -369,8 +365,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
        case BTF_KIND_DATASEC: {
                const struct btf_var_secinfo *v = (const void *)(t + 1);
                const struct btf_type *vt;
-               __u16 vlen = BTF_INFO_VLEN(t->info);
-               int i;
+               __u32 i, vlen = BTF_INFO_VLEN(t->info);
 
                if (json_output) {
                        jsonw_uint_field(w, "size", t->size);
@@ -675,7 +670,7 @@ static __u64 btf_name_hasher(__u64 hash, const struct btf *btf, __u32 name_off)
 static __u64 btf_type_disambig_hash(const struct btf *btf, __u32 id, bool include_members)
 {
        const struct btf_type *t = btf__type_by_id(btf, id);
-       int i;
+       __u32 i;
        size_t hash = 0;
 
        hash = btf_name_hasher(hash, btf, t->name_off);
index def297e879f453d8fa54c2a9e00a915d9b1039ab..9dc8425b1789926bca082c37e4060617d27d1294 100644 (file)
@@ -150,7 +150,7 @@ static int btf_dumper_enum(const struct btf_dumper *d,
 {
        const struct btf_enum *enums = btf_enum(t);
        __s64 value;
-       __u16 i;
+       __u32 i;
 
        switch (t->size) {
        case 8:
@@ -189,7 +189,7 @@ static int btf_dumper_enum64(const struct btf_dumper *d,
        const struct btf_enum64 *enums = btf_enum64(t);
        __u32 val_lo32, val_hi32;
        __u64 value;
-       __u16 i;
+       __u32 i;
 
        value = *(__u64 *)data;
        val_lo32 = (__u32)value;
index 2f9e10752e288d1c6ab9f5f40da82099aeb69a6f..37159e02f418cb597afdf1ba3e05e1e5302737e5 100644 (file)
@@ -2094,7 +2094,8 @@ btfgen_mark_type(struct btfgen_info *info, unsigned int type_id, bool follow_poi
        struct btf_type *cloned_type;
        struct btf_param *param;
        struct btf_array *array;
-       int err, i;
+       __u32 i;
+       int err;
 
        if (type_id == 0)
                return 0;
@@ -2229,7 +2230,8 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
        const struct btf_type *btf_type;
        struct btf *btf = info->src_btf;
        struct btf_type *cloned_type;
-       int i, err;
+       int err;
+       __u32 i;
 
        if (type_id == 0)
                return 0;
@@ -2249,7 +2251,7 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
        case BTF_KIND_STRUCT:
        case BTF_KIND_UNION: {
                struct btf_member *m = btf_members(btf_type);
-               __u16 vlen = btf_vlen(btf_type);
+               __u32 vlen = btf_vlen(btf_type);
 
                if (behind_ptr)
                        break;
@@ -2286,7 +2288,7 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
                break;
        }
        case BTF_KIND_FUNC_PROTO: {
-               __u16 vlen = btf_vlen(btf_type);
+               __u32 vlen = btf_vlen(btf_type);
                struct btf_param *param;
 
                /* mark ret type */
@@ -2492,8 +2494,9 @@ static struct btf *btfgen_get_btf(struct btfgen_info *info)
 {
        struct btf *btf_new = NULL;
        unsigned int *ids = NULL;
-       unsigned int i, n = btf__type_cnt(info->marked_btf);
+       unsigned int n = btf__type_cnt(info->marked_btf);
        int err = 0;
+       __u32 i;
 
        btf_new = btf__new_empty();
        if (!btf_new) {
@@ -2523,8 +2526,7 @@ static struct btf *btfgen_get_btf(struct btfgen_info *info)
                /* add members for struct and union */
                if (btf_is_composite(type)) {
                        struct btf_member *cloned_m, *m;
-                       unsigned short vlen;
-                       int idx_src;
+                       __u32 vlen, idx_src;
 
                        name = btf__str_by_offset(info->src_btf, type->name_off);