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

net/tls: use sg_next() to walk sg entries

Partially sent record cleanup path increments an SG entry
directly instead of using sg_next(). This should not be a
problem today, as encrypted messages should be always
allocated as arrays. But given this is a cleanup path it's
easy to miss was this ever to change. Use sg_next(), and
simplify the code.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e5ffed3
...@@ -376,7 +376,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx, ...@@ -376,7 +376,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx,
int flags); int flags);
int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
int flags); int flags);
bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx); void tls_free_partial_record(struct sock *sk, struct tls_context *ctx);
static inline struct tls_msg *tls_msg(struct sk_buff *skb) static inline struct tls_msg *tls_msg(struct sk_buff *skb)
{ {
......
...@@ -209,24 +209,15 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, ...@@ -209,24 +209,15 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
return tls_push_sg(sk, ctx, sg, offset, flags); return tls_push_sg(sk, ctx, sg, offset, flags);
} }
bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx) void tls_free_partial_record(struct sock *sk, struct tls_context *ctx)
{ {
struct scatterlist *sg; struct scatterlist *sg;
sg = ctx->partially_sent_record; for (sg = ctx->partially_sent_record; sg; sg = sg_next(sg)) {
if (!sg)
return false;
while (1) {
put_page(sg_page(sg)); put_page(sg_page(sg));
sk_mem_uncharge(sk, sg->length); sk_mem_uncharge(sk, sg->length);
if (sg_is_last(sg))
break;
sg++;
} }
ctx->partially_sent_record = NULL; ctx->partially_sent_record = NULL;
return true;
} }
static void tls_write_space(struct sock *sk) static void tls_write_space(struct sock *sk)
......
...@@ -2089,7 +2089,8 @@ void tls_sw_release_resources_tx(struct sock *sk) ...@@ -2089,7 +2089,8 @@ void tls_sw_release_resources_tx(struct sock *sk)
/* Free up un-sent records in tx_list. First, free /* Free up un-sent records in tx_list. First, free
* the partially sent record if any at head of tx_list. * the partially sent record if any at head of tx_list.
*/ */
if (tls_free_partial_record(sk, tls_ctx)) { if (tls_ctx->partially_sent_record) {
tls_free_partial_record(sk, tls_ctx);
rec = list_first_entry(&ctx->tx_list, rec = list_first_entry(&ctx->tx_list,
struct tls_rec, list); struct tls_rec, list);
list_del(&rec->list); list_del(&rec->list);
......
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