bpf: Add support for reading socket family, type, protocol

Add socket family, type and protocol to bpf_sock allowing bpf programs
read-only access.

Add __sk_flags_offset[0] to struct sock before the bitfield to
programmtically determine the offset of the unsigned int containing
protocol and type.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David Ahern
2016-12-01 08:48:06 -08:00
committed by David S. Miller
parent ad2805dc79
commit aa4c1037a3
3 changed files with 39 additions and 0 deletions

View File

@@ -571,6 +571,9 @@ enum bpf_ret_code {
struct bpf_sock {
__u32 bound_dev_if;
__u32 family;
__u32 type;
__u32 protocol;
};
/* User return codes for XDP prog type.