Commit df9e03ae authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller

selftests: mptcp: make sendfile selftest work

When the selftest got added, sendfile() on mptcp sockets returned
-EOPNOTSUPP, so running 'mptcp_connect.sh -m sendfile' failed
immediately.

This is no longer the case, but the script fails anyway due to timeout.
Let the receiver know once the sender has sent all data, just like
with '-m mmap' mode.

v2: need to respect cfg_wait too, as pm_userspace.sh relied
on -m sendfile to keep the connection open (Mat Martineau)

Fixes: 048d19d4 ("mptcp: add basic kselftest for mptcp")
Reported-by: default avatarXiumei Mu <xmu@redhat.com>
Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c886d702
...@@ -553,6 +553,18 @@ static void set_nonblock(int fd, bool nonblock) ...@@ -553,6 +553,18 @@ static void set_nonblock(int fd, bool nonblock)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
} }
static void shut_wr(int fd)
{
/* Close our write side, ev. give some time
* for address notification and/or checking
* the current status
*/
if (cfg_wait)
usleep(cfg_wait);
shutdown(fd, SHUT_WR);
}
static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out) static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out)
{ {
struct pollfd fds = { struct pollfd fds = {
...@@ -630,14 +642,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after ...@@ -630,14 +642,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after
/* ... and peer also closed already */ /* ... and peer also closed already */
break; break;
/* ... but we still receive. shut_wr(peerfd);
* Close our write side, ev. give some time
* for address notification and/or checking
* the current status
*/
if (cfg_wait)
usleep(cfg_wait);
shutdown(peerfd, SHUT_WR);
} else { } else {
if (errno == EINTR) if (errno == EINTR)
continue; continue;
...@@ -767,7 +772,7 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd, ...@@ -767,7 +772,7 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd,
if (err) if (err)
return err; return err;
shutdown(peerfd, SHUT_WR); shut_wr(peerfd);
err = do_recvfile(peerfd, outfd); err = do_recvfile(peerfd, outfd);
*in_closed_after_out = true; *in_closed_after_out = true;
...@@ -791,6 +796,9 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd, ...@@ -791,6 +796,9 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd,
err = do_sendfile(infd, peerfd, size); err = do_sendfile(infd, peerfd, size);
if (err) if (err)
return err; return err;
shut_wr(peerfd);
err = do_recvfile(peerfd, outfd); err = do_recvfile(peerfd, outfd);
*in_closed_after_out = true; *in_closed_after_out = true;
} }
......
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