]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-socket: Remove posix-fdtab dependency
authorAndrei Tatar <andrei@unikraft.io>
Thu, 22 Feb 2024 19:40:25 +0000 (20:40 +0100)
committerUnikraft Bot <monkey@unikraft.io>
Tue, 4 Feb 2025 10:22:02 +0000 (10:22 +0000)
This change makes posix-fdtab no longer a hard dependency of
posix-socket, allowing socket operations using the internal API without
needing a userspace-visible fdtab.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1437

lib/posix-socket/include/uk/socket.h
lib/posix-socket/socket.c

index e322803b7e5e76d7934afdea8b4f42cc7e6cd3c7..8ff21f342b8b2b1dfbbf8b6f028a44d450b88eef 100644 (file)
@@ -42,6 +42,8 @@
 
 #include <sys/socket.h>
 
+#include <uk/config.h>
+
 struct posix_socket_driver;
 
 struct posix_socket_node {
@@ -69,11 +71,13 @@ const struct uk_file *uk_socket_accept(const struct uk_file *sock, int blocking,
                                       struct sockaddr *addr,
                                       socklen_t *addr_len, int flags);
 
+#if CONFIG_LIBPOSIX_FDTAB
 int uk_sys_socket(int family, int type, int protocol);
 
 int uk_sys_socketpair(int family, int type, int protocol, int sv[2]);
 
 int uk_sys_accept(const struct uk_file *sock, int blocking,
                  struct sockaddr *addr, socklen_t *addr_len, int flags);
+#endif /* CONFIG_LIBPOSIX_FDTAB */
 
 #endif /* __UK_SOCKET__ */
index 271d88744c6c351170eae0a7d01e0681fba3412f..fa95d3a1b775dfcc379a21f406a4790f43f2dbb1 100644 (file)
@@ -44,7 +44,6 @@
 #include <uk/socket.h>
 #include <uk/file.h>
 #include <uk/file/nops.h>
-#include <uk/posix-fdtab.h>
 #include <uk/posix-fd.h>
 #include <uk/errptr.h>
 #include <uk/print.h>
 #include <uk/essentials.h>
 #include <errno.h>
 
+#if CONFIG_LIBPOSIX_FDTAB
+#include <uk/posix-fdtab.h>
+#endif /* CONFIG_LIBPOSIX_FDTAB */
+
 #include "events.h"
 
 
@@ -73,7 +76,7 @@ struct socket_alloc {
 #endif /* CONFIG_LIBPOSIX_SOCKET_EVENTS */
 };
 
-
+#if CONFIG_LIBPOSIX_FDTAB
 static struct uk_ofile *socketfd_get(int fd)
 {
        struct uk_ofile *of = uk_fdtab_get(fd);
@@ -86,7 +89,7 @@ static struct uk_ofile *socketfd_get(int fd)
        }
        return of;
 }
-
+#endif /* CONFIG_LIBPOSIX_FDTAB */
 
 static ssize_t
 socket_read(const struct uk_file *sock,
@@ -270,7 +273,7 @@ struct uk_file *uk_socket_create(int family, int type, int protocol)
 }
 
 /* Internal API & Syscalls */
-
+#if CONFIG_LIBPOSIX_FDTAB
 int uk_sys_socket(int family, int type, int protocol)
 {
        int fd;
@@ -309,6 +312,7 @@ UK_SYSCALL_R_DEFINE(int, socket, int, family, int, type, int, protocol)
 
        return ret;
 }
+#endif /* CONFIG_LIBPOSIX_FDTAB */
 
 const struct uk_file *uk_socket_accept(const struct uk_file *sock, int blocking,
                                       struct sockaddr *addr,
@@ -349,6 +353,7 @@ const struct uk_file *uk_socket_accept(const struct uk_file *sock, int blocking,
        return &al->f;
 }
 
+#if CONFIG_LIBPOSIX_FDTAB
 int uk_sys_accept(const struct uk_file *sock, int blocking,
                  struct sockaddr *addr, socklen_t *addr_len, int flags)
 {
@@ -908,6 +913,8 @@ ssize_t send(int sock, const void *buf, size_t len, int flags)
 }
 #endif /* UK_LIBC_SYSCALLS */
 
+#endif /* CONFIG_LIBPOSIX_FDTAB */
+
 
 int uk_socketpair_create(int family, int type, int protocol,
                         const struct uk_file *sv[2])
@@ -952,6 +959,7 @@ err_free:
        return ret;
 }
 
+#if CONFIG_LIBPOSIX_FDTAB
 int uk_sys_socketpair(int family, int type, int protocol, int sv[2])
 {
        int ret;
@@ -1009,3 +1017,4 @@ UK_SYSCALL_R_DEFINE(int, socketpair, int, family, int, type, int, protocol,
                trace_posix_socket_socketpair_ret(ret);
        return ret;
 }
+#endif /* CONFIG_LIBPOSIX_FDTAB */