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 sync 2025-02-25 #182

Merged
merged 9 commits into from
Feb 25, 2025
2 changes: 1 addition & 1 deletion BPF-CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c45323b7560ec87c37c729b703c86ee65f136d75
319fc77f8f45a1b3dba15b0cc1a869778fd222f7
2 changes: 1 addition & 1 deletion CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
01f3ce5328c405179b2c69ea047c423dad2bfa6d
239860828f8660e2be487e2fbdae2640cce3fd67
5 changes: 4 additions & 1 deletion include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -6019,7 +6019,10 @@ union bpf_attr {
FN(user_ringbuf_drain, 209, ##ctx) \
FN(cgrp_storage_get, 210, ##ctx) \
FN(cgrp_storage_delete, 211, ##ctx) \
/* */
/* This helper list is effectively frozen. If you are trying to \
* add a new helper, you should add a kfunc instead which has \
* less stability guarantees. See Documentation/bpf/kfuncs.rst \
*/

/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
* know or care about integer value that is now passed as second argument
Expand Down
3 changes: 2 additions & 1 deletion include/uapi/linux/btf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ struct btf_type {
* bits 24-28: kind (e.g. int, ptr, array...etc)
* bits 29-30: unused
* bit 31: kind_flag, currently used by
* struct, union, enum, fwd and enum64
* struct, union, enum, fwd, enum64,
* decl_tag and type_tag
*/
__u32 info;
/* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64.
Expand Down
2 changes: 2 additions & 0 deletions include/uapi/linux/if_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,8 @@ enum {
IFLA_NETKIT_MODE,
IFLA_NETKIT_SCRUB,
IFLA_NETKIT_PEER_SCRUB,
IFLA_NETKIT_HEADROOM,
IFLA_NETKIT_TAILROOM,
__IFLA_NETKIT_MAX,
};
#define IFLA_NETKIT_MAX (__IFLA_NETKIT_MAX - 1)
Expand Down
7 changes: 7 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ FEATURE_TESTS += libbfd-liberty
FEATURE_TESTS += libbfd-liberty-z
FEATURE_TESTS += disassembler-four-args
FEATURE_TESTS += disassembler-init-styled
FEATURE_TESTS += libelf-zstd

FEATURE_DISPLAY := clang-bpf-co-re
FEATURE_DISPLAY += llvm
Expand All @@ -126,6 +127,12 @@ endif

LIBS = $(LIBBPF) -lelf -lz
LIBS_BOOTSTRAP = $(LIBBPF_BOOTSTRAP) -lelf -lz

ifeq ($(feature-libelf-zstd),1)
LIBS += -lzstd
LIBS_BOOTSTRAP += -lzstd
endif

ifeq ($(feature-libcap), 1)
CFLAGS += -DUSE_LIBCAP
LIBS += -lcap
Expand Down
3 changes: 2 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,11 @@ int get_fd_type(int fd)
p_err("can't read link type: %s", strerror(errno));
return -1;
}
if (n == sizeof(path)) {
if (n == sizeof(buf)) {
p_err("can't read link type: path too long!");
return -1;
}
buf[n] = '\0';

if (strstr(buf, "bpf-map"))
return BPF_OBJ_MAP;
Expand Down
12 changes: 6 additions & 6 deletions src/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ static void codegen_destroy(struct bpf_object *obj, const char *obj_name)
continue;
if (bpf_map__is_internal(map) &&
(bpf_map__map_flags(map) & BPF_F_MMAPABLE))
printf("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$zd);\n",
printf("\tskel_free_map_data(skel->%1$s, skel->maps.%1$s.initial_value, %2$zu);\n",
ident, bpf_map_mmap_sz(map));
codegen("\
\n\
Expand Down Expand Up @@ -984,7 +984,7 @@ static int walk_st_ops_shadow_vars(struct btf *btf, const char *ident,

offset = m->offset / 8;
if (next_offset < offset)
printf("\t\t\tchar __padding_%d[%d];\n", i, offset - next_offset);
printf("\t\t\tchar __padding_%d[%u];\n", i, offset - next_offset);

switch (btf_kind(member_type)) {
case BTF_KIND_INT:
Expand Down Expand Up @@ -1052,7 +1052,7 @@ static int walk_st_ops_shadow_vars(struct btf *btf, const char *ident,
/* Cannot fail since it must be a struct type */
size = btf__resolve_size(btf, map_type_id);
if (next_offset < (__u32)size)
printf("\t\t\tchar __padding_end[%d];\n", size - next_offset);
printf("\t\t\tchar __padding_end[%u];\n", size - next_offset);

out:
btf_dump__free(d);
Expand Down Expand Up @@ -2095,7 +2095,7 @@ btfgen_mark_type(struct btfgen_info *info, unsigned int type_id, bool follow_poi
break;
/* tells if some other type needs to be handled */
default:
p_err("unsupported kind: %s (%d)", btf_kind_str(btf_type), type_id);
p_err("unsupported kind: %s (%u)", btf_kind_str(btf_type), type_id);
return -EINVAL;
}

Expand Down Expand Up @@ -2147,7 +2147,7 @@ static int btfgen_record_field_relo(struct btfgen_info *info, struct bpf_core_sp
btf_type = btf__type_by_id(btf, type_id);
break;
default:
p_err("unsupported kind: %s (%d)",
p_err("unsupported kind: %s (%u)",
btf_kind_str(btf_type), btf_type->type);
return -EINVAL;
}
Expand Down Expand Up @@ -2246,7 +2246,7 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
}
/* tells if some other type needs to be handled */
default:
p_err("unsupported kind: %s (%d)", btf_kind_str(btf_type), type_id);
p_err("unsupported kind: %s (%u)", btf_kind_str(btf_type), type_id);
return -EINVAL;
}

Expand Down
14 changes: 7 additions & 7 deletions src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int link_parse_fd(int *argc, char ***argv)

fd = bpf_link_get_fd_by_id(id);
if (fd < 0)
p_err("failed to get link with ID %d: %s", id, strerror(errno));
p_err("failed to get link with ID %u: %s", id, strerror(errno));
return fd;
} else if (is_prefix(**argv, "pinned")) {
char *path;
Expand Down Expand Up @@ -404,23 +404,23 @@ static char *perf_config_hw_cache_str(__u64 config)
if (hw_cache)
snprintf(str, PERF_HW_CACHE_LEN, "%s-", hw_cache);
else
snprintf(str, PERF_HW_CACHE_LEN, "%lld-", config & 0xff);
snprintf(str, PERF_HW_CACHE_LEN, "%llu-", config & 0xff);

op = perf_event_name(evsel__hw_cache_op, (config >> 8) & 0xff);
if (op)
snprintf(str + strlen(str), PERF_HW_CACHE_LEN - strlen(str),
"%s-", op);
else
snprintf(str + strlen(str), PERF_HW_CACHE_LEN - strlen(str),
"%lld-", (config >> 8) & 0xff);
"%llu-", (config >> 8) & 0xff);

result = perf_event_name(evsel__hw_cache_result, config >> 16);
if (result)
snprintf(str + strlen(str), PERF_HW_CACHE_LEN - strlen(str),
"%s", result);
else
snprintf(str + strlen(str), PERF_HW_CACHE_LEN - strlen(str),
"%lld", config >> 16);
"%llu", config >> 16);
return str;
}

Expand Down Expand Up @@ -623,7 +623,7 @@ static void show_link_ifindex_plain(__u32 ifindex)
else
snprintf(devname, sizeof(devname), "(detached)");
if (ret)
snprintf(devname, sizeof(devname), "%s(%d)",
snprintf(devname, sizeof(devname), "%s(%u)",
tmpname, ifindex);
printf("ifindex %s ", devname);
}
Expand Down Expand Up @@ -699,7 +699,7 @@ void netfilter_dump_plain(const struct bpf_link_info *info)
if (pfname)
printf("\n\t%s", pfname);
else
printf("\n\tpf: %d", pf);
printf("\n\tpf: %u", pf);

if (hookname)
printf(" %s", hookname);
Expand Down Expand Up @@ -773,7 +773,7 @@ static void show_uprobe_multi_plain(struct bpf_link_info *info)
printf("func_cnt %u ", info->uprobe_multi.count);

if (info->uprobe_multi.pid)
printf("pid %d ", info->uprobe_multi.pid);
printf("pid %u ", info->uprobe_multi.pid);

printf("\n\t%-16s %-16s %-16s", "offset", "ref_ctr_offset", "cookies");
for (i = 0; i < info->uprobe_multi.count; i++) {
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int do_version(int argc, char **argv)
BPFTOOL_MINOR_VERSION, BPFTOOL_PATCH_VERSION);
#endif
jsonw_name(json_wtr, "libbpf_version");
jsonw_printf(json_wtr, "\"%d.%d\"",
jsonw_printf(json_wtr, "\"%u.%u\"",
libbpf_major_version(), libbpf_minor_version());

jsonw_name(json_wtr, "features");
Expand Down Expand Up @@ -370,7 +370,7 @@ static int do_batch(int argc, char **argv)
while ((cp = strstr(buf, "\\\n")) != NULL) {
if (!fgets(contline, sizeof(contline), fp) ||
strlen(contline) == 0) {
p_err("missing continuation line on command %d",
p_err("missing continuation line on command %u",
lines);
err = -1;
goto err_close;
Expand All @@ -381,7 +381,7 @@ static int do_batch(int argc, char **argv)
*cp = '\0';

if (strlen(buf) + strlen(contline) + 1 > sizeof(buf)) {
p_err("command %d is too long", lines);
p_err("command %u is too long", lines);
err = -1;
goto err_close;
}
Expand Down Expand Up @@ -423,7 +423,7 @@ static int do_batch(int argc, char **argv)
err = -1;
} else {
if (!json_output)
printf("processed %d commands\n", lines);
printf("processed %u commands\n", lines);
}
err_close:
if (fp != stdin)
Expand Down
14 changes: 9 additions & 5 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
}
if (info->value_size) {
for (i = 0; i < n; i++) {
printf("value (CPU %02d):%c",
printf("value (CPU %02u):%c",
i, info->value_size > 16 ? '\n' : ' ');
fprint_hex(stdout, value + i * step,
info->value_size, " ");
Expand Down Expand Up @@ -316,7 +316,7 @@ static char **parse_bytes(char **argv, const char *name, unsigned char *val,
}

if (i != n) {
p_err("%s expected %d bytes got %d", name, n, i);
p_err("%s expected %u bytes got %u", name, n, i);
return NULL;
}

Expand Down Expand Up @@ -462,7 +462,7 @@ static void show_map_header_json(struct bpf_map_info *info, json_writer_t *wtr)
jsonw_string_field(wtr, "name", info->name);

jsonw_name(wtr, "flags");
jsonw_printf(wtr, "%d", info->map_flags);
jsonw_printf(wtr, "%u", info->map_flags);
}

static int show_map_close_json(int fd, struct bpf_map_info *info)
Expand Down Expand Up @@ -588,7 +588,7 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
if (prog_type_str)
printf("owner_prog_type %s ", prog_type_str);
else
printf("owner_prog_type %d ", prog_type);
printf("owner_prog_type %u ", prog_type);
}
if (owner_jited)
printf("owner%s jited",
Expand All @@ -615,7 +615,7 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
printf("\n\t");

if (info->btf_id)
printf("btf_id %d", info->btf_id);
printf("btf_id %u", info->btf_id);

if (frozen)
printf("%sfrozen", info->btf_id ? " " : "");
Expand Down Expand Up @@ -1270,6 +1270,10 @@ static int do_create(int argc, char **argv)
} else if (is_prefix(*argv, "name")) {
NEXT_ARG();
map_name = GET_ARG();
if (strlen(map_name) > BPF_OBJ_NAME_LEN - 1) {
p_info("Warning: map name is longer than %u characters, it will be truncated.",
BPF_OBJ_NAME_LEN - 1);
}
} else if (is_prefix(*argv, "key")) {
if (parse_u32_arg(&argc, &argv, &key_size,
"key size"))
Expand Down
Loading