netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/tls: enable sk_msg redirect to tls socket egress
@ 2019-11-18 15:40 Willem de Bruijn
  2019-11-19  5:47 ` John Fastabend
  2019-11-19 23:04 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Willem de Bruijn @ 2019-11-18 15:40 UTC (permalink / raw)
  To: netdev; +Cc: bpf, john.fastabend, jakub.kicinski, daniel, Willem de Bruijn

From: Willem de Bruijn <willemb@google.com>

Bring back tls_sw_sendpage_locked. sk_msg redirection into a socket
with TLS_TX takes the following path:

  tcp_bpf_sendmsg_redir
    tcp_bpf_push_locked
      tcp_bpf_push
        kernel_sendpage_locked
          sock->ops->sendpage_locked

Also update the flags test in tls_sw_sendpage_locked to allow flag
MSG_NO_SHARED_FRAGS. bpf_tcp_sendmsg sets this.

Link: https://lore.kernel.org/netdev/CA+FuTSdaAawmZ2N8nfDDKu3XLpXBbMtcCT0q4FntDD2gn8ASUw@mail.gmail.com/T/#t
Link: https://github.com/wdebruij/kerneltools/commits/icept.2
Fixes: 0608c69c9a80 ("bpf: sk_msg, sock{map|hash} redirect through ULP")
Fixes: f3de19af0f5b ("Revert \"net/tls: remove unused function tls_sw_sendpage_locked\"")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 include/net/tls.h  |  2 ++
 net/tls/tls_main.c |  1 +
 net/tls/tls_sw.c   | 11 +++++++++++
 3 files changed, 14 insertions(+)

diff --git a/include/net/tls.h b/include/net/tls.h
index 794e297483eab..f4ad831eaa02b 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -356,6 +356,8 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx);
 void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);
 void tls_sw_strparser_done(struct tls_context *tls_ctx);
 int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
+int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
+			   int offset, size_t size, int flags);
 int tls_sw_sendpage(struct sock *sk, struct page *page,
 		    int offset, size_t size, int flags);
 void tls_sw_cancel_work_tx(struct tls_context *tls_ctx);
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 0775ae40fcfb4..f874cc0da45df 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -908,6 +908,7 @@ static int __init tls_register(void)
 {
 	tls_sw_proto_ops = inet_stream_ops;
 	tls_sw_proto_ops.splice_read = tls_sw_splice_read;
+	tls_sw_proto_ops.sendpage_locked   = tls_sw_sendpage_locked,
 
 	tls_device_init();
 	tcp_register_ulp(&tcp_tls_ulp_ops);
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 446f23c1f3ce4..319735d5c084f 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1204,6 +1204,17 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
 	return copied ? copied : ret;
 }
 
+int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
+			   int offset, size_t size, int flags)
+{
+	if (flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
+		      MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY |
+		      MSG_NO_SHARED_FRAGS))
+		return -ENOTSUPP;
+
+	return tls_sw_do_sendpage(sk, page, offset, size, flags);
+}
+
 int tls_sw_sendpage(struct sock *sk, struct page *page,
 		    int offset, size_t size, int flags)
 {
-- 
2.24.0.432.g9d3f5f5b63-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] net/tls: enable sk_msg redirect to tls socket egress
  2019-11-18 15:40 [PATCH] net/tls: enable sk_msg redirect to tls socket egress Willem de Bruijn
@ 2019-11-19  5:47 ` John Fastabend
  2019-11-19 23:04 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: John Fastabend @ 2019-11-19  5:47 UTC (permalink / raw)
  To: Willem de Bruijn, netdev
  Cc: bpf, john.fastabend, jakub.kicinski, daniel, Willem de Bruijn

Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> Bring back tls_sw_sendpage_locked. sk_msg redirection into a socket
> with TLS_TX takes the following path:
> 
>   tcp_bpf_sendmsg_redir
>     tcp_bpf_push_locked
>       tcp_bpf_push
>         kernel_sendpage_locked
>           sock->ops->sendpage_locked
> 
> Also update the flags test in tls_sw_sendpage_locked to allow flag
> MSG_NO_SHARED_FRAGS. bpf_tcp_sendmsg sets this.
> 
> Link: https://lore.kernel.org/netdev/CA+FuTSdaAawmZ2N8nfDDKu3XLpXBbMtcCT0q4FntDD2gn8ASUw@mail.gmail.com/T/#t
> Link: https://github.com/wdebruij/kerneltools/commits/icept.2
> Fixes: 0608c69c9a80 ("bpf: sk_msg, sock{map|hash} redirect through ULP")
> Fixes: f3de19af0f5b ("Revert \"net/tls: remove unused function tls_sw_sendpage_locked\"")
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> ---

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net/tls: enable sk_msg redirect to tls socket egress
  2019-11-18 15:40 [PATCH] net/tls: enable sk_msg redirect to tls socket egress Willem de Bruijn
  2019-11-19  5:47 ` John Fastabend
@ 2019-11-19 23:04 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-11-19 23:04 UTC (permalink / raw)
  To: willemdebruijn.kernel
  Cc: netdev, bpf, john.fastabend, jakub.kicinski, daniel, willemb

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Mon, 18 Nov 2019 10:40:51 -0500

> From: Willem de Bruijn <willemb@google.com>
> 
> Bring back tls_sw_sendpage_locked. sk_msg redirection into a socket
> with TLS_TX takes the following path:
> 
>   tcp_bpf_sendmsg_redir
>     tcp_bpf_push_locked
>       tcp_bpf_push
>         kernel_sendpage_locked
>           sock->ops->sendpage_locked
> 
> Also update the flags test in tls_sw_sendpage_locked to allow flag
> MSG_NO_SHARED_FRAGS. bpf_tcp_sendmsg sets this.
> 
> Link: https://lore.kernel.org/netdev/CA+FuTSdaAawmZ2N8nfDDKu3XLpXBbMtcCT0q4FntDD2gn8ASUw@mail.gmail.com/T/#t
> Link: https://github.com/wdebruij/kerneltools/commits/icept.2
> Fixes: 0608c69c9a80 ("bpf: sk_msg, sock{map|hash} redirect through ULP")
> Fixes: f3de19af0f5b ("Revert \"net/tls: remove unused function tls_sw_sendpage_locked\"")
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Applied and queued up for -stable, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-19 23:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 15:40 [PATCH] net/tls: enable sk_msg redirect to tls socket egress Willem de Bruijn
2019-11-19  5:47 ` John Fastabend
2019-11-19 23:04 ` David Miller

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).