From: Sharan Santhanam Date: Fri, 15 Jun 2018 20:53:48 +0000 (+0200) Subject: Expose socket header & disable socket polling X-Git-Tag: RELEASE-0.3~7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5adf61d1925df62b67beca58f59ed215e4a7fa2a;p=unikraft%2Flibs%2Flwip.git Expose socket header & disable socket polling In this patch, we expose the socket API through lwIP. In its current implementation, we do disable support for select()/poll() on a file descriptor since an implementation is missing in vfscore. We are going to add this feature again in the near future. Signed-off-by: Sharan Santhanam --- diff --git a/include/sys/socket.h b/include/sys/socket.h index 05da60b..5f496cb 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -1,7 +1,6 @@ #ifndef UK_LWIP_SOCKET_H #include -#ifndef CONFIG_HAVE_LIBC #if CONFIG_LIBLWIP #include @@ -11,5 +10,4 @@ #define SOCK_CLOEXEC 0x10000000 #define SOCK_NONBLOCK 0x20000000 -#endif /* CONFIG_HAVELIBC */ #endif /* UK_LWIP_SOCKET_H */ diff --git a/patches/0002-introduce-lwip_getsock_status.patch b/patches/0002-introduce-lwip_getsock_status.patch deleted file mode 100644 index 65447b7..0000000 --- a/patches/0002-introduce-lwip_getsock_status.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff -urp lwip-2.0.3-orig/src/api/sockets.c src/api/sockets.c ---- a/src/api/sockets.c 2018-03-20 13:07:37.161480805 +0100 -+++ b/src/api/sockets.c 2018-03-19 18:01:08.206420575 +0100 -@@ -1290,6 +1290,46 @@ lwip_writev(int s, const struct iovec *i - return lwip_sendmsg(s, &msg, 0); - } - -+int lwip_getsock_status(int fd) -+{ -+ int flags = 0; -+ struct lwip_sock *sock; -+ -+ SYS_ARCH_DECL_PROTECT(lev); -+ SYS_ARCH_PROTECT(lev); -+ sock = tryget_socket(fd); -+ if (sock != NULL) { -+ void* lastdata = sock->lastdata; -+ s16_t rcvevent = sock->rcvevent; -+ u16_t sendevent = sock->sendevent; -+ u16_t errevent = sock->errevent; -+ SYS_ARCH_UNPROTECT(lev); -+ -+ /* ... then examine it: */ -+ /* See if netconn of this socket is ready for read */ -+ if ((lastdata != NULL) || (rcvevent > 0)) { -+ flags |= LWIP_SOC_RD_READY; -+ LWIP_DEBUGF(SOCKETS_DEBUG, ("%s: lwip_fd=%d ready for reading\n", -+ __func__, fd)); -+ } -+ /* See if netconn of this socket is ready for write */ -+ if (sendevent != 0) { -+ flags |= LWIP_SOC_WR_READY; -+ LWIP_DEBUGF(SOCKETS_DEBUG, ("%s: lwip_fd=%d ready for writing\n", -+ __func__, fd)); -+ } -+ /* See if netconn of this socket had an error */ -+ if (errevent != 0) { -+ flags |= LWIP_SOC_EXCEPTION; -+ LWIP_DEBUGF(SOCKETS_DEBUG, ("%s: lwip_fd=%d ready for exception\n", -+ __func__, fd)); -+ } -+ } else { -+ SYS_ARCH_UNPROTECT(lev); -+ } -+ -+ return flags; -+} - /** - * Go through the readset and writeset lists and see which socket of the sockets - * set in the sets has events. On return, readset, writeset and exceptset have -diff -urp src/include/lwip/sockets.h src/include/lwip/sockets.h ---- a/src/include/lwip/sockets.h 2017-03-01 23:13:14.000000000 +0100 -+++ b/src/include/lwip/sockets.h 2018-03-19 17:34:49.143047601 +0100 -@@ -419,6 +419,10 @@ typedef struct ip_mreq { - #define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7))) - #define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) - -+#define LWIP_SOC_RD_READY 0x01 -+#define LWIP_SOC_WR_READY 0x02 -+#define LWIP_SOC_EXCEPTION 0x04 -+ - typedef struct fd_set - { - unsigned char fd_bits [(FD_SETSIZE+7)/8];