]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/sctp/socket.c
sctp: Fix break indentation in sctp_ioctl().
[net-next-2.6.git] / net / sctp / socket.c
index cf6dcc908b88366d763ef5f3577722ae54c65d76..d4bf2a78cb8a2ce4b8742243511307862f6604f5 100644 (file)
@@ -3592,7 +3592,40 @@ out:
 /* The SCTP ioctl handler. */
 SCTP_STATIC int sctp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 {
-       return -ENOIOCTLCMD;
+       int rc = -ENOTCONN;
+
+       sctp_lock_sock(sk);
+
+       /*
+        * SEQPACKET-style sockets in LISTENING state are valid, for
+        * SCTP, so only discard TCP-style sockets in LISTENING state.
+        */
+       if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
+               goto out;
+
+       switch (cmd) {
+       case SIOCINQ: {
+               struct sk_buff *skb;
+               unsigned int amount = 0;
+
+               skb = skb_peek(&sk->sk_receive_queue);
+               if (skb != NULL) {
+                       /*
+                        * We will only return the amount of this packet since
+                        * that is all that will be read.
+                        */
+                       amount = skb->len;
+               }
+               rc = put_user(amount, (int __user *)arg);
+               break;
+       }
+       default:
+               rc = -ENOIOCTLCMD;
+               break;
+       }
+out:
+       sctp_release_sock(sk);
+       return rc;
 }
 
 /* This is the function which gets called during socket creation to
@@ -3851,7 +3884,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len,
        }
 
 out:
-       return (retval);
+       return retval;
 }
 
 
@@ -3907,7 +3940,7 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len,
        }
 
 out:
-       return (retval);
+       return retval;
 }
 
 /* 7.1.12 Enable/Disable message fragmentation (SCTP_DISABLE_FRAGMENTS)
@@ -5561,7 +5594,7 @@ static int sctp_get_port(struct sock *sk, unsigned short snum)
        /* Note: sk->sk_num gets filled in if ephemeral port request. */
        ret = sctp_get_port_local(sk, &addr);
 
-       return (ret ? 1 : 0);
+       return ret ? 1 : 0;
 }
 
 /*