switch sctp_user_addto_chunk() and sctp_datamsg_from_user() to passing iov_iter
[cascardo/linux.git] / net / sctp / socket.c
index 634a2ab..0397ac9 100644 (file)
@@ -162,7 +162,7 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)
 
        chunk->skb->destructor = sctp_wfree;
        /* Save the chunk pointer in skb for sctp_wfree to use later.  */
-       *((struct sctp_chunk **)(chunk->skb->cb)) = chunk;
+       skb_shinfo(chunk->skb)->destructor_arg = chunk;
 
        asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) +
                                sizeof(struct sk_buff) +
@@ -1609,6 +1609,9 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
        __u16 sinfo_flags = 0;
        long timeo;
        int err;
+       struct iov_iter from;
+
+       iov_iter_init(&from, WRITE, msg->msg_iov, msg->msg_iovlen, msg_len);
 
        err = 0;
        sp = sctp_sk(sk);
@@ -1947,7 +1950,7 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
        }
 
        /* Break the message into multiple chunks of maximum size. */
-       datamsg = sctp_datamsg_from_user(asoc, sinfo, msg, msg_len);
+       datamsg = sctp_datamsg_from_user(asoc, sinfo, &from);
        if (IS_ERR(datamsg)) {
                err = PTR_ERR(datamsg);
                goto out_free;
@@ -2095,7 +2098,7 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
        if (copied > len)
                copied = len;
 
-       err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+       err = skb_copy_datagram_msg(skb, 0, msg, copied);
 
        event = sctp_skb2event(skb);
 
@@ -6870,14 +6873,10 @@ static void sctp_wake_up_waiters(struct sock *sk,
  */
 static void sctp_wfree(struct sk_buff *skb)
 {
-       struct sctp_association *asoc;
-       struct sctp_chunk *chunk;
-       struct sock *sk;
+       struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
+       struct sctp_association *asoc = chunk->asoc;
+       struct sock *sk = asoc->base.sk;
 
-       /* Get the saved chunk pointer.  */
-       chunk = *((struct sctp_chunk **)(skb->cb));
-       asoc = chunk->asoc;
-       sk = asoc->base.sk;
        asoc->sndbuf_used -= SCTP_DATA_SNDSIZE(chunk) +
                                sizeof(struct sk_buff) +
                                sizeof(struct sctp_chunk);