Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 454bfe97 authored by David S. Miller's avatar David S. Miller
Browse files


Daniel Borkmann says:

====================
pull-request: bpf-next 2018-03-21

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) Add a BPF hook for sendmsg and sendfile by reusing the ULP infrastructure
   and sockmap. Three helpers are added along with this, bpf_msg_apply_bytes(),
   bpf_msg_cork_bytes(), and bpf_msg_pull_data(). The first is used to tell
   for how many bytes the verdict should be applied to, the second to tell
   that x bytes need to be queued first to retrigger the BPF program for a
   verdict, and the third helper is mainly for the sendfile case to pull in
   data for making it private for reading and/or writing, from John.

2) Improve address to symbol resolution of user stack traces in BPF stackmap.
   Currently, the latter stores the address for each entry in the call trace,
   however to map these addresses to user space files, it is necessary to
   maintain the mapping from these virtual addresses to symbols in the binary
   which is not practical for system-wide profiling. Instead, this option for
   the stackmap rather stores the ELF build id and offset for the call trace
   entries, from Song.

3) Add support that allows BPF programs attached to perf events to read the
   address values recorded with the perf events. They are requested through
   PERF_SAMPLE_ADDR via perf_event_open(). Main motivation behind it is to
   support building memory or lock access profiling and tracing tools with
   the help of BPF, from Teng.

4) Several improvements to the tools/bpf/ Makefiles. The 'make bpf' in the
   tools directory does not provide the standard quiet output except for
   bpftool and it also does not respect specifying a build output directory.
   'make bpf_install' command neither respects specified destination nor
   prefix, all from Jiri. In addition, Jakub fixes several other minor issues
   in the Makefiles on top of that, e.g. fixing dependency paths, phony
   targets and more.

5) Various doc updates e.g. add a comment for BPF fs about reserved names
   to make the dentry lookup from there a bit more obvious, and a comment
   to the bpf_devel_QA file in order to explain the diff between native
   and bpf target clang usage with regards to pointer size, from Quentin
   and Daniel.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0466080c 78262f45
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -539,6 +539,18 @@ A: Although LLVM IR generation and optimization try to stay architecture
       The clang option "-fno-jump-tables" can be used to disable
       switch table generation.

     - For clang -target bpf, it is guaranteed that pointer or long /
       unsigned long types will always have a width of 64 bit, no matter
       whether underlying clang binary or default target (or kernel) is
       32 bit. However, when native clang target is used, then it will
       compile these types based on the underlying architecture's conventions,
       meaning in case of 32 bit architecture, pointer or long / unsigned
       long types e.g. in BPF context structure will have width of 32 bit
       while the BPF LLVM back end still operates in 64 bit. The native
       target is mostly needed in tracing for the case of walking pt_regs
       or other kernel structures where CPU's register width matters.
       Otherwise, clang -target bpf is generally recommended.

   You should use default target when:

     - Your program includes a header file, e.g., ptrace.h, which eventually
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ struct bpf_verifier_env;
struct perf_event;
struct bpf_prog;
struct bpf_map;
struct sock;

/* map is generic key/value storage optionally accesible by eBPF programs */
struct bpf_map_ops {
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_OUT, lwt_inout)
BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_XMIT, lwt_xmit)
BPF_PROG_TYPE(BPF_PROG_TYPE_SOCK_OPS, sock_ops)
BPF_PROG_TYPE(BPF_PROG_TYPE_SK_SKB, sk_skb)
BPF_PROG_TYPE(BPF_PROG_TYPE_SK_MSG, sk_msg)
#endif
#ifdef CONFIG_BPF_EVENTS
BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe)
+17 −0
Original line number Diff line number Diff line
@@ -507,6 +507,22 @@ struct xdp_buff {
	struct xdp_rxq_info *rxq;
};

struct sk_msg_buff {
	void *data;
	void *data_end;
	__u32 apply_bytes;
	__u32 cork_bytes;
	int sg_copybreak;
	int sg_start;
	int sg_curr;
	int sg_end;
	struct scatterlist sg_data[MAX_SKB_FRAGS];
	bool sg_copy[MAX_SKB_FRAGS];
	__u32 key;
	__u32 flags;
	struct bpf_map *map;
};

/* Compute the linear packet data range [data, data_end) which
 * will be accessed by various program types (cls_bpf, act_bpf,
 * lwt, ...). Subsystems allowing direct data access must (!)
@@ -771,6 +787,7 @@ xdp_data_meta_unsupported(const struct xdp_buff *xdp)
void bpf_warn_invalid_xdp_action(u32 act);

struct sock *do_sk_redirect_map(struct sk_buff *skb);
struct sock *do_msg_redirect_map(struct sk_msg_buff *md);

#ifdef CONFIG_BPF_JIT
extern int bpf_jit_enable;
+1 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@ struct ucred {
#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
#define MSG_BATCH	0x40000 /* sendmmsg(): more messages coming */
#define MSG_EOF         MSG_FIN
#define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */

#define MSG_ZEROCOPY	0x4000000	/* Use user data in kernel path */
#define MSG_FASTOPEN	0x20000000	/* Send data in TCP SYN */
Loading