Commit 77462de1 authored by Jiang Wang's avatar Jiang Wang Committed by Andrii Nakryiko

af_unix: Add read_sock for stream socket types

To support sockmap for af_unix stream type, implement
read_sock, which is similar to the read_sock for unix
dgram sockets.
Signed-off-by: default avatarJiang Wang <jiang.wang@bytedance.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210816190327.2739291-2-jiang.wang@bytedance.com
parent edce1a24
...@@ -679,6 +679,8 @@ static int unix_dgram_sendmsg(struct socket *, struct msghdr *, size_t); ...@@ -679,6 +679,8 @@ static int unix_dgram_sendmsg(struct socket *, struct msghdr *, size_t);
static int unix_dgram_recvmsg(struct socket *, struct msghdr *, size_t, int); static int unix_dgram_recvmsg(struct socket *, struct msghdr *, size_t, int);
static int unix_read_sock(struct sock *sk, read_descriptor_t *desc, static int unix_read_sock(struct sock *sk, read_descriptor_t *desc,
sk_read_actor_t recv_actor); sk_read_actor_t recv_actor);
static int unix_stream_read_sock(struct sock *sk, read_descriptor_t *desc,
sk_read_actor_t recv_actor);
static int unix_dgram_connect(struct socket *, struct sockaddr *, static int unix_dgram_connect(struct socket *, struct sockaddr *,
int, int); int, int);
static int unix_seqpacket_sendmsg(struct socket *, struct msghdr *, size_t); static int unix_seqpacket_sendmsg(struct socket *, struct msghdr *, size_t);
...@@ -732,6 +734,7 @@ static const struct proto_ops unix_stream_ops = { ...@@ -732,6 +734,7 @@ static const struct proto_ops unix_stream_ops = {
.shutdown = unix_shutdown, .shutdown = unix_shutdown,
.sendmsg = unix_stream_sendmsg, .sendmsg = unix_stream_sendmsg,
.recvmsg = unix_stream_recvmsg, .recvmsg = unix_stream_recvmsg,
.read_sock = unix_stream_read_sock,
.mmap = sock_no_mmap, .mmap = sock_no_mmap,
.sendpage = unix_stream_sendpage, .sendpage = unix_stream_sendpage,
.splice_read = unix_stream_splice_read, .splice_read = unix_stream_splice_read,
...@@ -2491,6 +2494,15 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk, ...@@ -2491,6 +2494,15 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,
} }
#endif #endif
static int unix_stream_read_sock(struct sock *sk, read_descriptor_t *desc,
sk_read_actor_t recv_actor)
{
if (unlikely(sk->sk_state != TCP_ESTABLISHED))
return -ENOTCONN;
return unix_read_sock(sk, desc, recv_actor);
}
static int unix_stream_read_generic(struct unix_stream_read_state *state, static int unix_stream_read_generic(struct unix_stream_read_state *state,
bool freezable) bool freezable)
{ {
......
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