Marc Rittinghaus [Mon, 20 Jun 2022 16:57:53 +0000 (18:57 +0200)]
Add eventpoll patch
The polling interface used by posix-socket is based on the eventpoll
API. This patch modifies lwip to call a custom callback for event
notification in lwip's posix-socket driver. It also changes definitions
in lwip's internal socket.h to be compatible with external definitions
we use.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #17
Marc Rittinghaus [Mon, 20 Jun 2022 16:54:05 +0000 (18:54 +0200)]
Switch to posix-socket
This commit replaces the old socket interface provided by lwip with a
driver that plugs into posix-socket. This removes the system call
definitions from lwip and separates system calls from the network
stack.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #17
Simon Kuenzer [Tue, 12 Oct 2021 15:24:04 +0000 (17:24 +0200)]
Print per-device checksum configuration
During network device initialization, print the checksum
handling configuration that get set by the underlying
uknetdev driver. This should simplify first-level of
diagnosis.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #10
Simon Kuenzer [Tue, 12 Oct 2021 15:22:01 +0000 (17:22 +0200)]
Print network device hardware address
During network device initialization, print the hardware
address of the network device to the info kernel console.
This should simplify first-level of diagnosis.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #10
Vlad Badoiu [Tue, 18 Jan 2022 20:16:12 +0000 (22:16 +0200)]
lwip: Add dumb socketpair implementation
We add a dumb implementation of socketpair until
posix-socket is upstreamed. Since we have no SMP
available on Unikraft, this implementation works
well.
Daniel Dinca [Wed, 17 Nov 2021 17:37:01 +0000 (19:37 +0200)]
Add mailbox configuration options
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
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Approved-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #14
Simon Kuenzer [Tue, 9 Nov 2021 15:15:20 +0000 (16:15 +0100)]
Configuration: Differentiate between loopback traffic and loopback device
This commit enables configuring handling of loopback traffic
separately from loopback device. Loopback traffic allows to
send packets with a destination IP address that is equal to
the netif device IP address, and looping them back up the
stack.
The loopback interface provides an interface for localhost
communication (127.0.0.1). The loopback interface
configuration is moved under the `Netif drivers` submenu.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #11
Simon Kuenzer [Tue, 19 Oct 2021 13:45:03 +0000 (15:45 +0200)]
Option for latest lwIP 2.1.x version including Unikraft patches
Introduces an option to choose the latest lwIP version from
the 2.1.x series that is tested by the Unikraft team. This
version is based on the latest official lwIP release,
includes some bugfixes and security fixes, and includes
feature enhancements done by the Unikraft community. These
enhancements are not yet upstream available as part of the
official lwIP project (upstreaming ongoing).
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #9
Simon Kuenzer [Fri, 15 Oct 2021 16:35:43 +0000 (18:35 +0200)]
Option to choose latest lwIP version from 2.1.x series
Introduces an option to choose latest lwIP version from
the 2.1.x series. This version is based on the latest
official lwIP release and includes further bugfixes and
security fixes. Because we point to a branch head,
recent commits could break compiling. Because of this,
we mark this option as `unofficial`.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #9
Simon Kuenzer [Mon, 16 Aug 2021 13:29:18 +0000 (15:29 +0200)]
Point to Unikraft's lwIP fork
With this commit the build system is going to download lwIP
2.1.2 from our official fork on GitHub. Some patch files had
to be adopted (whitespaces) to still apply.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #9
Marc Rittinghaus [Wed, 11 Aug 2021 09:45:39 +0000 (11:45 +0200)]
include: Add IP fragment option
This patch adds a configuration menu that allows for setting IP
options whenever IPv4 or IPv6 is enabled. As a first option, the
number of IP fragments waiting to be reassembled can be configured.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #7
Simon Kuenzer [Tue, 13 Jul 2021 15:50:00 +0000 (17:50 +0200)]
Correct license headers introduced by University Politehnica of Bucharest
This commit removes the additional clause
"THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY"
from BSD license headers that got introduced by mistake
with the following commits: 6fc2582 - Add gethostbyaddr stub (Vlad-Andrei BĂDOIU (78692)) 8193fe5 - Add sendfile() stub (Mihai Pogonaru) 5259076 - Add inet_ntop(), inet_pton() functions (Bogdan Lascu) cb9517a - Add getservbyname and getservbyport stubs (Vlad-Andrei BĂDOIU (78692))
On the one hand, this additional clause is redundant because
the BSD license already states that it must remain and the
copyright notice must be kept.
On the other hand, the clause freezes the file header
and prohibits future contributors from extending the
copyright notice for their contributions. This additional
clause is not part of the official BSD 3-clause.
The original author(s) or an authorized representative from
the author's affiliation consents to the change with a
`Reviewed-by` tag to this commit.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #6
Simon Kuenzer [Tue, 13 Jul 2021 15:49:59 +0000 (17:49 +0200)]
Correct license headers introduced by NEC Laboratories Europe GmbH
This commit removes the additional clause
"THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY"
from BSD license headers that got introduced by mistake
with the following commits: 96d4f49 - Initial port of lwIP to Unikraft (Sharan Santhanam) d01ed1c - Netif driver for libuknetdev devices (Simon Kuenzer) cf5ec19 - Update to lwIP 2.1.2 (Simon Kuenzer)
On the one hand, this additional clause is redundant because
the BSD license already states that it must remain and the
copyright notice must be kept.
On the other hand, the clause freezes the file header
and prohibits future contributors from extending the
copyright notice for their contributions. This additional
clause is not part of the official BSD 3-clause.
The original author(s) or an authorized representative from
the author's affiliation consents to the change with a
`Reviewed-by` tag to this commit.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #5
Hugo Lefeuvre [Thu, 18 Jun 2020 13:59:08 +0000 (15:59 +0200)]
lwip: support for memory pools
Add support for memory pools.
There are now two allocation modes:
(1) heap only, malloc/free are used everywhere (even for memp allocations)
(2) memory pools with custom pools.
The pools are sized to provide good performance for Redis: 1000x256,
1000x512, 1000x1256. Overall this is equivalent to ~2MB, which might be
too much in some cases. In any case, these should be manually tweaked
for performance critical applications.
Increase the defaults for the maximum number of TCP sockets and listeners
(was previously 5, now 64), and expose them via the menuconfig.
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Simon Kuenzer [Wed, 2 Dec 2020 23:32:14 +0000 (00:32 +0100)]
Option to force polling mode
Introduces an option to force polling mode for uknetdev devices
irrespective if the device supports interrupt-driven mode.
Because this option always causes 100% CPU utilization it should
be considered as workaround for cases where interrupt-based
handling performs badly.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Simon Kuenzer [Mon, 9 Nov 2020 16:06:23 +0000 (17:06 +0100)]
cc.h: Disable Ethernet frame padding
We set ETH_PAD_SIZE to 0 and remove support from uknetdev.c. This is done
because some uknetdev drivers will not support it (e.g., netfront) and
according to https://lwn.net/Articles/89597/, the gains of doing padding
is negligible on the CPU architectures that we currently support while
potentially hurting DMA engine performances that may get involved with
the respective driver and/or hypervisor.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Simon Kuenzer [Mon, 9 Nov 2020 16:06:22 +0000 (17:06 +0100)]
uknetdev: Per device `lwip_data` to callbacks
In order to hand-over per device `lwip_data` to the rx/tx packet allocation
function (`netif_alloc_rxpkts()`), we move storing the reference to the
allocator that used for packet allocations to `lwip_data`. In the future,
this can be used to enable per device buffer pools (e.g.,
with `ukallocpool`) for faster allocation and freeing requests.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
The uknetdev library provides the way to check if interrupts are
supported on a uk_netdev. If the device does not support interrupt
the lwip stack would create a thread to poll the receive queue for
packets.
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu> Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Reserves space for per-network-device (uknetdev). This will be later
used to store network stack specific specific information in the netdevice.
Reserving this memory allows us to store the memory continuously in the
netdev instead of additional dereferences.
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu> Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Costin Lupu [Tue, 3 Mar 2020 14:14:43 +0000 (16:14 +0200)]
init.c: Retrieve IP v4 address from device information
IP addresses for netfront devices on Xen may be configured using Xenstore.
Therefore we should first try to get the IP address from device before taking
it from elsewhere.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Simon Kuenzer [Mon, 17 Feb 2020 12:23:08 +0000 (13:23 +0100)]
net/if.h: Add include guard
Expose `struct ifconf` also when _GNU_SOURCE is defined but add an
include guard for the header. This way, double definitons of the
struct are avoided.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Felipe Huici [Fri, 14 Feb 2020 13:12:14 +0000 (14:12 +0100)]
Fix compile error when enabling Operation mode (Mainloop (non-threaded).
Enabling operating mode non-threaded (aka CONFIG_LWIP_NOTHREADS)
disables the socket API from lwip. This commit makes it so that our
socket-related glue code isn't added to the build if this option is
enabled.
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu> Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Simon Kuenzer [Thu, 13 Feb 2020 22:50:54 +0000 (23:50 +0100)]
uknetdev: Yield receive thread on full stack queue
When a too high rate of network traffic is received, the netdev's receive
thread may never yield and only forwards packets to the lwip stack
thread. This works as expected until the input queue runs full. If the
the stack is never able to process them, the stack becomes completely
unresponsive. Instead of dropping just a few packets all successive
packets are dropped.
This commit introduces a thread yield when this condition is met and
gives the chance to process queued packets.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Simon Kuenzer [Wed, 12 Feb 2020 14:31:38 +0000 (15:31 +0100)]
Stub getservbyport_r()
Building lwip breaks when nolibc is selected. getservbyport_r() was
relying on definitions which aren't available with nolibc. This commit
stubs this function because it seems that it wasn't used and tested so
far.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Simon Kuenzer [Wed, 12 Feb 2020 14:31:29 +0000 (15:31 +0100)]
ppoll()/generic select() only available with libc
The options LWIP_SOCKET_SELECT_GENERIC_FDS and LWIP_SOCKET_PPOLL are
only made available when a proper libc (HAVE_LIBC) is added and
enabled to the build. These options do not work with nolibc.
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Costin Lupu [Sat, 16 Nov 2019 21:50:52 +0000 (23:50 +0200)]
sockets.c: Make select() not return errors when using it with file descriptor types other than sockets
lwip's select() implementation supports only sockets. Up until now, we returned
errors when using select() with other file descriptor types. These changes make
it possible to use other file descriptor types as well, even though they will
be ignored.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Felipe Huici [Mon, 21 Oct 2019 13:46:35 +0000 (15:46 +0200)]
Add getservbyport_r and if_indextoname
Add stub for if_indextoname and full definition, taken from musl, for
getservbyport_r . if_indextoname's stub returns 0 (i.e., interface 0),
which should be good enough for our purposes.
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu> Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Felipe Huici [Mon, 21 Oct 2019 13:46:34 +0000 (15:46 +0200)]
Add IPv6 macro definitions
Add IN6_IS_ADDR_MULTICAST, IN6_IS_ADDR_LINKLOCAL and
IN6_IS_ADDR_MC_LINKLOCAL macro definitions. These are defined by libc,
but not included in by our netinet/in.h glue when sockets are enabled,
breaking builds that depend on these and sockets.
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu> Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Felipe Huici [Wed, 18 Sep 2019 09:21:26 +0000 (11:21 +0200)]
Remove exportsyms.uk
For now we remove exportsyms.uk . This is to prevent a lot of
unnecessary confusion (and wasted time) arising from undefined
reference linker errors when the actual sybol is actually in the
sources. We may revert this at some later point in time.
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu> Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
We currently just set a stub for .vop_getattr operation in order to avoid
crashes. And since we are here, this patch also disables the cast-function-type
warnings which annoyingly apear for each source file that sets some filesystem
callbacks.
It's simpler to suppress the warning rather than add '__unused' qualifier each
time. This also seems it was the initial intention behind using
'-Wunused-parameter', given that all warnings are enabled by default.
* As we did in commit b0dc593d, we use function wrappers instead of macros for
gethostbyname() and gethostbyname_r()
* Add missing declarations of functions implemented or stubbed in glue code
Bogdan Lascu [Fri, 23 Aug 2019 11:53:44 +0000 (14:53 +0300)]
Define getaddrinfo() and freeaddrinfo() as functions instead of wrappers
Commit 28138d6d added getaddrinfo() and freeaddrinfo() as wrappers. However,
it's not necessary for a source file to include the netdb.h header where they
are defined when it uses them. So their definitions are needed as functions and
not as macros.
Bogdan Lascu [Fri, 16 Aug 2019 07:09:42 +0000 (10:09 +0300)]
lwipopts.h: Use libc ioctl.h if available
If we do have a libc ioctl.h header then we should be using it because it
usually contains a larger number of constants with better value assignments than
the ones in lwip.
Costin Lupu [Fri, 16 Aug 2019 07:09:40 +0000 (10:09 +0300)]
Adapt getnameinfo() function to Unikraft
This is how you adapt a function to Unikraft:
1. Add license if it is missing; in our case, getnameinfo() was initially taken
from musl to OsV and enhanced a bit, so we had to add the BSD license of OsV and
the MIT license of musl; we decided to take the OsV implementation because it
also checks the local /etc/hosts file before issuing DNS requests
2. Use Unikraft headers
3. Fix checkpatch issues
4. Disable some unsupported functionality; in our case, we don't support name
requests for getnameinfo(); we could have if the DNS implementation of lwip
supported DNS resource records
5. Define constants that are not already provided by the origin code
6. Add its source file to Makefile.uk
7. Export the function
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Mihai Pogonaru [Sat, 29 Jun 2019 13:54:57 +0000 (16:54 +0300)]
Update the number of remaining unprocessed bytes correctly
Update uio structure in sock_net_write/read. VFSCORE expects the
update of the resid member of uio such that it reflects the
number of bytes that remain unprocessed.
Set the UK_VFSCORE_NOPOS flag on the socket vfscore_file. This
flag informs VFSCORE to do not update the offset of our socket
file since it doesn't make sense for sockets.
Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com> Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
Mihai Pogonaru [Sat, 29 Jun 2019 13:54:56 +0000 (16:54 +0300)]
Use vfs functions to allocate/free the resources used for a socket (Part I)
This part changes LWIP so that it lets vfs to free the resources
used to integrate sockets in vfs.
Right now sock_net_close frees the vfscore_file, dentry and vnode
used for the socket. This can cause problems since vfs unlocks the
vnode after calling sock_net_close so it accesses freed memory.
We will let vfs handle the freeing of the resources used for a
socket by setting the dentry refcount to 1 such that, when a socket is
closed (so its vfscore_file is also closed), the dentry's refcount
hits 0, the dentry is deleted so the vnode refcount hits 0
and it is also deleted.
Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com> Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
Mihai Pogonaru [Sat, 15 Jun 2019 13:18:19 +0000 (16:18 +0300)]
Provide gethostbyname and gethostbyname_r
Define gethostbyname and gethostbyname_r as their LWIP counterparts.
The defines are in place in origin/netdb.h, but they are protected by
LWIP_COMPAT_SOCKETS, which for us is defined as 0 since we provide
wrappers for most of socket.h functions.
Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com> Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
Florian Schmidt [Mon, 20 May 2019 11:29:51 +0000 (13:29 +0200)]
Provide poll() and select() wrappers around lwip versions
This takes the vfscore-provided file descriptors, translates them into
lwip file descriptors, and will run the lwip versions on those sockets.
If any of the file descriptors provided isn't an LWIP socket, the call
will fail with a return of -1, errno EBADF.
Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Florian Schmidt [Mon, 20 May 2019 11:29:50 +0000 (13:29 +0200)]
sockets.c: Refuse to deal with non-sockets
Otherwise, socket_net_file_get() will try to look up lwip's file
descriptors for file objects not created by lwip, reading garbage from
where it expects sock_fd in sock_net_file.
Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu> Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>