diff options
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index a40bc8c0af4b..4cf7e2279480 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -67,8 +67,8 @@ #include <linux/atomic.h> #include <net/dst.h> #include <net/checksum.h> -#include <net/tcp_states.h> #include <linux/net_tstamp.h> +#include <net/tcp_states.h> struct cgroup; struct cgroup_subsys; @@ -423,6 +423,7 @@ struct sock { void *sk_security; #endif __u32 sk_mark; + kuid_t sk_uid; u32 sk_classid; struct cg_proto *sk_cgrp; void (*sk_state_change)(struct sock *sk); @@ -1060,6 +1061,7 @@ struct proto { void (*destroy_cgroup)(struct mem_cgroup *memcg); struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); #endif + int (*diag_destroy)(struct sock *sk, int err); }; /* @@ -1736,6 +1738,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) sk->sk_wq = parent->wq; parent->sk = sk; sk_set_socket(sk, parent); + sk->sk_uid = SOCK_INODE(parent)->i_uid; security_sock_graft(sk, parent); write_unlock_bh(&sk->sk_callback_lock); } @@ -1743,6 +1746,11 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) kuid_t sock_i_uid(struct sock *sk); unsigned long sock_i_ino(struct sock *sk); +static inline kuid_t sock_net_uid(const struct net *net, const struct sock *sk) +{ + return sk ? sk->sk_uid : make_kuid(net->user_ns, 0); +} + static inline struct dst_entry * __sk_dst_get(struct sock *sk) { @@ -2281,10 +2289,11 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb) /* This helper checks if a socket is a full socket, * ie _not_ a timewait or request socket. + * TODO: Check for TCPF_NEW_SYN_RECV when that starts to exist. */ static inline bool sk_fullsock(const struct sock *sk) { - return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV); + return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT); } void sock_enable_timestamp(struct sock *sk, int flag); |