Skip to content

Commit

Permalink
espintcp: Inline do_tcp_sendpages()
Browse files Browse the repository at this point in the history
do_tcp_sendpages() is now just a small wrapper around tcp_sendmsg_locked(),
so inline it, allowing do_tcp_sendpages() to be removed.  This is part of
replacing ->sendpage() with a call to sendmsg() with MSG_SPLICE_PAGES set.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steffen Klassert <steffen.klassert@secunet.com>
cc: Herbert Xu <herbert@gondor.apana.org.au>
cc: David Ahern <dsahern@kernel.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
David Howells authored and Jakub Kicinski committed May 24, 2023
1 parent ebf2e88 commit 7f8816a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/xfrm/espintcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,30 @@ static int espintcp_sendskb_locked(struct sock *sk, struct espintcp_msg *emsg,
static int espintcp_sendskmsg_locked(struct sock *sk,
struct espintcp_msg *emsg, int flags)
{
struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, };
struct sk_msg *skmsg = &emsg->skmsg;
struct scatterlist *sg;
int done = 0;
int ret;

flags |= MSG_SENDPAGE_NOTLAST;
msghdr.msg_flags |= MSG_SENDPAGE_NOTLAST;
sg = &skmsg->sg.data[skmsg->sg.start];
do {
struct bio_vec bvec;
size_t size = sg->length - emsg->offset;
int offset = sg->offset + emsg->offset;
struct page *p;

emsg->offset = 0;

if (sg_is_last(sg))
flags &= ~MSG_SENDPAGE_NOTLAST;
msghdr.msg_flags &= ~MSG_SENDPAGE_NOTLAST;

p = sg_page(sg);
retry:
ret = do_tcp_sendpages(sk, p, offset, size, flags);
bvec_set_page(&bvec, p, size, offset);
iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size);
ret = tcp_sendmsg_locked(sk, &msghdr, size);
if (ret < 0) {
emsg->offset = offset - sg->offset;
skmsg->sg.start += done;
Expand Down

0 comments on commit 7f8816a

Please sign in to comment.