Skip to content

Commit

Permalink
xfrm: espintcp: save and call old ->sk_destruct
Browse files Browse the repository at this point in the history
When ESP encapsulation is enabled on a TCP socket, I'm replacing the
existing ->sk_destruct callback with espintcp_destruct. We still need to
call the old callback to perform the other cleanups when the socket is
destroyed. Save the old callback, and call it from espintcp_destruct.

Fixes: e27cca9 ("xfrm: add espintcp (RFC 8229)")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Sabrina Dubroca authored and Steffen Klassert committed Apr 20, 2020
1 parent 29e4276 commit 9f0cadc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/espintcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct espintcp_ctx {
struct espintcp_msg partial;
void (*saved_data_ready)(struct sock *sk);
void (*saved_write_space)(struct sock *sk);
void (*saved_destruct)(struct sock *sk);
struct work_struct work;
bool tx_running;
};
Expand Down
2 changes: 2 additions & 0 deletions net/xfrm/espintcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ static void espintcp_destruct(struct sock *sk)
{
struct espintcp_ctx *ctx = espintcp_getctx(sk);

ctx->saved_destruct(sk);
kfree(ctx);
}

Expand Down Expand Up @@ -419,6 +420,7 @@ static int espintcp_init_sk(struct sock *sk)
sk->sk_socket->ops = &espintcp_ops;
ctx->saved_data_ready = sk->sk_data_ready;
ctx->saved_write_space = sk->sk_write_space;
ctx->saved_destruct = sk->sk_destruct;
sk->sk_data_ready = espintcp_data_ready;
sk->sk_write_space = espintcp_write_space;
sk->sk_destruct = espintcp_destruct;
Expand Down

0 comments on commit 9f0cadc

Please sign in to comment.