Skip to content

Commit

Permalink
af_unix: Add a dummy ->close() for sockmap
Browse files Browse the repository at this point in the history
Unlike af_inet, unix_proto is very different, it does not even
have a ->close(). We have to add a dummy implementation to
satisfy sockmap. Normally it is just a nop, it is introduced only
for sockmap to replace it.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210704190252.11866-6-xiyou.wangcong@gmail.com
  • Loading branch information
Cong Wang authored and Alexei Starovoitov committed Jul 16, 2021
1 parent 83301b5 commit c7272e1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,18 @@ static const struct proto_ops unix_seqpacket_ops = {
.show_fdinfo = unix_show_fdinfo,
};

static void unix_close(struct sock *sk, long timeout)
{
/* Nothing to do here, unix socket does not need a ->close().
* This is merely for sockmap.
*/
}

static struct proto unix_proto = {
.name = "UNIX",
.owner = THIS_MODULE,
.obj_size = sizeof(struct unix_sock),
.close = unix_close,
};

static struct sock *unix_create1(struct net *net, struct socket *sock, int kern)
Expand Down Expand Up @@ -868,6 +876,7 @@ static int unix_release(struct socket *sock)
if (!sk)
return 0;

sk->sk_prot->close(sk, 0);
unix_release_sock(sk, 0);
sock->sk = NULL;

Expand Down

0 comments on commit c7272e1

Please sign in to comment.