Files
android_kernel_xiaomi_sm8450/include/uapi/linux
Martin KaFai Lau 655a51e536 bpf: Add struct bpf_tcp_sock and BPF_FUNC_tcp_sock
This patch adds a helper function BPF_FUNC_tcp_sock and it
is currently available for cg_skb and sched_(cls|act):

struct bpf_tcp_sock *bpf_tcp_sock(struct bpf_sock *sk);

int cg_skb_foo(struct __sk_buff *skb) {
	struct bpf_tcp_sock *tp;
	struct bpf_sock *sk;
	__u32 snd_cwnd;

	sk = skb->sk;
	if (!sk)
		return 1;

	tp = bpf_tcp_sock(sk);
	if (!tp)
		return 1;

	snd_cwnd = tp->snd_cwnd;
	/* ... */

	return 1;
}

A 'struct bpf_tcp_sock' is also added to the uapi bpf.h to provide
read-only access.  bpf_tcp_sock has all the existing tcp_sock's fields
that has already been exposed by the bpf_sock_ops.
i.e. no new tcp_sock's fields are exposed in bpf.h.

This helper returns a pointer to the tcp_sock.  If it is not a tcp_sock
or it cannot be traced back to a tcp_sock by sk_to_full_sk(), it
returns NULL.  Hence, the caller needs to check for NULL before
accessing it.

The current use case is to expose members from tcp_sock
to allow a cg_skb_bpf_prog to provide per cgroup traffic
policing/shaping.

Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-02-10 19:46:17 -08:00
..
2018-07-23 19:18:10 +01:00
2019-01-07 08:45:47 -08:00
2019-01-24 11:11:42 -07:00
2019-02-03 11:17:31 -08:00
2018-11-17 20:33:32 -08:00
2018-12-20 19:13:07 +01:00
2018-06-18 15:11:53 +10:00
2018-10-15 15:43:07 +02:00
2018-09-13 10:46:24 +02:00
2018-09-05 22:27:11 -07:00
2018-11-30 17:16:38 -08:00
2018-07-07 17:41:38 +02:00
2018-08-03 10:03:57 -07:00
2017-11-28 16:54:00 +01:00
2018-12-19 09:40:13 +01:00
2018-04-11 10:28:37 -07:00
2018-10-17 13:56:58 -07:00
2018-12-16 12:15:25 -08:00
2018-12-01 12:38:32 +01:00
2018-01-14 23:06:30 -05:00
2018-01-16 16:47:29 +01:00
2018-02-06 22:53:56 +00:00
2018-05-31 00:13:56 +08:00
2018-03-20 03:17:41 +02:00
2018-04-14 11:59:31 -04:00
2017-11-24 10:18:41 +00:00
2017-11-16 10:49:00 +09:00
2018-04-11 10:28:37 -07:00
2019-02-01 15:00:55 -08:00
2018-09-03 13:29:38 +02:00
2018-02-06 18:32:44 -08:00
2016-12-16 00:13:32 +02:00