]> xenbits.xensource.com Git - unikraft/libs/lwip.git/log
unikraft/libs/lwip.git
17 months agosocket.c: Port to the new posix-socket API
Andrei Tatar [Fri, 3 Nov 2023 16:24:32 +0000 (17:24 +0100)]
socket.c: Port to the new posix-socket API

This change ports lwip to the new posix-socket API introduced with the
vfs refactoring. As part of this port lwip no longer depends on vfscore.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #39

17 months agoinclude: Expose LwIP's RAW protocol
Ethan Cotterell [Thu, 29 Apr 2021 14:50:41 +0000 (15:50 +0100)]
include: Expose LwIP's RAW protocol

This commit optionalizes LwIP's "RAW" protocol, making it available to
use within Unikraft when enabled.

Signed-off-by: Ethan Cotterell <e.cotterell@lancs.ac.uk>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #2

18 months agoIntroduce `Library.uk` RELEASE-0.15.0
Alexander Jung [Tue, 11 Jul 2023 21:25:56 +0000 (21:25 +0000)]
Introduce `Library.uk`

This new file represents the first step towards proper versioning support of
external microlibrary in Unikraft.  The file itself acts as mechanism for
holding metadata-only values about the microlibrary.  This metadata is designed
to be compatible with GNU Make whilst simultaneously being human-readable and
readable by programs that are not GNU Make (e.g. tools such as KraftKit).

An important feature of this file is the inclusion of microlibrary versions.
In a later step, once relevant integrations have been made to Unikrat's core
build system and to relevant tools such as KraftKit, the user will be able to
see and select from different versions of the microlibrary.

In this initial commit, the relevant metadata is absorbed from both Makefile.uk,
Config.uk, but also includes new information such as SPDX License identifier.

Signed-off-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #37

20 months agoMakefile.uk: Silence macro redefinition warnings RELEASE-0.14.0
Andrei Tatar [Tue, 27 Jun 2023 16:21:52 +0000 (18:21 +0200)]
Makefile.uk: Silence macro redefinition warnings

This change silences clang's macro redefinition warning which triggers
often for LWIP when it redefines LITTLE_ENDIAN and BIG_ENDIAN.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #38

2 years agopatches: Align TCP_KEEP* macro values with those of Linux RELEASE-0.13.0 RELEASE-0.13.1
Ioan-Teodor Teugea [Fri, 21 Apr 2023 21:01:43 +0000 (00:01 +0300)]
patches: Align TCP_KEEP* macro values with those of Linux

Add patch to change TCP define values
to the values currently used by the Linux kernel
for compatibility with socket related syscalls.

Signed-off-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #34

2 years agoAdd SOCK_NONBLOCK to accept4 and socket
Marc Rittinghaus [Wed, 12 Apr 2023 13:26:11 +0000 (15:26 +0200)]
Add SOCK_NONBLOCK to accept4 and socket

This commit adds support for the SOCK_NONBLOCK flag to
the accept4 and socket calls.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #33

2 years agoAdapt forced polling mode to uknetdev flag rename RELEASE-0.12.0
Marco Schlumpp [Sun, 5 Feb 2023 10:33:29 +0000 (11:33 +0100)]
Adapt forced polling mode to uknetdev flag rename

The rxq interrupt flag was renamed in unikraft some time ago [1]. This
adapts liblwip to this change.

[1]: unikraft/unikraft@bf6ebd2b49728278b6f19ef6ef060d86ca166675

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #30

2 years agoRemove unused configuration options
Marco Schlumpp [Mon, 30 Jan 2023 10:20:57 +0000 (11:20 +0100)]
Remove unused configuration options

These were originally used when LWIP provided poll functions, but these
were moved to posix-event.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #26

2 years agoPass TCP timestamps config define to LWIP code
Marco Schlumpp [Mon, 30 Jan 2023 10:19:18 +0000 (11:19 +0100)]
Pass TCP timestamps config define to LWIP code

The corresponding Unikraft config has a CONFIG_ prefix that won't be
picked up by the LWIP source code.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #26

2 years agoPass TCP keep-alive config define to LWIP code
Marco Schlumpp [Mon, 30 Jan 2023 10:19:05 +0000 (11:19 +0100)]
Pass TCP keep-alive config define to LWIP code

The corresponding Unikraft config has a CONFIG_ prefix that won't be
picked up by the LWIP source code.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #26

2 years agoMakefile.uk: Use -Wno-cast-function-type for GCC >= 8 RELEASE-0.11.0
Razvan Deaconescu [Wed, 30 Nov 2022 00:02:21 +0000 (02:02 +0200)]
Makefile.uk: Use -Wno-cast-function-type for GCC >= 8

The `-Wno-cast-function-type` build option is only present for GCC >= 8.
Update `Makefile.uk` to use the option conditionally.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #28

2 years agopatches: Include fcntl.h and sys/ioctl.h in sockets.c
Razvan Deaconescu [Sun, 27 Nov 2022 10:44:47 +0000 (12:44 +0200)]
patches: Include fcntl.h and sys/ioctl.h in sockets.c

When using Musl, `fcntl.h` and `sys/ioctl.h` are indirectly included in
`sockets.c` via other header files.

When using nolibc, however, `fcntl.h` and `sys/ioctl.h` are not
included. This commit updates the `sockets.c` patch file to include
`fcntl.h` and `sys/ioctl.h`.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #27

2 years agopatches: Add patches for Musl compatibility
Razvan Deaconescu [Sun, 20 Nov 2022 15:18:20 +0000 (17:18 +0200)]
patches: Add patches for Musl compatibility

Add patch files that remove or update functions, macros and variables in
LWIP original source code to make it compatible to Musl.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #23

2 years agoRemove commented out source code files
Razvan Deaconescu [Sun, 20 Nov 2022 13:16:12 +0000 (15:16 +0200)]
Remove commented out source code files

Lines were commented out in `Makefile.uk`. Remove them from
`Makefile.uk` and also fully remove the source code files from the tree.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #23

2 years agoRemove source code files defined by libc
Razvan Deaconescu [Sun, 20 Nov 2022 13:14:46 +0000 (15:14 +0200)]
Remove source code files defined by libc

Remove source code files that are to be defined by the standard C
library (Musl or nolibc).

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #23

2 years agosockets.c: Remove functions defined in libc
Razvan Deaconescu [Sun, 20 Nov 2022 13:08:09 +0000 (15:08 +0200)]
sockets.c: Remove functions defined in libc

Functions `if_nametoindex` and `if_indextoname` are to be defined by the
standard C library (Musl, nolibc).

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #23

2 years agoAdopt to refactored scheduling API (lib/uksched)
Simon Kuenzer [Wed, 20 Apr 2022 21:35:58 +0000 (23:35 +0200)]
Adopt to refactored scheduling API (lib/uksched)

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #19

2 years agoMakefile.uk: Remove ip6addr-related files
Razvan Deaconescu [Wed, 9 Nov 2022 07:21:36 +0000 (09:21 +0200)]
Makefile.uk: Remove ip6addr-related files

These are to be defined by the libc implementation (such as Musl).

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #25

2 years agoserv.c: Add uk/essentials.h as include dependency
Razvan Deaconescu [Thu, 27 Oct 2022 14:44:20 +0000 (17:44 +0300)]
serv.c: Add uk/essentials.h as include dependency

This fixes build issue with undefined `__unused` symbol.

Fixes #21

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Virtan <virtanrazvan@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #22

2 years agoRemove redundant argument from POSIX_SOCKET_FAMILY_REGISTER macro RELEASE-0.10.0
Maria Sfiraiala [Sun, 21 Aug 2022 13:54:02 +0000 (16:54 +0300)]
Remove redundant argument from POSIX_SOCKET_FAMILY_REGISTER macro

In the `POSIX_SOCKET_FAMILY_REGISTER` macro, when the IPv6 option is
selected, the third argument produces a compilation error.

Due to the macro being defined in
`unikraft/lib/posix-socket/include/uk/socket_driver.h` with only 2
arguments, the third argument becomes redundant.

This commit removes it and ensures that the `AF_INET6` is successfully
registered.

Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #18

2 years agoAdd eventpoll patch
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

2 years agoSwitch to posix-socket
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

2 years agoFix return values of recv/send functions
Marc Rittinghaus [Mon, 20 Jun 2022 16:50:57 +0000 (18:50 +0200)]
Fix return values of recv/send functions

In the current headers the recv and send class functions return an int.
However, according to the man pages they should return a ssize_t.

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

3 years agoPrint per-device checksum configuration RELEASE-0.8.0 RELEASE-0.9.0
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

3 years agoPrint network device hardware address
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

3 years agoProbe network device features
Simon Kuenzer [Tue, 12 Oct 2021 15:19:03 +0000 (17:19 +0200)]
Probe network device features

Latest lib/uknetdev updates make it necessary that new network
interfaces need to be probed for feature negotiation before the
interface can be used.

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

3 years agolwip: Add dumb socketpair implementation RELEASE-0.7.0
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.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
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: #15

3 years agoAdd mailbox configuration options RELEASE-0.6
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

3 years agosockets.c: fix crash when handling invalid/unsupported FDs
Hugo Lefeuvre [Fri, 26 Nov 2021 14:23:11 +0000 (15:23 +0100)]
sockets.c: fix crash when handling invalid/unsupported FDs

aee924b [0] introduce a bug where any return value of sock_net_file_get
that is an error code but *not -EBADF* will return in a crash.

Assume a situation where sock_net_file_get(i) returns an error-encoded
file that is not -EBADF (e.g., -EINVAL): that file will go through the

if (PTR2ERR(file) == -EBADF)

check and pass it, moving on to

if (maxfd < file->sock_fd)

where the error-encoded pointer is dereferenced, resulting in a crash.

[0] https://github.com/hlef/lib-lwip/commit/aee924ba854034f8b085a4298

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

3 years agoConfiguration: Differentiate between loopback traffic and loopback device
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

3 years agoOption for latest lwIP 2.1.x version including Unikraft patches
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

3 years agoOption to choose latest lwIP version from 2.1.x series
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

3 years agoPoint to Unikraft's lwIP fork
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

3 years agoinclude: Add IP fragment option
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

3 years agouknetdev: Initialize the txq_conf
Sharan Santhanam [Wed, 30 Jun 2021 08:00:24 +0000 (10:00 +0200)]
uknetdev: Initialize the txq_conf

This patch initializes the txq_conf structure.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #4

3 years agoCorrect license headers introduced by University Politehnica of Bucharest
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

3 years agoCorrect license headers introduced by NEC Laboratories Europe GmbH
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

4 years agolwip: support for memory pools
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>
4 years agoOption to force polling mode RELEASE-0.5
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>
4 years agoalloc.c: Include missing `<stddef.h>`
Simon Kuenzer [Wed, 2 Dec 2020 23:31:57 +0000 (00:31 +0100)]
alloc.c: Include missing `<stddef.h>`

Include `<stddef.h>` that provides the definition for `size_t`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
4 years agoAdd in6addr_loopback
Vlad-Andrei Badoiu [Thu, 14 May 2020 13:06:41 +0000 (16:06 +0300)]
Add in6addr_loopback

Bind9 uses the in6addr_loopback symbol. We add this
symbol in a separate c file, in6addr_loopback.c.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Reviewed-by: Alice Suiu <alicesuiu17@gmail.com>
4 years agouknetdev: Retrieve `ioalign` from device
Simon Kuenzer [Mon, 9 Nov 2020 16:06:26 +0000 (17:06 +0100)]
uknetdev: Retrieve `ioalign` from device

Retrieve `ioalign` from uknetdev device and apply it to packet buffer
allocations.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
4 years agonetbuf: Aligned buffers with `lwip_alloc_netbuf()`
Simon Kuenzer [Mon, 9 Nov 2020 16:06:25 +0000 (17:06 +0100)]
netbuf: Aligned buffers with `lwip_alloc_netbuf()`

Adds an alignment parameter to `lwip_alloc_netbuf()` that enables
alignment of the buffer area (`m->buf`).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
4 years agouknetdev: Per device RX and TX headroom
Simon Kuenzer [Mon, 9 Nov 2020 16:06:24 +0000 (17:06 +0100)]
uknetdev: Per device RX and TX headroom

Store required rx and tx headroom on `lwip_data` by storing the
device info per device.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
4 years agocc.h: Disable Ethernet frame padding
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>
4 years agouknetdev: Per device `lwip_data` to callbacks
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>
4 years agolib/lwip: Enable poll only receive
Sharan Santhanam [Tue, 21 Jul 2020 15:32:46 +0000 (17:32 +0200)]
lib/lwip: Enable poll only receive

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>
4 years agolib/lwip: Fetch features supported on the netdev
Sharan Santhanam [Tue, 21 Jul 2020 15:32:45 +0000 (17:32 +0200)]
lib/lwip: Fetch features supported on the netdev

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
4 years agolib/lwip: Reserve per netdev space for lwip
Sharan Santhanam [Tue, 21 Jul 2020 15:32:44 +0000 (17:32 +0200)]
lib/lwip: Reserve per netdev space for lwip

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>
4 years agoinit.c: Retrieve IP v4 address from device information
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>
5 years agonetinet/in.h: Add several missing IPV6 & IP defines and structures
Vlad-Andrei BĂDOIU [Tue, 31 Mar 2020 14:39:47 +0000 (17:39 +0300)]
netinet/in.h: Add several missing IPV6 & IP defines and structures

Our in.h header is missing several defines and structures. We
import their definition from musl.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agonetinet/tcp.h: Add header guards
Vlad-Andrei BĂDOIU [Tue, 31 Mar 2020 14:39:46 +0000 (17:39 +0300)]
netinet/tcp.h: Add header guards

tcp.h is missing the header guards, we add
them in this patch.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoUse if_nametoindex and if_nametoindex from lwip
Vlad-Andrei BĂDOIU [Tue, 31 Mar 2020 14:39:45 +0000 (17:39 +0300)]
Use if_nametoindex and if_nametoindex from lwip

if_nametoindex and if_nametoindex are currently subbed. We
remove the stubs and use the implementation from lwip.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agonet/if.h: Add include guard RELEASE-0.4
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>
5 years agosys/socket.h: Fix typo of guard: CONFIG_LWIP_SOCKET
Simon Kuenzer [Mon, 17 Feb 2020 12:22:57 +0000 (13:22 +0100)]
sys/socket.h: Fix typo of guard: CONFIG_LWIP_SOCKET

Fixes a typo of the CONFIG_LWIP_SOCKET guard.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoFix compile error when enabling Operation mode (Mainloop (non-threaded).
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>
5 years agouknetdev: Yield receive thread on full stack queue
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>
5 years agoStub getservbyport_r()
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>
5 years agoppoll()/generic select() only available with libc
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>
5 years agolwip: Add compile guard for struct ifconf
Sharan Santhanam [Sun, 2 Feb 2020 13:39:11 +0000 (14:39 +0100)]
lwip: Add compile guard for struct ifconf

Fix to disable redefinition of struct ifconf from python

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
5 years agoAdd nameserver headers from musl.
Felipe Huici [Mon, 9 Dec 2019 10:49:45 +0000 (11:49 +0100)]
Add nameserver headers from musl.

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, 51eb2084 .

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoMake headers compatible with c++ builds
Felipe Huici [Mon, 9 Dec 2019 08:19:25 +0000 (09:19 +0100)]
Make headers compatible with c++ builds

Add extern C clauses to header files so that c++ builds do not break.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoAdd missing EAI_* macro definitions
Felipe Huici [Mon, 9 Dec 2019 08:19:24 +0000 (09:19 +0100)]
Add missing EAI_* macro definitions

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agopatches: Add more fields to struct ifreq
Costin Lupu [Fri, 6 Dec 2019 13:23:46 +0000 (15:23 +0200)]
patches: Add more fields to struct ifreq

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agopatches: Add ipi_spec_dst field to struct in_pktinfo
Costin Lupu [Fri, 6 Dec 2019 13:23:45 +0000 (15:23 +0200)]
patches: Add ipi_spec_dst field to struct in_pktinfo

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agoAdd missing definitions for supporting Ruby
Costin Lupu [Fri, 6 Dec 2019 13:23:44 +0000 (15:23 +0200)]
Add missing definitions for supporting Ruby

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agoImport network headers from musl to support Ruby
Costin Lupu [Fri, 6 Dec 2019 13:23:43 +0000 (15:23 +0200)]
Import network headers from musl to support Ruby

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agosockets.c: Add ppoll() function
Costin Lupu [Mon, 25 Nov 2019 07:47:43 +0000 (09:47 +0200)]
sockets.c: Add ppoll() function

This ppoll() implementation is adapted from its man page. If tmo_p is NULL,
then ppoll() can block indefinitely.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoFix compilation warning
Jia He [Fri, 11 Oct 2019 15:19:28 +0000 (23:19 +0800)]
Fix compilation warning

Fix warning about comparison between signed and unsigned integer in
proto.c by changing idx from int to unsigned int.

Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosockets.c: Make select() not return errors when using it with file descriptor types...
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>
5 years agosys/socket.h: Define AF_LOCAL
Costin Lupu [Fri, 1 Nov 2019 11:16:43 +0000 (13:16 +0200)]
sys/socket.h: Define AF_LOCAL

We use, just like on Linux, the same value as AF_UNIX. Or the other way around.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoAdd getservbyport_r and if_indextoname
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>
5 years agoAdd IPv6 macro definitions
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>
5 years agosys/socket.h: Add AF_UNIX and SCM_RIGHTS definitions
Mihai Pogonaru [Tue, 29 Oct 2019 20:30:35 +0000 (22:30 +0200)]
sys/socket.h: Add AF_UNIX and SCM_RIGHTS definitions

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd sendfile() stub
Mihai Pogonaru [Mon, 28 Oct 2019 23:40:03 +0000 (01:40 +0200)]
Add sendfile() stub

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdapt sendfile.h to Unikraft
Mihai Pogonaru [Mon, 28 Oct 2019 23:40:02 +0000 (01:40 +0200)]
Adapt sendfile.h to Unikraft

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoImport sendfile.h from musl
Mihai Pogonaru [Mon, 28 Oct 2019 23:40:01 +0000 (01:40 +0200)]
Import sendfile.h from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 06d4075a.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd TCP_CORK definition to netinet/tcp.h
Mihai Pogonaru [Sun, 27 Oct 2019 19:58:43 +0000 (21:58 +0200)]
Add TCP_CORK definition to netinet/tcp.h

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoliblwip: Move liblwip_init to inittab
Sharan Santhanam [Mon, 7 Oct 2019 08:54:05 +0000 (10:54 +0200)]
liblwip: Move liblwip_init to inittab

We move the liblwip initialization to the into the lwip library
and register it with the inittab.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
5 years agoMakefile.uk: Compile getnameinfo.c only when DNS is enabled
Costin Lupu [Fri, 4 Oct 2019 16:52:13 +0000 (19:52 +0300)]
Makefile.uk: Compile getnameinfo.c only when DNS is enabled

getnameinfo() function needs definitions that are enabled only when LWIP_DNS is
configured.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agoRemove exportsyms.uk
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>
5 years agoEnable loopback interface
Costin Lupu [Thu, 12 Sep 2019 09:00:01 +0000 (12:00 +0300)]
Enable loopback interface

The loopback interface is used in many of the Python 3 unit tests.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agosockets.c: Set stub for .vop_getattr operation
Costin Lupu [Thu, 12 Sep 2019 09:00:00 +0000 (12:00 +0300)]
sockets.c: Set stub for .vop_getattr operation

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.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoMakefile.uk: Suppress 'unused parameters' warnings
Costin Lupu [Wed, 4 Sep 2019 19:09:12 +0000 (22:09 +0300)]
Makefile.uk: Suppress 'unused parameters' warnings

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.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agosockets: Add socketpair() stub
Costin Lupu [Wed, 4 Sep 2019 19:09:11 +0000 (22:09 +0300)]
sockets: Add socketpair() stub

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agosockets: Add recvmsg() function
Costin Lupu [Wed, 4 Sep 2019 19:09:10 +0000 (22:09 +0300)]
sockets: Add recvmsg() function

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agosys/socket.h: Add SOMAXCONN macro
Costin Lupu [Wed, 4 Sep 2019 19:09:09 +0000 (22:09 +0300)]
sys/socket.h: Add SOMAXCONN macro

This is the maximum value for the backlog parameter of listen() function.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoRevisit netdb.h declarations
Costin Lupu [Wed, 4 Sep 2019 19:09:08 +0000 (22:09 +0300)]
Revisit netdb.h declarations

* 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

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoexportsyms.uk: Add dns_gethostbyname
Felipe Huici [Tue, 3 Sep 2019 09:33:15 +0000 (11:33 +0200)]
exportsyms.uk: Add dns_gethostbyname

Add dns_gethostbyname needed by the Micropython port

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoexportsyms.uk: Alphabetize symbol list.
Felipe Huici [Tue, 3 Sep 2019 08:03:43 +0000 (10:03 +0200)]
exportsyms.uk: Alphabetize symbol list.

To enhance readabilty we alphabetize the list of exported symbols. All
Unikraft libs should follow this in the future.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoexportsyms.uk: expose symbols needed by Micropython port.
Felipe Huici [Tue, 3 Sep 2019 08:03:42 +0000 (10:03 +0200)]
exportsyms.uk: expose symbols needed by Micropython port.

Add symbols (e.g., dns_gethostbyname, getnameinfo) needed by
Micropython.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoMakefile.uk: Guard socket-related source files.
Felipe Huici [Tue, 3 Sep 2019 08:03:41 +0000 (10:03 +0200)]
Makefile.uk: Guard socket-related source files.

Put compile guards around socket-related source files such that they
do not get compiled if sockets are disabled.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoFix some compilation errors and warnings that are generated with nolibc
Costin Lupu [Thu, 29 Aug 2019 14:07:14 +0000 (17:07 +0300)]
Fix some compilation errors and warnings that are generated with nolibc

As the title says, this should be tested with nolibc.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoDeclare mem_* functions only for lwip internal use
Felipe Huici [Tue, 27 Aug 2019 11:13:55 +0000 (13:13 +0200)]
Declare mem_* functions only for lwip internal use

Openssl has its own mem_* functions declarations, which differ from the lwip
ones. Therefore we enable the lwip declarations only for lwip code.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoDefine getaddrinfo() and freeaddrinfo() as functions instead of wrappers
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.

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agonetdb.h: Add getservbyname() and getservbyport() declarations
Costin Lupu [Fri, 16 Aug 2019 07:09:43 +0000 (10:09 +0300)]
netdb.h: Add getservbyname() and getservbyport() declarations

The stubs were already defined, but the declarations were missing.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agolwipopts.h: Use libc ioctl.h if available
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.

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdapt getnameinfo() function to Unikraft
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>
5 years agoImport getnameinfo() function from OsV
Costin Lupu [Fri, 16 Aug 2019 07:09:39 +0000 (10:09 +0300)]
Import getnameinfo() function from OsV

Copied as it is from official OsV git mirror
https://github.com/cloudius-systems/osv.git, commit ee7a2cd4.

Original file location: libc/network/getnameinfo.c

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd getaddrinfo() wrapper
Bogdan Lascu [Fri, 2 Aug 2019 12:57:40 +0000 (15:57 +0300)]
Add getaddrinfo() wrapper

... and freeaddrinfo() and gai_strerror().

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>