aboutsummaryrefslogtreecommitdiffstats
path: root/net/tls/tls_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tls/tls_main.c')
-rw-r--r--net/tls/tls_main.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 545bf34ed599..3aafb871a0a8 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -54,6 +54,9 @@ enum {
54enum { 54enum {
55 TLS_BASE, 55 TLS_BASE,
56 TLS_SW, 56 TLS_SW,
57#ifdef CONFIG_TLS_DEVICE
58 TLS_HW,
59#endif
57 TLS_HW_RECORD, 60 TLS_HW_RECORD,
58 TLS_NUM_CONFIG, 61 TLS_NUM_CONFIG,
59}; 62};
@@ -280,6 +283,15 @@ static void tls_sk_proto_close(struct sock *sk, long timeout)
280 tls_sw_free_resources_rx(sk); 283 tls_sw_free_resources_rx(sk);
281 } 284 }
282 285
286#ifdef CONFIG_TLS_DEVICE
287 if (ctx->tx_conf != TLS_HW) {
288#else
289 {
290#endif
291 kfree(ctx);
292 ctx = NULL;
293 }
294
283skip_tx_cleanup: 295skip_tx_cleanup:
284 release_sock(sk); 296 release_sock(sk);
285 sk_proto_close(sk, timeout); 297 sk_proto_close(sk, timeout);
@@ -442,8 +454,16 @@ static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
442 } 454 }
443 455
444 if (tx) { 456 if (tx) {
445 rc = tls_set_sw_offload(sk, ctx, 1); 457#ifdef CONFIG_TLS_DEVICE
446 conf = TLS_SW; 458 rc = tls_set_device_offload(sk, ctx);
459 conf = TLS_HW;
460 if (rc) {
461#else
462 {
463#endif
464 rc = tls_set_sw_offload(sk, ctx, 1);
465 conf = TLS_SW;
466 }
447 } else { 467 } else {
448 rc = tls_set_sw_offload(sk, ctx, 0); 468 rc = tls_set_sw_offload(sk, ctx, 0);
449 conf = TLS_SW; 469 conf = TLS_SW;
@@ -596,6 +616,16 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG],
596 prot[TLS_SW][TLS_SW].recvmsg = tls_sw_recvmsg; 616 prot[TLS_SW][TLS_SW].recvmsg = tls_sw_recvmsg;
597 prot[TLS_SW][TLS_SW].close = tls_sk_proto_close; 617 prot[TLS_SW][TLS_SW].close = tls_sk_proto_close;
598 618
619#ifdef CONFIG_TLS_DEVICE
620 prot[TLS_HW][TLS_BASE] = prot[TLS_BASE][TLS_BASE];
621 prot[TLS_HW][TLS_BASE].sendmsg = tls_device_sendmsg;
622 prot[TLS_HW][TLS_BASE].sendpage = tls_device_sendpage;
623
624 prot[TLS_HW][TLS_SW] = prot[TLS_BASE][TLS_SW];
625 prot[TLS_HW][TLS_SW].sendmsg = tls_device_sendmsg;
626 prot[TLS_HW][TLS_SW].sendpage = tls_device_sendpage;
627#endif
628
599 prot[TLS_HW_RECORD][TLS_HW_RECORD] = *base; 629 prot[TLS_HW_RECORD][TLS_HW_RECORD] = *base;
600 prot[TLS_HW_RECORD][TLS_HW_RECORD].hash = tls_hw_hash; 630 prot[TLS_HW_RECORD][TLS_HW_RECORD].hash = tls_hw_hash;
601 prot[TLS_HW_RECORD][TLS_HW_RECORD].unhash = tls_hw_unhash; 631 prot[TLS_HW_RECORD][TLS_HW_RECORD].unhash = tls_hw_unhash;
@@ -630,7 +660,7 @@ static int tls_init(struct sock *sk)
630 ctx->getsockopt = sk->sk_prot->getsockopt; 660 ctx->getsockopt = sk->sk_prot->getsockopt;
631 ctx->sk_proto_close = sk->sk_prot->close; 661 ctx->sk_proto_close = sk->sk_prot->close;
632 662
633 /* Build IPv6 TLS whenever the address of tcpv6_prot changes */ 663 /* Build IPv6 TLS whenever the address of tcpv6 _prot changes */
634 if (ip_ver == TLSV6 && 664 if (ip_ver == TLSV6 &&
635 unlikely(sk->sk_prot != smp_load_acquire(&saved_tcpv6_prot))) { 665 unlikely(sk->sk_prot != smp_load_acquire(&saved_tcpv6_prot))) {
636 mutex_lock(&tcpv6_prot_mutex); 666 mutex_lock(&tcpv6_prot_mutex);
@@ -680,6 +710,9 @@ static int __init tls_register(void)
680 tls_sw_proto_ops.poll = tls_sw_poll; 710 tls_sw_proto_ops.poll = tls_sw_poll;
681 tls_sw_proto_ops.splice_read = tls_sw_splice_read; 711 tls_sw_proto_ops.splice_read = tls_sw_splice_read;
682 712
713#ifdef CONFIG_TLS_DEVICE
714 tls_device_init();
715#endif
683 tcp_register_ulp(&tcp_tls_ulp_ops); 716 tcp_register_ulp(&tcp_tls_ulp_ops);
684 717
685 return 0; 718 return 0;
@@ -688,6 +721,9 @@ static int __init tls_register(void)
688static void __exit tls_unregister(void) 721static void __exit tls_unregister(void)
689{ 722{
690 tcp_unregister_ulp(&tcp_tls_ulp_ops); 723 tcp_unregister_ulp(&tcp_tls_ulp_ops);
724#ifdef CONFIG_TLS_DEVICE
725 tls_device_cleanup();
726#endif
691} 727}
692 728
693module_init(tls_register); 729module_init(tls_register);