summaryrefslogtreecommitdiff
path: root/Kernel/Net/Socket.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-12-02 01:01:02 +0200
committerAndreas Kling <kling@serenityos.org>2021-12-05 12:53:29 +0100
commit613ade9deca60a53235490de6e0d6281ea2ac295 (patch)
treefb6972502a6e86a16ad08e1858b6a8a6513c50a0 /Kernel/Net/Socket.cpp
parent641498954fd79772de365435ed24ef6c79cbee48 (diff)
downloadserenity-613ade9deca60a53235490de6e0d6281ea2ac295.zip
Kernel: Implement the SO_DONTROUTE SOL_SOCKET-level option
Diffstat (limited to 'Kernel/Net/Socket.cpp')
-rw-r--r--Kernel/Net/Socket.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index da99bfd724..b3187c585e 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -123,6 +123,14 @@ ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<const void*> u
return ENOTSUP;
}
return {};
+ case SO_DONTROUTE: {
+ int routing_disabled;
+ if (user_value_size != sizeof(routing_disabled))
+ return EINVAL;
+ TRY(copy_from_user(&routing_disabled, static_ptr_cast<const int*>(user_value)));
+ m_routing_disabled = routing_disabled != 0;
+ return {};
+ }
default:
dbgln("setsockopt({}) at SOL_SOCKET not implemented.", option);
return ENOPROTOOPT;
@@ -216,6 +224,14 @@ ErrorOr<void> Socket::getsockopt(OpenFileDescription&, int level, int option, Us
size = sizeof(accepting_connections);
return copy_to_user(value_size, &size);
}
+ case SO_DONTROUTE: {
+ int routing_disabled = m_routing_disabled ? 1 : 0;
+ if (size < sizeof(routing_disabled))
+ return EINVAL;
+ TRY(copy_to_user(static_ptr_cast<int*>(value), &routing_disabled));
+ size = sizeof(routing_disabled);
+ return copy_to_user(value_size, &size);
+ }
default:
dbgln("setsockopt({}) at SOL_SOCKET not implemented.", option);
return ENOPROTOOPT;