Commit 3764ae5b authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

tls: rx: refactor decrypt_skb_update()

Use early return and a jump label to remove two indentation levels.
No functional changes.
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5dbda02d
...@@ -1564,32 +1564,35 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb, ...@@ -1564,32 +1564,35 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
struct tls_prot_info *prot = &tls_ctx->prot_info; struct tls_prot_info *prot = &tls_ctx->prot_info;
struct strp_msg *rxm = strp_msg(skb); struct strp_msg *rxm = strp_msg(skb);
struct tls_msg *tlm = tls_msg(skb); struct tls_msg *tlm = tls_msg(skb);
int pad, err = 0; int pad, err;
if (tlm->decrypted) {
*zc = false;
return 0;
}
if (!tlm->decrypted) {
if (tls_ctx->rx_conf == TLS_HW) { if (tls_ctx->rx_conf == TLS_HW) {
err = tls_device_decrypted(sk, tls_ctx, skb, rxm); err = tls_device_decrypted(sk, tls_ctx, skb, rxm);
if (err < 0) if (err < 0)
return err; return err;
/* skip SW decryption if NIC handled it already */
if (tlm->decrypted) {
*zc = false;
goto decrypt_done;
}
} }
/* Still not decrypted after tls_device */ err = decrypt_internal(sk, skb, dest, NULL, chunk, zc, async);
if (!tlm->decrypted) {
err = decrypt_internal(sk, skb, dest, NULL, chunk, zc,
async);
if (err < 0) { if (err < 0) {
if (err == -EINPROGRESS) if (err == -EINPROGRESS)
tls_advance_record_sn(sk, prot, tls_advance_record_sn(sk, prot, &tls_ctx->rx);
&tls_ctx->rx);
else if (err == -EBADMSG) else if (err == -EBADMSG)
TLS_INC_STATS(sock_net(sk), TLS_INC_STATS(sock_net(sk), LINUX_MIB_TLSDECRYPTERROR);
LINUX_MIB_TLSDECRYPTERROR);
return err; return err;
} }
} else {
*zc = false;
}
decrypt_done:
pad = padding_length(prot, skb); pad = padding_length(prot, skb);
if (pad < 0) if (pad < 0)
return pad; return pad;
...@@ -1599,11 +1602,8 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb, ...@@ -1599,11 +1602,8 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb,
rxm->full_len -= prot->overhead_size; rxm->full_len -= prot->overhead_size;
tls_advance_record_sn(sk, prot, &tls_ctx->rx); tls_advance_record_sn(sk, prot, &tls_ctx->rx);
tlm->decrypted = 1; tlm->decrypted = 1;
} else {
*zc = false;
}
return err; return 0;
} }
int decrypt_skb(struct sock *sk, struct sk_buff *skb, int decrypt_skb(struct sock *sk, struct sk_buff *skb,
......
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