tls: reduce size of tls_cipher_size_desc
authorSabrina Dubroca <sd@queasysnail.net>
Fri, 25 Aug 2023 21:35:11 +0000 (23:35 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 28 Aug 2023 00:17:41 +0000 (17:17 -0700)
commit037303d6760751fdb95ba62cf448ecbc1ac29c98
tree65f0a5591fe99e40bbc767a6e5bcc7efce6993ae
parent200e23165109a173ffde3310dffa5ef5e502d97f
tls: reduce size of tls_cipher_size_desc

tls_cipher_size_desc indexes ciphers by their type, but we're not
using indices 0..50 of the array. Each struct tls_cipher_size_desc is
20B, so that's a lot of unused memory. We can reindex the array
starting at the lowest used cipher_type.

Introduce the get_cipher_size_desc helper to find the right item and
avoid out-of-bounds accesses, and make tls_cipher_size_desc's size
explicit so that gcc reminds us to update TLS_CIPHER_MIN/MAX when we
add a new cipher.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://lore.kernel.org/r/5e054e370e240247a5d37881a1cd93a67c15f4ca.1692977948.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/tls/tls.h
net/tls/tls_device.c
net/tls/tls_device_fallback.c
net/tls/tls_main.c