Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 135523
b: refs/heads/master
c: 38938bf
h: refs/heads/master
i:
  135521: 55540c2
  135519: 52c33fd
v: v3
  • Loading branch information
Pablo Neira Ayuso authored and David S. Miller committed Mar 24, 2009
1 parent d146031 commit f2e5e55
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 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: 7f649269c318c41030e492fc35f03d38c6e3b39b
refs/heads/master: 38938bfe3489394e2eed5e40c9bb8f66a2ce1405
1 change: 1 addition & 0 deletions trunk/include/linux/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct nlmsgerr
#define NETLINK_DROP_MEMBERSHIP 2
#define NETLINK_PKTINFO 3
#define NETLINK_BROADCAST_ERROR 4
#define NETLINK_NO_ENOBUFS 5

struct nl_pktinfo
{
Expand Down
38 changes: 32 additions & 6 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct netlink_sock {
#define NETLINK_KERNEL_SOCKET 0x1
#define NETLINK_RECV_PKTINFO 0x2
#define NETLINK_BROADCAST_SEND_ERROR 0x4
#define NETLINK_RECV_NO_ENOBUFS 0x8

static inline struct netlink_sock *nlk_sk(struct sock *sk)
{
Expand Down Expand Up @@ -717,10 +718,15 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr,

static void netlink_overrun(struct sock *sk)
{
if (!test_and_set_bit(0, &nlk_sk(sk)->state)) {
sk->sk_err = ENOBUFS;
sk->sk_error_report(sk);
struct netlink_sock *nlk = nlk_sk(sk);

if (!(nlk->flags & NETLINK_RECV_NO_ENOBUFS)) {
if (!test_and_set_bit(0, &nlk_sk(sk)->state)) {
sk->sk_err = ENOBUFS;
sk->sk_error_report(sk);
}
}
atomic_inc(&sk->sk_drops);
}

static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid)
Expand Down Expand Up @@ -1182,6 +1188,15 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
nlk->flags &= ~NETLINK_BROADCAST_SEND_ERROR;
err = 0;
break;
case NETLINK_NO_ENOBUFS:
if (val) {
nlk->flags |= NETLINK_RECV_NO_ENOBUFS;
clear_bit(0, &nlk->state);
wake_up_interruptible(&nlk->wait);
} else
nlk->flags &= ~NETLINK_RECV_NO_ENOBUFS;
err = 0;
break;
default:
err = -ENOPROTOOPT;
}
Expand Down Expand Up @@ -1224,6 +1239,16 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
return -EFAULT;
err = 0;
break;
case NETLINK_NO_ENOBUFS:
if (len < sizeof(int))
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_RECV_NO_ENOBUFS ? 1 : 0;
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
default:
err = -ENOPROTOOPT;
}
Expand Down Expand Up @@ -1879,20 +1904,21 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
if (v == SEQ_START_TOKEN)
seq_puts(seq,
"sk Eth Pid Groups "
"Rmem Wmem Dump Locks\n");
"Rmem Wmem Dump Locks Drops\n");
else {
struct sock *s = v;
struct netlink_sock *nlk = nlk_sk(s);

seq_printf(seq, "%p %-3d %-6d %08x %-8d %-8d %p %d\n",
seq_printf(seq, "%p %-3d %-6d %08x %-8d %-8d %p %-8d %-8d\n",
s,
s->sk_protocol,
nlk->pid,
nlk->groups ? (u32)nlk->groups[0] : 0,
atomic_read(&s->sk_rmem_alloc),
atomic_read(&s->sk_wmem_alloc),
nlk->cb,
atomic_read(&s->sk_refcnt)
atomic_read(&s->sk_refcnt),
atomic_read(&s->sk_drops)
);

}
Expand Down

0 comments on commit f2e5e55

Please sign in to comment.