diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2016-12-01 08:48:06 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-02 13:46:09 -0500 |
commit | aa4c1037a30f4e88f444e83d42c2befbe0d5caf5 (patch) | |
tree | e2bb34c401d93df49f035a1d45c01fdff44b371d /include/net/sock.h | |
parent | ad2805dc79e647ec2aee931a51924fda9d03b2fc (diff) | |
download | linux-aa4c1037a30f4e88f444e83d42c2befbe0d5caf5.tar.bz2 |
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>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 442cbb118a07..69afda6bea15 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -389,6 +389,21 @@ struct sock { * Because of non atomicity rules, all * changes are protected by socket lock. */ + unsigned int __sk_flags_offset[0]; +#ifdef __BIG_ENDIAN_BITFIELD +#define SK_FL_PROTO_SHIFT 16 +#define SK_FL_PROTO_MASK 0x00ff0000 + +#define SK_FL_TYPE_SHIFT 0 +#define SK_FL_TYPE_MASK 0x0000ffff +#else +#define SK_FL_PROTO_SHIFT 8 +#define SK_FL_PROTO_MASK 0x0000ff00 + +#define SK_FL_TYPE_SHIFT 16 +#define SK_FL_TYPE_MASK 0xffff0000 +#endif + kmemcheck_bitfield_begin(flags); unsigned int sk_padding : 2, sk_no_check_tx : 1, |