OSDN Git Service

Merge 4.4.161 into android-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / net / sock.h
index 5770757..5b1a715 100644 (file)
@@ -446,6 +446,7 @@ struct sock {
        void                    *sk_security;
 #endif
        __u32                   sk_mark;
+       kuid_t                  sk_uid;
 #ifdef CONFIG_CGROUP_NET_CLASSID
        u32                     sk_classid;
 #endif
@@ -1067,6 +1068,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);
 };
 
 int proto_register(struct proto *prot, int alloc_slab);
@@ -1691,6 +1693,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);
 }
@@ -1698,6 +1701,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 u32 net_tx_rndhash(void)
 {
        u32 v = prandom_u32();