diff options
Diffstat (limited to 'net/tls/tls_main.c')
-rw-r--r-- | net/tls/tls_main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 28887cf628b8..78cb4a584080 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c | |||
@@ -55,6 +55,8 @@ enum { | |||
55 | 55 | ||
56 | static struct proto *saved_tcpv6_prot; | 56 | static struct proto *saved_tcpv6_prot; |
57 | static DEFINE_MUTEX(tcpv6_prot_mutex); | 57 | static DEFINE_MUTEX(tcpv6_prot_mutex); |
58 | static struct proto *saved_tcpv4_prot; | ||
59 | static DEFINE_MUTEX(tcpv4_prot_mutex); | ||
58 | static LIST_HEAD(device_list); | 60 | static LIST_HEAD(device_list); |
59 | static DEFINE_SPINLOCK(device_spinlock); | 61 | static DEFINE_SPINLOCK(device_spinlock); |
60 | static struct proto tls_prots[TLS_NUM_PROTS][TLS_NUM_CONFIG][TLS_NUM_CONFIG]; | 62 | static struct proto tls_prots[TLS_NUM_PROTS][TLS_NUM_CONFIG][TLS_NUM_CONFIG]; |
@@ -700,6 +702,16 @@ static int tls_init(struct sock *sk) | |||
700 | mutex_unlock(&tcpv6_prot_mutex); | 702 | mutex_unlock(&tcpv6_prot_mutex); |
701 | } | 703 | } |
702 | 704 | ||
705 | if (ip_ver == TLSV4 && | ||
706 | unlikely(sk->sk_prot != smp_load_acquire(&saved_tcpv4_prot))) { | ||
707 | mutex_lock(&tcpv4_prot_mutex); | ||
708 | if (likely(sk->sk_prot != saved_tcpv4_prot)) { | ||
709 | build_protos(tls_prots[TLSV4], sk->sk_prot); | ||
710 | smp_store_release(&saved_tcpv4_prot, sk->sk_prot); | ||
711 | } | ||
712 | mutex_unlock(&tcpv4_prot_mutex); | ||
713 | } | ||
714 | |||
703 | ctx->tx_conf = TLS_BASE; | 715 | ctx->tx_conf = TLS_BASE; |
704 | ctx->rx_conf = TLS_BASE; | 716 | ctx->rx_conf = TLS_BASE; |
705 | update_sk_prot(sk, ctx); | 717 | update_sk_prot(sk, ctx); |
@@ -731,8 +743,6 @@ static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = { | |||
731 | 743 | ||
732 | static int __init tls_register(void) | 744 | static int __init tls_register(void) |
733 | { | 745 | { |
734 | build_protos(tls_prots[TLSV4], &tcp_prot); | ||
735 | |||
736 | tls_sw_proto_ops = inet_stream_ops; | 746 | tls_sw_proto_ops = inet_stream_ops; |
737 | tls_sw_proto_ops.splice_read = tls_sw_splice_read; | 747 | tls_sw_proto_ops.splice_read = tls_sw_splice_read; |
738 | 748 | ||