Skip to content

Commit 11fe926

Browse files
Björn Töpelborkmann
authored andcommitted
Revert "xsk: simplify AF_XDP socket teardown"
This reverts commit e2ce367. It turns out that the sock destructor xsk_destruct was needed after all. The cleanup simplification broke the skb transmit cleanup path, due to that the umem was prematurely destroyed. The umem cannot be destroyed until all outstanding skbs are freed, which means that we cannot remove the umem until the sk_destruct has been called. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent df1a2cb commit 11fe926

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

net/xdp/xsk.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ static int xsk_release(struct socket *sock)
366366

367367
xskq_destroy(xs->rx);
368368
xskq_destroy(xs->tx);
369-
xdp_put_umem(xs->umem);
370369

371370
sock_orphan(sk);
372371
sock->sk = NULL;
@@ -718,6 +717,18 @@ static const struct proto_ops xsk_proto_ops = {
718717
.sendpage = sock_no_sendpage,
719718
};
720719

720+
static void xsk_destruct(struct sock *sk)
721+
{
722+
struct xdp_sock *xs = xdp_sk(sk);
723+
724+
if (!sock_flag(sk, SOCK_DEAD))
725+
return;
726+
727+
xdp_put_umem(xs->umem);
728+
729+
sk_refcnt_debug_dec(sk);
730+
}
731+
721732
static int xsk_create(struct net *net, struct socket *sock, int protocol,
722733
int kern)
723734
{
@@ -744,6 +755,9 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol,
744755

745756
sk->sk_family = PF_XDP;
746757

758+
sk->sk_destruct = xsk_destruct;
759+
sk_refcnt_debug_inc(sk);
760+
747761
sock_set_flag(sk, SOCK_RCU_FREE);
748762

749763
xs = xdp_sk(sk);

0 commit comments

Comments
 (0)