Commit d976092c authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

mptcp: implement MSG_TRUNC support

The mentioned flag is currently silenlty ignored. This
change implements the TCP-like behaviour, dropping the
pending data up to the specified length.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Sigend-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb9d80f4
...@@ -1739,7 +1739,7 @@ static void mptcp_wait_data(struct sock *sk, long *timeo) ...@@ -1739,7 +1739,7 @@ static void mptcp_wait_data(struct sock *sk, long *timeo)
static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk, static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
struct msghdr *msg, struct msghdr *msg,
size_t len) size_t len, int flags)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int copied = 0; int copied = 0;
...@@ -1750,12 +1750,14 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk, ...@@ -1750,12 +1750,14 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
u32 count = min_t(size_t, len - copied, data_len); u32 count = min_t(size_t, len - copied, data_len);
int err; int err;
if (!(flags & MSG_TRUNC)) {
err = skb_copy_datagram_msg(skb, offset, msg, count); err = skb_copy_datagram_msg(skb, offset, msg, count);
if (unlikely(err < 0)) { if (unlikely(err < 0)) {
if (!copied) if (!copied)
return err; return err;
break; break;
} }
}
copied += count; copied += count;
...@@ -1966,7 +1968,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -1966,7 +1968,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
while (copied < len) { while (copied < len) {
int bytes_read; int bytes_read;
bytes_read = __mptcp_recvmsg_mskq(msk, msg, len - copied); bytes_read = __mptcp_recvmsg_mskq(msk, msg, len - copied, flags);
if (unlikely(bytes_read < 0)) { if (unlikely(bytes_read < 0)) {
if (!copied) if (!copied)
copied = bytes_read; copied = bytes_read;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment