mirror of
https://github.com/torvalds/linux
synced 2024-09-06 09:51:23 +00:00
vsock: SO_RCVLOWAT transport set callback
This adds transport specific callback for SO_RCVLOWAT, because in some transports it may be difficult to know current available number of bytes ready to read. Thus, when SO_RCVLOWAT is set, transport may reject it. Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
ab48508191
commit
e38f22c860
|
@ -135,6 +135,7 @@ struct vsock_transport {
|
|||
u64 (*stream_rcvhiwat)(struct vsock_sock *);
|
||||
bool (*stream_is_active)(struct vsock_sock *);
|
||||
bool (*stream_allow)(u32 cid, u32 port);
|
||||
int (*set_rcvlowat)(struct vsock_sock *vsk, int val);
|
||||
|
||||
/* SEQ_PACKET. */
|
||||
ssize_t (*seqpacket_dequeue)(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
|
|
|
@ -2137,6 +2137,25 @@ vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int vsock_set_rcvlowat(struct sock *sk, int val)
|
||||
{
|
||||
const struct vsock_transport *transport;
|
||||
struct vsock_sock *vsk;
|
||||
|
||||
vsk = vsock_sk(sk);
|
||||
|
||||
if (val > vsk->buffer_size)
|
||||
return -EINVAL;
|
||||
|
||||
transport = vsk->transport;
|
||||
|
||||
if (transport && transport->set_rcvlowat)
|
||||
return transport->set_rcvlowat(vsk, val);
|
||||
|
||||
WRITE_ONCE(sk->sk_rcvlowat, val ? : 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct proto_ops vsock_stream_ops = {
|
||||
.family = PF_VSOCK,
|
||||
.owner = THIS_MODULE,
|
||||
|
@ -2156,6 +2175,7 @@ static const struct proto_ops vsock_stream_ops = {
|
|||
.recvmsg = vsock_connectible_recvmsg,
|
||||
.mmap = sock_no_mmap,
|
||||
.sendpage = sock_no_sendpage,
|
||||
.set_rcvlowat = vsock_set_rcvlowat,
|
||||
};
|
||||
|
||||
static const struct proto_ops vsock_seqpacket_ops = {
|
||||
|
|
Loading…
Reference in a new issue