Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 67065
b: refs/heads/master
c: aed8156
h: refs/heads/master
i:
  67063: 23dcd25
v: v3
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Oct 11, 2007
1 parent 1e59d71 commit 96f34b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7ee015e0fa3c856416e9477aac4b850ec6f09017
refs/heads/master: aed815601f3f95281ab3a01f7e2cbe1bd54285a0
13 changes: 9 additions & 4 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ static inline struct netlink_sock *nlk_sk(struct sock *sk)
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;
Expand Down Expand Up @@ -489,7 +494,7 @@ static int netlink_release(struct socket *sock)
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;
Expand Down Expand Up @@ -716,7 +721,7 @@ static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid)

/* 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);
Expand Down Expand Up @@ -762,7 +767,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
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);
Expand Down Expand Up @@ -861,7 +866,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group)
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);
Expand Down

0 comments on commit 96f34b5

Please sign in to comment.