netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: netdev@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Boris Pismenny <borisp@nvidia.com>,
	John Fastabend <john.fastabend@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	David Ahern <dsahern@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 11/14] tls/sw: Support MSG_SPLICE_PAGES
Date: Wed, 7 Jun 2023 10:19:45 -0700	[thread overview]
Message-ID: <20230607101945.65c5df51@kernel.org> (raw)
In-Reply-To: <20230607140559.2263470-12-dhowells@redhat.com>

On Wed,  7 Jun 2023 15:05:56 +0100 David Howells wrote:
> +static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg,
> +				 struct sk_msg *msg_pl, size_t try_to_copy,
> +				 ssize_t *copied)
> +{
> +	struct page *page = NULL, **pages = &page;
> +
> +	do {
> +		ssize_t part;
> +		size_t off;
> +		bool put = false;
> +
> +		part = iov_iter_extract_pages(&msg->msg_iter, &pages,
> +					      try_to_copy, 1, 0, &off);
> +		if (part <= 0)
> +			return part ?: -EIO;
> +
> +		if (WARN_ON_ONCE(!sendpage_ok(page))) {
> +			iov_iter_revert(&msg->msg_iter, part);
> +			return -EIO;
> +		}
> +
> +		sk_msg_page_add(msg_pl, page, part, off);
> +		sk_mem_charge(sk, part);
> +		if (put)
> +			put_page(page);

is put ever set to true?

> +		*copied += part;
> +		try_to_copy -= part;
> +	} while (try_to_copy && !sk_msg_full(msg_pl));
> +
> +	return 0;
> +}
> +
>  int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>  {
>  	long timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
> @@ -1020,6 +1052,17 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>  			full_record = true;
>  		}
>  
> +		if (try_to_copy && (msg->msg_flags & MSG_SPLICE_PAGES)) {
> +			ret = tls_sw_sendmsg_splice(sk, msg, msg_pl,
> +						    try_to_copy, &copied);
> +			if (ret < 0)
> +				goto send_end;
> +			tls_ctx->pending_open_record_frags = true;
> +			if (full_record || eor || sk_msg_full(msg_pl))
> +				goto copied;
> +			continue;
> +		}
> +
>  		if (!is_kvec && (full_record || eor) && !async_capable) {
>  			u32 first = msg_pl->sg.end;
>  
> @@ -1082,8 +1125,9 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>  		/* Open records defined only if successfully copied, otherwise
>  		 * we would trim the sg but not reset the open record frags.
>  		 */
> -		tls_ctx->pending_open_record_frags = true;
>  		copied += try_to_copy;
> +copied:
> +		tls_ctx->pending_open_record_frags = true;

Why move pending-open-record-frags setting if it's also set before
jumping?

>  		if (full_record || eor) {
>  			ret = bpf_exec_tx_verdict(msg_pl, sk, full_record,
>  						  record_type, &copied,

  reply	other threads:[~2023-06-07 17:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 14:05 [PATCH net-next v5 00/14] splice, net: Rewrite splice-to-socket, fix SPLICE_F_MORE and handle MSG_SPLICE_PAGES in AF_TLS David Howells
2023-06-07 14:05 ` [PATCH net-next v5 01/14] net: Block MSG_SENDPAGE_* from being passed to sendmsg() by userspace David Howells
2023-06-07 14:05 ` [PATCH net-next v5 02/14] tls: Allow MSG_SPLICE_PAGES but treat it as normal sendmsg David Howells
2023-06-07 14:05 ` [PATCH net-next v5 03/14] splice, net: Use sendmsg(MSG_SPLICE_PAGES) rather than ->sendpage() David Howells
2023-06-07 16:55   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 04/14] splice, net: Add a splice_eof op to file-ops and socket-ops David Howells
2023-06-07 16:56   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 05/14] tls/sw: Use splice_eof() to flush David Howells
2023-06-07 16:57   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 06/14] tls/device: " David Howells
2023-06-07 16:58   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 07/14] ipv4, ipv6: " David Howells
2023-06-07 15:32   ` Kuniyuki Iwashima
2023-06-07 15:43   ` David Howells
2023-06-07 15:54     ` Kuniyuki Iwashima
2023-06-07 16:01     ` David Howells
2023-06-07 14:05 ` [PATCH net-next v5 08/14] chelsio/chtls: " David Howells
2023-06-07 14:05 ` [PATCH net-next v5 09/14] kcm: " David Howells
2023-06-07 16:05   ` Kuniyuki Iwashima
2023-06-07 17:10   ` David Howells
2023-06-07 14:05 ` [PATCH net-next v5 10/14] splice, net: Fix SPLICE_F_MORE signalling in splice_direct_to_actor() David Howells
2023-06-07 14:05 ` [PATCH net-next v5 11/14] tls/sw: Support MSG_SPLICE_PAGES David Howells
2023-06-07 17:19   ` Jakub Kicinski [this message]
2023-06-07 17:29   ` David Howells
2023-06-07 17:31   ` David Howells
2023-06-07 17:34     ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 12/14] tls/sw: Convert tls_sw_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-06-07 17:20   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 13/14] tls/device: Support MSG_SPLICE_PAGES David Howells
2023-06-07 17:25   ` Jakub Kicinski
2023-06-07 14:05 ` [PATCH net-next v5 14/14] tls/device: Convert tls_device_sendpage() to use MSG_SPLICE_PAGES David Howells
2023-06-07 17:26   ` Jakub Kicinski
2023-06-07 17:35   ` David Howells
2023-06-07 17:46     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230607101945.65c5df51@kernel.org \
    --to=kuba@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=borisp@nvidia.com \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).