Commit 9f0c8245 authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by David S. Miller

tls: use fixed size for tls_offload_context_{tx,rx}.driver_state

driver_state is a flex array, but is always allocated by the tls core
to a fixed size (TLS_DRIVER_STATE_SIZE_{TX,RX}). Simplify the code by
making that size explicit so that sizeof(struct
tls_offload_context_{tx,rx}) works.
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0700aa3a
...@@ -150,6 +150,7 @@ struct tls_record_info { ...@@ -150,6 +150,7 @@ struct tls_record_info {
skb_frag_t frags[MAX_SKB_FRAGS]; skb_frag_t frags[MAX_SKB_FRAGS];
}; };
#define TLS_DRIVER_STATE_SIZE_TX 16
struct tls_offload_context_tx { struct tls_offload_context_tx {
struct crypto_aead *aead_send; struct crypto_aead *aead_send;
spinlock_t lock; /* protects records list */ spinlock_t lock; /* protects records list */
...@@ -163,17 +164,13 @@ struct tls_offload_context_tx { ...@@ -163,17 +164,13 @@ struct tls_offload_context_tx {
void (*sk_destruct)(struct sock *sk); void (*sk_destruct)(struct sock *sk);
struct work_struct destruct_work; struct work_struct destruct_work;
struct tls_context *ctx; struct tls_context *ctx;
u8 driver_state[] __aligned(8);
/* The TLS layer reserves room for driver specific state /* The TLS layer reserves room for driver specific state
* Currently the belief is that there is not enough * Currently the belief is that there is not enough
* driver specific state to justify another layer of indirection * driver specific state to justify another layer of indirection
*/ */
#define TLS_DRIVER_STATE_SIZE_TX 16 u8 driver_state[TLS_DRIVER_STATE_SIZE_TX] __aligned(8);
}; };
#define TLS_OFFLOAD_CONTEXT_SIZE_TX \
(sizeof(struct tls_offload_context_tx) + TLS_DRIVER_STATE_SIZE_TX)
enum tls_context_flags { enum tls_context_flags {
/* tls_device_down was called after the netdev went down, device state /* tls_device_down was called after the netdev went down, device state
* was released, and kTLS works in software, even though rx_conf is * was released, and kTLS works in software, even though rx_conf is
...@@ -303,6 +300,7 @@ struct tls_offload_resync_async { ...@@ -303,6 +300,7 @@ struct tls_offload_resync_async {
u32 log[TLS_DEVICE_RESYNC_ASYNC_LOGMAX]; u32 log[TLS_DEVICE_RESYNC_ASYNC_LOGMAX];
}; };
#define TLS_DRIVER_STATE_SIZE_RX 8
struct tls_offload_context_rx { struct tls_offload_context_rx {
/* sw must be the first member of tls_offload_context_rx */ /* sw must be the first member of tls_offload_context_rx */
struct tls_sw_context_rx sw; struct tls_sw_context_rx sw;
...@@ -326,17 +324,13 @@ struct tls_offload_context_rx { ...@@ -326,17 +324,13 @@ struct tls_offload_context_rx {
struct tls_offload_resync_async *resync_async; struct tls_offload_resync_async *resync_async;
}; };
}; };
u8 driver_state[] __aligned(8);
/* The TLS layer reserves room for driver specific state /* The TLS layer reserves room for driver specific state
* Currently the belief is that there is not enough * Currently the belief is that there is not enough
* driver specific state to justify another layer of indirection * driver specific state to justify another layer of indirection
*/ */
#define TLS_DRIVER_STATE_SIZE_RX 8 u8 driver_state[TLS_DRIVER_STATE_SIZE_RX] __aligned(8);
}; };
#define TLS_OFFLOAD_CONTEXT_SIZE_RX \
(sizeof(struct tls_offload_context_rx) + TLS_DRIVER_STATE_SIZE_RX)
struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context, struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context,
u32 seq, u64 *p_record_sn); u32 seq, u64 *p_record_sn);
......
...@@ -1038,7 +1038,7 @@ static struct tls_offload_context_tx *alloc_offload_ctx_tx(struct tls_context *c ...@@ -1038,7 +1038,7 @@ static struct tls_offload_context_tx *alloc_offload_ctx_tx(struct tls_context *c
struct tls_offload_context_tx *offload_ctx; struct tls_offload_context_tx *offload_ctx;
__be64 rcd_sn; __be64 rcd_sn;
offload_ctx = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_TX, GFP_KERNEL); offload_ctx = kzalloc(sizeof(*offload_ctx), GFP_KERNEL);
if (!offload_ctx) if (!offload_ctx)
return NULL; return NULL;
...@@ -1225,7 +1225,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx) ...@@ -1225,7 +1225,7 @@ int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
goto release_lock; goto release_lock;
} }
context = kzalloc(TLS_OFFLOAD_CONTEXT_SIZE_RX, GFP_KERNEL); context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context) { if (!context) {
rc = -ENOMEM; rc = -ENOMEM;
goto release_lock; goto release_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment