Kernel/Net: Implement SO_SNDBUF and SO_RCVBUF getsockopt for AF_LOCAL

These options are used for QoS and return buffer length as response.
We currently don't support setting the buffer size.
This commit is contained in:
logkos 2024-09-22 19:45:26 +03:00 committed by Tim Schumacher
parent 62f5bba718
commit 513eb6ed03

View file

@ -403,10 +403,22 @@ ErrorOr<void> LocalSocket::getsockopt(OpenFileDescription& description, int leve
TRY(copy_from_user(&size, value_size.unsafe_userspace_ptr()));
switch (option) {
case SO_SNDBUF:
return ENOTSUP;
case SO_RCVBUF:
return ENOTSUP;
case SO_SNDBUF: {
if (size != sizeof(int))
return EINVAL;
int snd_buffer_size = static_cast<int>(m_for_server->space_for_writing() + m_for_server->immediately_readable());
TRY(copy_to_user(static_ptr_cast<int*>(value), &snd_buffer_size));
TRY(copy_to_user(value_size, &size));
return {};
}
case SO_RCVBUF: {
if (size != sizeof(int))
return EINVAL;
int rcv_buffer_size = static_cast<int>(m_for_client->space_for_writing() + m_for_client->immediately_readable());
TRY(copy_to_user(static_ptr_cast<int*>(value), &rcv_buffer_size));
TRY(copy_to_user(value_size, &size));
return {};
}
case SO_PEERCRED: {
if (size < sizeof(ucred))
return EINVAL;