mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
af_unix: Move CINQ/COUTQ code to helpers
Currently tcp diag reports rqlen and wqlen values similar to how the CINQ/COUTQ iotcls do. To make unix diag report these values in the same way move the respective code into helpers. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
257b529876
commit
885ee74d5d
2 changed files with 39 additions and 23 deletions
|
@ -66,6 +66,9 @@ struct unix_sock {
|
||||||
|
|
||||||
#define peer_wait peer_wq.wait
|
#define peer_wait peer_wq.wait
|
||||||
|
|
||||||
|
long unix_inq_len(struct sock *sk);
|
||||||
|
long unix_outq_len(struct sock *sk);
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL
|
#ifdef CONFIG_SYSCTL
|
||||||
extern int unix_sysctl_register(struct net *net);
|
extern int unix_sysctl_register(struct net *net);
|
||||||
extern void unix_sysctl_unregister(struct net *net);
|
extern void unix_sysctl_unregister(struct net *net);
|
||||||
|
|
|
@ -2065,25 +2065,13 @@ static int unix_shutdown(struct socket *sock, int mode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
long unix_inq_len(struct sock *sk)
|
||||||
{
|
|
||||||
struct sock *sk = sock->sk;
|
|
||||||
long amount = 0;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
switch (cmd) {
|
|
||||||
case SIOCOUTQ:
|
|
||||||
amount = sk_wmem_alloc_get(sk);
|
|
||||||
err = put_user(amount, (int __user *)arg);
|
|
||||||
break;
|
|
||||||
case SIOCINQ:
|
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
long amount = 0;
|
||||||
|
|
||||||
if (sk->sk_state == TCP_LISTEN) {
|
if (sk->sk_state == TCP_LISTEN)
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock(&sk->sk_receive_queue.lock);
|
spin_lock(&sk->sk_receive_queue.lock);
|
||||||
if (sk->sk_type == SOCK_STREAM ||
|
if (sk->sk_type == SOCK_STREAM ||
|
||||||
|
@ -2096,10 +2084,35 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||||
amount = skb->len;
|
amount = skb->len;
|
||||||
}
|
}
|
||||||
spin_unlock(&sk->sk_receive_queue.lock);
|
spin_unlock(&sk->sk_receive_queue.lock);
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(unix_inq_len);
|
||||||
|
|
||||||
|
long unix_outq_len(struct sock *sk)
|
||||||
|
{
|
||||||
|
return sk_wmem_alloc_get(sk);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(unix_outq_len);
|
||||||
|
|
||||||
|
static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||||
|
{
|
||||||
|
struct sock *sk = sock->sk;
|
||||||
|
long amount = 0;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SIOCOUTQ:
|
||||||
|
amount = unix_outq_len(sk);
|
||||||
|
err = put_user(amount, (int __user *)arg);
|
||||||
|
break;
|
||||||
|
case SIOCINQ:
|
||||||
|
amount = unix_inq_len(sk);
|
||||||
|
if (amount < 0)
|
||||||
|
err = amount;
|
||||||
|
else
|
||||||
err = put_user(amount, (int __user *)arg);
|
err = put_user(amount, (int __user *)arg);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = -ENOIOCTLCMD;
|
err = -ENOIOCTLCMD;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue