forked from mirrors/linux
		
	net/tls: enable sk_msg redirect to tls socket egress
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: 0608c69c9a ("bpf: sk_msg, sock{map|hash} redirect through ULP")
Fixes: f3de19af0f ("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>
Signed-off-by: David S. Miller <davem@davemloft.net>
			
			
This commit is contained in:
		
							parent
							
								
									db96c2cb48
								
							
						
					
					
						commit
						d4ffb02dee
					
				
					 3 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
					@ -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_arm(struct sock *sk, struct tls_context *ctx);
 | 
				
			||||||
void tls_sw_strparser_done(struct tls_context *tls_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_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 tls_sw_sendpage(struct sock *sk, struct page *page,
 | 
				
			||||||
		    int offset, size_t size, int flags);
 | 
							    int offset, size_t size, int flags);
 | 
				
			||||||
void tls_sw_cancel_work_tx(struct tls_context *tls_ctx);
 | 
					void tls_sw_cancel_work_tx(struct tls_context *tls_ctx);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -908,6 +908,7 @@ static int __init tls_register(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tls_sw_proto_ops = inet_stream_ops;
 | 
						tls_sw_proto_ops = inet_stream_ops;
 | 
				
			||||||
	tls_sw_proto_ops.splice_read = tls_sw_splice_read;
 | 
						tls_sw_proto_ops.splice_read = tls_sw_splice_read;
 | 
				
			||||||
 | 
						tls_sw_proto_ops.sendpage_locked   = tls_sw_sendpage_locked,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tls_device_init();
 | 
						tls_device_init();
 | 
				
			||||||
	tcp_register_ulp(&tcp_tls_ulp_ops);
 | 
						tcp_register_ulp(&tcp_tls_ulp_ops);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1204,6 +1204,17 @@ static int tls_sw_do_sendpage(struct sock *sk, struct page *page,
 | 
				
			||||||
	return copied ? copied : ret;
 | 
						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 tls_sw_sendpage(struct sock *sk, struct page *page,
 | 
				
			||||||
		    int offset, size_t size, int flags)
 | 
							    int offset, size_t size, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue