return container_of(sk, struct netlink_sock, sk);
 }
 
+static inline int netlink_is_kernel(struct sock *sk)
+{
+       return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET;
+}
+
 struct nl_pid_hash {
        struct hlist_head *table;
        unsigned long rehash_time;
        module_put(nlk->module);
 
        netlink_table_grab();
-       if (nlk->flags & NETLINK_KERNEL_SOCKET) {
+       if (netlink_is_kernel(sk)) {
                kfree(nl_table[sk->sk_protocol].listeners);
                nl_table[sk->sk_protocol].module = NULL;
                nl_table[sk->sk_protocol].registered = 0;
 
        /* Don't bother queuing skb if kernel socket has no input function */
        nlk = nlk_sk(sock);
-       if ((nlk->pid == 0 && !nlk->data_ready) ||
+       if ((netlink_is_kernel(sock) && !nlk->data_ready) ||
            (sock->sk_state == NETLINK_CONNECTED &&
             nlk->dst_pid != nlk_sk(ssk)->pid)) {
                sock_put(sock);
            test_bit(0, &nlk->state)) {
                DECLARE_WAITQUEUE(wait, current);
                if (!timeo) {
-                       if (!ssk || nlk_sk(ssk)->pid == 0)
+                       if (!ssk || netlink_is_kernel(ssk))
                                netlink_overrun(sk);
                        sock_put(sk);
                        kfree_skb(skb);
        int res = 0;
        unsigned long *listeners;
 
-       BUG_ON(!(nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET));
+       BUG_ON(!netlink_is_kernel(sk));
 
        rcu_read_lock();
        listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners);