Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BPF-CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
319fc77f8f45a1b3dba15b0cc1a869778fd222f7
0c2623cef4f49e1ef6a908a389eea86130d11057
2 changes: 1 addition & 1 deletion CHECKPOINT-COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
239860828f8660e2be487e2fbdae2640cce3fd67
25601e85441dd91cf7973b002f27af4c5b8691ea
6 changes: 0 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ INSTALL ?= install
RM ?= rm -f
RMDIR ?= rmdir --ignore-fail-on-non-empty

ifeq ($(V),1)
Q =
else
Q = @
endif

prefix ?= /usr/local
mandir ?= $(prefix)/man
man8dir = $(mandir)/man8
Expand Down
35 changes: 35 additions & 0 deletions include/uapi/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#define BPF_XCHG (0xe0 | BPF_FETCH) /* atomic exchange */
#define BPF_CMPXCHG (0xf0 | BPF_FETCH) /* atomic compare-and-write */

#define BPF_LOAD_ACQ 0x100 /* load-acquire */
#define BPF_STORE_REL 0x110 /* store-release */

enum bpf_cond_pseudo_jmp {
BPF_MAY_GOTO = 0,
};
Expand Down Expand Up @@ -1207,6 +1210,7 @@ enum bpf_perf_event_type {
#define BPF_F_BEFORE (1U << 3)
#define BPF_F_AFTER (1U << 4)
#define BPF_F_ID (1U << 5)
#define BPF_F_PREORDER (1U << 6)
#define BPF_F_LINK BPF_F_LINK /* 1 << 13 */

/* If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the
Expand Down Expand Up @@ -1648,6 +1652,7 @@ union bpf_attr {
};
__u32 next_id;
__u32 open_flags;
__s32 fd_by_id_token_fd;
};

struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */
Expand Down Expand Up @@ -6916,6 +6921,12 @@ enum {
BPF_SOCK_OPS_ALL_CB_FLAGS = 0x7F,
};

enum {
SK_BPF_CB_TX_TIMESTAMPING = 1<<0,
SK_BPF_CB_MASK = (SK_BPF_CB_TX_TIMESTAMPING - 1) |
SK_BPF_CB_TX_TIMESTAMPING
};

/* List of known BPF sock_ops operators.
* New entries can only be added at the end
*/
Expand Down Expand Up @@ -7028,6 +7039,29 @@ enum {
* by the kernel or the
* earlier bpf-progs.
*/
BPF_SOCK_OPS_TSTAMP_SCHED_CB, /* Called when skb is passing
* through dev layer when
* SK_BPF_CB_TX_TIMESTAMPING
* feature is on.
*/
BPF_SOCK_OPS_TSTAMP_SND_SW_CB, /* Called when skb is about to send
* to the nic when SK_BPF_CB_TX_TIMESTAMPING
* feature is on.
*/
BPF_SOCK_OPS_TSTAMP_SND_HW_CB, /* Called in hardware phase when
* SK_BPF_CB_TX_TIMESTAMPING feature
* is on.
*/
BPF_SOCK_OPS_TSTAMP_ACK_CB, /* Called when all the skbs in the
* same sendmsg call are acked
* when SK_BPF_CB_TX_TIMESTAMPING
* feature is on.
*/
BPF_SOCK_OPS_TSTAMP_SENDMSG_CB, /* Called when every sendmsg syscall
* is triggered. It's used to correlate
* sendmsg timestamp with corresponding
* tskey.
*/
};

/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect
Expand Down Expand Up @@ -7094,6 +7128,7 @@ enum {
TCP_BPF_SYN_IP = 1006, /* Copy the IP[46] and TCP header */
TCP_BPF_SYN_MAC = 1007, /* Copy the MAC, IP[46], and TCP header */
TCP_BPF_SOCK_OPS_CB_FLAGS = 1008, /* Get or Set TCP sock ops flags */
SK_BPF_CB_FLAGS = 1009, /* Get or set sock ops flags in socket */
};

enum {
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Missing asm support
*
* __BIT128() would not work in the asm code, as it shifts an
* 'unsigned __init128' data type as direct representation of
* 'unsigned __int128' data type as direct representation of
* 128 bit constants is not supported in the gcc compiler, as
* they get silently truncated.
*
Expand Down
21 changes: 8 additions & 13 deletions scripts/sync-kernel-expected-diff.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
libbpf
--- src/Makefile
+++ src/Makefile
@@ -1,10 +1,8 @@
@@ -1,13 +1,11 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-include ../../scripts/Makefile.include
+include Makefile.include
Expand All @@ -32,17 +32,12 @@
-srctree := $(patsubst %/,%,$(dir $(srctree)))
endif

ifeq ($(V),1)
@@ -13,7 +11,7 @@
Q = @
endif

-BPF_DIR = $(srctree)/tools/lib/bpf
+BPF_DIR = $(srctree)/libbpf/src

ifneq ($(OUTPUT),)
_OUTPUT := $(OUTPUT)
@@ -43,16 +41,16 @@
@@ -37,16 +35,16 @@
$(QUIET_MKDIR)mkdir -p $@

$(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT)
Expand All @@ -63,7 +58,7 @@
ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" $@ install_headers

$(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
@@ -76,9 +74,9 @@
@@ -75,9 +73,9 @@
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(or $(OUTPUT),.) \
-I$(LIBBPF_INCLUDE) \
Expand All @@ -89,7 +84,7 @@
endif

LIBS = $(LIBBPF) -lelf -lz
@@ -214,7 +208,7 @@
@@ -225,7 +219,7 @@
$(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
$(QUIET_CLANG)$(CLANG) \
-I$(or $(OUTPUT),.) \
Expand All @@ -98,7 +93,7 @@
-I$(LIBBPF_BOOTSTRAP_INCLUDE) \
-g -O2 -Wall -fno-stack-protector \
--target=bpf -c $< -o $@
@@ -232,7 +226,7 @@
@@ -243,7 +237,7 @@

CFLAGS += $(if $(BUILD_BPF_SKELS),,-DBPFTOOL_WITHOUT_SKELETONS)

Expand All @@ -107,7 +102,7 @@
$(QUIET_CC)$(CC) $(CFLAGS) -c -MMD $< -o $@

$(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP)
@@ -251,7 +245,7 @@
@@ -262,7 +256,7 @@
$(call QUIET_CLEAN, feature-detect)
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null

Expand All @@ -116,7 +111,7 @@
$(call QUIET_CLEAN, bpftool)
$(Q)$(RM) -- $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
$(Q)$(RM) -- $(OUTPUT)*.skel.h $(OUTPUT)vmlinux.h
@@ -267,7 +261,7 @@
@@ -278,7 +272,7 @@

install: install-bin
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
Expand All @@ -125,7 +120,7 @@

uninstall:
$(call QUIET_UNINST, bpftool)
@@ -275,16 +269,16 @@
@@ -286,16 +280,16 @@
$(Q)$(RM) -- $(DESTDIR)$(bash_compdir)/bpftool

doc:
Expand Down
13 changes: 6 additions & 7 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
endif

ifeq ($(V),1)
Q =
else
Q = @
endif

BPF_DIR = $(srctree)/libbpf/src

ifneq ($(OUTPUT),)
Expand Down Expand Up @@ -69,7 +63,12 @@ prefix ?= /usr/local
bash_compdir ?= /usr/share/bash-completion/completions

CFLAGS += -O2
CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
CFLAGS += -W
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Wformat-signedness
CFLAGS += -Wno-unused-parameter
CFLAGS += -Wno-missing-field-initializers
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(or $(OUTPUT),.) \
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ EXTRA_WARNINGS := \
-Wundef \
-Wwrite-strings \

ifeq ($(V),1)
Q =
else
Q = @
endif

define descend
mkdir -p $(OUTPUT)$(1) && \
$(MAKE) --no-print-directory -C $(1) $(2)
Expand Down
14 changes: 7 additions & 7 deletions src/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
if (btf_kflag(t))
printf("\n\t'%s' val=%d", name, v->val);
else
printf("\n\t'%s' val=%u", name, v->val);
printf("\n\t'%s' val=%u", name, (__u32)v->val);
}
}
if (json_output)
Expand Down Expand Up @@ -1022,7 +1022,7 @@ static int do_dump(int argc, char **argv)
for (i = 0; i < root_type_cnt; i++) {
if (root_type_ids[i] == root_id) {
err = -EINVAL;
p_err("duplicate root_id %d supplied", root_id);
p_err("duplicate root_id %u supplied", root_id);
goto done;
}
}
Expand Down Expand Up @@ -1132,7 +1132,7 @@ build_btf_type_table(struct hashmap *tab, enum bpf_obj_type type,
break;
default:
err = -1;
p_err("unexpected object type: %d", type);
p_err("unexpected object type: %u", type);
goto err_free;
}
if (err) {
Expand All @@ -1155,7 +1155,7 @@ build_btf_type_table(struct hashmap *tab, enum bpf_obj_type type,
break;
default:
err = -1;
p_err("unexpected object type: %d", type);
p_err("unexpected object type: %u", type);
goto err_free;
}
if (fd < 0) {
Expand Down Expand Up @@ -1188,7 +1188,7 @@ build_btf_type_table(struct hashmap *tab, enum bpf_obj_type type,
break;
default:
err = -1;
p_err("unexpected object type: %d", type);
p_err("unexpected object type: %u", type);
goto err_free;
}
if (!btf_id)
Expand Down Expand Up @@ -1254,12 +1254,12 @@ show_btf_plain(struct bpf_btf_info *info, int fd,

n = 0;
hashmap__for_each_key_entry(btf_prog_table, entry, info->id) {
printf("%s%lu", n++ == 0 ? " prog_ids " : ",", entry->value);
printf("%s%lu", n++ == 0 ? " prog_ids " : ",", (unsigned long)entry->value);
}

n = 0;
hashmap__for_each_key_entry(btf_map_table, entry, info->id) {
printf("%s%lu", n++ == 0 ? " map_ids " : ",", entry->value);
printf("%s%lu", n++ == 0 ? " map_ids " : ",", (unsigned long)entry->value);
}

emit_obj_refs_plain(refs_table, info->id, "\n\tpids ");
Expand Down
2 changes: 1 addition & 1 deletion src/btf_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id,
case BTF_KIND_ARRAY:
array = (struct btf_array *)(t + 1);
BTF_PRINT_TYPE(array->type);
BTF_PRINT_ARG("[%d]", array->nelems);
BTF_PRINT_ARG("[%u]", array->nelems);
break;
case BTF_KIND_PTR:
BTF_PRINT_TYPE(t->type);
Expand Down
2 changes: 1 addition & 1 deletion src/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int show_bpf_prog(int id, enum bpf_attach_type attach_type,
if (attach_btf_name)
printf(" %-15s", attach_btf_name);
else if (info.attach_btf_id)
printf(" attach_btf_obj_id=%d attach_btf_id=%d",
printf(" attach_btf_obj_id=%u attach_btf_id=%u",
info.attach_btf_obj_id, info.attach_btf_id);
printf("\n");
}
Expand Down
4 changes: 2 additions & 2 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ ifindex_to_arch(__u32 ifindex, __u64 ns_dev, __u64 ns_ino, const char **opt)
int vendor_id;

if (!ifindex_to_name_ns(ifindex, ns_dev, ns_ino, devname)) {
p_err("Can't get net device name for ifindex %d: %s", ifindex,
p_err("Can't get net device name for ifindex %u: %s", ifindex,
strerror(errno));
return NULL;
}
Expand All @@ -739,7 +739,7 @@ ifindex_to_arch(__u32 ifindex, __u64 ns_dev, __u64 ns_ino, const char **opt)
/* No NFP support in LLVM, we have no valid triple to return. */
default:
p_err("Can't get arch name for device vendor id 0x%04x",
vendor_id);
(unsigned int)vendor_id);
return NULL;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ int disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
{
const struct bpf_line_info *linfo = NULL;
unsigned int nr_skip = 0;
int count, i, pc = 0;
int count, i;
unsigned int pc = 0;
disasm_ctx_t ctx;

if (!len)
Expand Down
16 changes: 14 additions & 2 deletions src/kernel/bpf/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
insn->dst_reg, class == BPF_ALU ? 'w' : 'r',
insn->dst_reg);
} else if (is_addr_space_cast(insn)) {
verbose(cbs->private_data, "(%02x) r%d = addr_space_cast(r%d, %d, %d)\n",
verbose(cbs->private_data, "(%02x) r%d = addr_space_cast(r%d, %u, %u)\n",
insn->code, insn->dst_reg,
insn->src_reg, ((u32)insn->imm) >> 16, (u16)insn->imm);
} else if (is_mov_percpu_addr(insn)) {
Expand Down Expand Up @@ -267,6 +267,18 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
insn->dst_reg, insn->off, insn->src_reg);
} else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
insn->imm == BPF_LOAD_ACQ) {
verbose(cbs->private_data, "(%02x) r%d = load_acquire((%s *)(r%d %+d))\n",
insn->code, insn->dst_reg,
bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
insn->src_reg, insn->off);
} else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
insn->imm == BPF_STORE_REL) {
verbose(cbs->private_data, "(%02x) store_release((%s *)(r%d %+d), r%d)\n",
insn->code,
bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
insn->dst_reg, insn->off, insn->src_reg);
} else {
verbose(cbs->private_data, "BUG_%02x\n", insn->code);
}
Expand Down Expand Up @@ -369,7 +381,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
insn->code, class == BPF_JMP32 ? 'w' : 'r',
insn->dst_reg,
bpf_jmp_string[BPF_OP(insn->code) >> 4],
insn->imm, insn->off);
(u32)insn->imm, insn->off);
}
} else {
verbose(cbs->private_data, "(%02x) %s\n",
Expand Down
6 changes: 3 additions & 3 deletions src/map_perf_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ print_bpf_output(void *private_data, int cpu, struct perf_event_header *event)
jsonw_end_object(json_wtr);
} else {
if (e->header.type == PERF_RECORD_SAMPLE) {
printf("== @%lld.%09lld CPU: %d index: %d =====\n",
printf("== @%llu.%09llu CPU: %d index: %d =====\n",
e->time / 1000000000ULL, e->time % 1000000000ULL,
cpu, idx);
fprint_hex(stdout, e->data, e->size, " ");
printf("\n");
} else if (e->header.type == PERF_RECORD_LOST) {
printf("lost %lld events\n", lost->lost);
printf("lost %llu events\n", lost->lost);
} else {
printf("unknown event type=%d size=%d\n",
printf("unknown event type=%u size=%u\n",
e->header.type, e->header.size);
}
}
Expand Down
Loading
Loading