]> git.hungrycats.org Git - linux/commitdiff
[AF_UNIX]: Fix SIOCINQ for STREAM and SEQPACKET.
authorDavid S. Miller <davem@nuts.davemloft.net>
Sun, 27 Feb 2005 03:15:10 +0000 (19:15 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sun, 27 Feb 2005 03:15:10 +0000 (19:15 -0800)
We should report the total bytes in the whole receive
queue, not just the first packet, in these cases.

Reported by Uwe Bonnes.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c

index 062bcc2080a70954974ef599c726e602b0c4e520..5658798cabc1daa7bac39e74b1bcb3ac02c748bb 100644 (file)
@@ -1850,15 +1850,22 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                case SIOCINQ:
                {
                        struct sk_buff *skb;
+
                        if (sk->sk_state == TCP_LISTEN) {
                                err = -EINVAL;
                                break;
                        }
 
                        spin_lock(&sk->sk_receive_queue.lock);
-                       skb = skb_peek(&sk->sk_receive_queue);
-                       if (skb)
-                               amount=skb->len;
+                       if (sk->sk_type == SOCK_STREAM ||
+                           sk->sk_type == SOCK_SEQPACKET) {
+                               skb_queue_walk(&sk->sk_receive_queue, skb)
+                                       amount += skb->len;
+                       } else {
+                               skb = skb_peek(&sk->sk_receive_queue);
+                               if (skb)
+                                       amount=skb->len;
+                       }
                        spin_unlock(&sk->sk_receive_queue.lock);
                        err = put_user(amount, (int __user *)arg);
                        break;