]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Add mailbox configuration options RELEASE-0.6
authorDaniel Dinca <danieldinca97@yahoo.com>
Wed, 17 Nov 2021 17:37:01 +0000 (19:37 +0200)
committerUnikraft <monkey@unikraft.io>
Tue, 30 Nov 2021 16:12:00 +0000 (16:12 +0000)
This fixes a bug where some packets are dropped because
LWIP mailbox is bigger than the UDP and TCP mailboxes.

This introduces the "LWIP stackthread mbox size" where you
can now select the size for the input mailbox for the lwip thread.

The sizes for the UDP and TCP mailboxes are now always bigger or
equal to the LWIP input mailbox. You can select the factor by which
they are greater in the "Sockets API" submenu. (i.e if you choose
a factor of 2 for the UDP mailbox it will have the size 2*LWIP mailbox
size).

Signed-off-by: Daniel Dinca <danieldinca97@yahoo.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Approved-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #13

Config.uk
include/lwipopts.h
mailbox.c

index 3b6aba905c4c905989c7f2802f77bbcfaa13d2cc..be7e74cf5b4e233e84c0bf607aec64b2bc4f734c 100644 (file)
--- a/Config.uk
+++ b/Config.uk
@@ -123,6 +123,39 @@ config LWIP_THREADS
                Creates a core thread for the stack.
 endchoice
 
+choice
+    prompt "Stack input mailbox size"
+    depends on LWIP_THREADS
+       default LWIP_STACKTHREAD_MBOX_SIZE_256
+    config LWIP_STACKTHREAD_MBOX_SIZE_32
+        bool "32"
+    config LWIP_STACKTHREAD_MBOX_SIZE_64
+        bool "64"
+    config LWIP_STACKTHREAD_MBOX_SIZE_128
+        bool "128"
+       config LWIP_STACKTHREAD_MBOX_SIZE_256
+        bool "256"
+    config LWIP_STACKTHREAD_MBOX_SIZE_512
+        bool "512"
+    config LWIP_STACKTHREAD_MBOX_SIZE_1024
+        bool "1024"
+       config LWIP_STACKTHREAD_MBOX_SIZE_2048
+        bool "2048"
+       help
+               This sets the size for the input mailbox that is used for receiving traffic from the network
+               interfaces.
+endchoice
+
+config LWIP_STACKTHREAD_MBOX_SIZE
+    int
+    default 32 if LWIP_STACKTHREAD_MBOX_SIZE_32
+    default 64 if LWIP_STACKTHREAD_MBOX_SIZE_64
+    default 128 if LWIP_STACKTHREAD_MBOX_SIZE_128
+    default 256 if LWIP_STACKTHREAD_MBOX_SIZE_256
+    default 512 if LWIP_STACKTHREAD_MBOX_SIZE_512
+    default 1024 if LWIP_STACKTHREAD_MBOX_SIZE_1024
+    default 2048 if LWIP_STACKTHREAD_MBOX_SIZE_2048
+
 choice
        prompt "Memory allocation mode"
        default LWIP_HEAP
@@ -247,10 +280,10 @@ config LWIP_DNS_TABLE_SIZE
        default 32
 endif
 
-config LWIP_SOCKET
+menuconfig LWIP_SOCKET
+       depends on LWIP_THREADS && (LWIP_UDP || LWIP_TCP)
        bool "Socket API"
        select LIBVFSCORE
-       depends on LWIP_THREADS && (LWIP_UDP || LWIP_TCP)
        default y
 
 if LWIP_SOCKET
@@ -269,6 +302,24 @@ if LWIP_SOCKET
                default y
                help
                        Enable ppoll() implementation.
+
+       config LWIP_UDP_RECVMBOX_FACTOR
+               int "Factor for UDP recvmbox"
+               depends on LWIP_UDP
+               range 1 5
+               default 2
+               help
+                       How many times should the UDP recvmbox be bigger than the LWIP stackthread mbox size.
+                       Default 2, maximum 5.
+
+       config LWIP_TCP_RECVMBOX_FACTOR
+               int "Factor for TCP recvmbox"
+               depends on LWIP_TCP
+               range 1 5
+               default 2
+               help
+                       How many times should the TCP recvmbox be bigger than the LWIP stackthread mbox size.
+                       Default 2, maximum 5.
 endif
 
 menuconfig LWIP_DEBUG
index 87b7329d4b8cc54cf894fe6cd0472a64ab2b5242..4433bed69ad45c571378d6dc8b4be0668b9727a2 100644 (file)
@@ -69,7 +69,10 @@ void sys_free(void *ptr);
 /* lightweight protection */
 #define SYS_LIGHTWEIGHT_PROT 1
 #define TCPIP_THREAD_NAME "lwip"
-#define TCPIP_MBOX_SIZE 256
+#define TCPIP_MBOX_SIZE CONFIG_LWIP_STACKTHREAD_MBOX_SIZE
+#define DEFAULT_UDP_RECVMBOX_SIZE ((CONFIG_LWIP_UDP_RECVMBOX_FACTOR) * (TCPIP_MBOX_SIZE))
+#define DEFAULT_TCP_RECVMBOX_SIZE ((CONFIG_LWIP_TCP_RECVMBOX_FACTOR) * (TCPIP_MBOX_SIZE))
+#define DEFAULT_ACCEPTMBOX_SIZE (TCPIP_MBOX_SIZE)
 #endif /* CONFIG_LWIP_NOTHREADS */
 
 /**
index b7dc2636309f8228a5a8518cf133776821e35e83..1467fbc9554aec301e00244499ff49bd9ec410b2 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
 #include <uk/mbox.h>
 #include <uk/arch/time.h>
 #include <lwip/sys.h>
+#include <lwipopts.h>
 
 #include <uk/essentials.h>
 
 /* Creates an empty mailbox. */
 err_t sys_mbox_new(sys_mbox_t *mbox, int size)
 {
-       if (size <= 0)
-               size = 32;
+       if (size <= 0) {
+               LWIP_DEBUGF(SOCKETS_DEBUG,
+                           ("Mailbox created with default size.\n"));
+               size = TCPIP_MBOX_SIZE;
+       }
 
        UK_ASSERT(mbox);
        mbox->a = uk_alloc_get_default();