]> xenbits.xensource.com Git - unikraft/libs/lwip.git/log
unikraft/libs/lwip.git
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>
5 years agoAdd inet_ntop(), inet_pton() functions
Bogdan Lascu [Fri, 2 Aug 2019 12:57:39 +0000 (15:57 +0300)]
Add inet_ntop(), inet_pton() functions

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 agoFurther protect gethostbyname* defines
Mihai Pogonaru [Sat, 29 Jun 2019 13:55:01 +0000 (16:55 +0300)]
Further protect gethostbyname* defines

lwip_gethostbyname and lwip_gethostbyname_r definitions are protected
by LWIP_DNS && LWIP_SOCKET

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoProvide ioctl for LWIP
Mihai Pogonaru [Sat, 29 Jun 2019 13:55:00 +0000 (16:55 +0300)]
Provide ioctl for LWIP

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agosockets.c: Change error handling to match vfs expectations
Mihai Pogonaru [Sat, 29 Jun 2019 13:54:59 +0000 (16:54 +0300)]
sockets.c: Change error handling to match vfs expectations

vfs expects file system functions (vnops) to return 0 on success
(and update the uio structure) or a positive error number
in case of an error.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoUse vfs functions to allocate/free the resources used for a socket (Part II)
Mihai Pogonaru [Sat, 29 Jun 2019 13:54:58 +0000 (16:54 +0300)]
Use vfs functions to allocate/free the resources used for a socket (Part II)

This part changes LWIP so that it uses vfs functions to allocate the
dentry and vnode used for sockets.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoUpdate the number of remaining unprocessed bytes correctly
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>
5 years agoUse vfs functions to allocate/free the resources used for a socket (Part I)
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>
5 years agoFix poll() ret variable type and select() maxfd calculation
Mihai Pogonaru [Wed, 26 Jun 2019 01:54:32 +0000 (04:54 +0300)]
Fix poll() ret variable type and select() maxfd calculation

Poll ret variable must be declared as int
Select must calculate maxfd as the maximum between lwip file descriptors

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd getservbyname and getservbyport stubs
Vlad-Andrei BĂDOIU (78692) [Tue, 25 Jun 2019 16:32:46 +0000 (16:32 +0000)]
Add getservbyname and getservbyport stubs

This patch adds a new file serv.c which holds the getserv* functions. Currently,
only the getservbyname and getservbyport are available.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd gethostbyaddr stub
Vlad-Andrei BĂDOIU (78692) [Tue, 25 Jun 2019 16:32:46 +0000 (16:32 +0000)]
Add gethostbyaddr stub

This patch adds a new file host.c that holds host related functions. For now,
gethostbyaddr is available.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd proto* functions
Vlad-Andrei BĂDOIU (78692) [Tue, 25 Jun 2019 16:32:45 +0000 (16:32 +0000)]
Add proto* functions

This patch adds endprotoent, setprotoent, getprotoent, getprotobyname and
getprotobynumber from musl.

tag: v1.1.14
commit <074e6b3fe3f2ad89b991f3d8ab0932035b312a62>

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoinclude/netinet/tcp.h: Remove TCP_MSS definition
Costin Lupu [Sun, 23 Jun 2019 18:25:04 +0000 (21:25 +0300)]
include/netinet/tcp.h: Remove TCP_MSS definition

TCP_MSS definition is already provided by lwipopts.h.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoProvide gethostbyname and gethostbyname_r
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>
5 years agoExport additional symbols
Vlad-Andrei BĂDOIU (78692) [Tue, 11 Jun 2019 01:08:58 +0000 (01:08 +0000)]
Export additional symbols

This patch adds ip4addr_aton, ip4addr_ntoa, ipaddr_addr, ip4addr_ntoa
and h_errno to exportsyms.uk.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd netinet/tcp.h
Vlad-Andrei BĂDOIU (78692) [Tue, 11 Jun 2019 01:08:57 +0000 (01:08 +0000)]
Add netinet/tcp.h

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd SOCK_SEQPACKET in socket.h
Vlad-Andrei BĂDOIU (78692) [Tue, 11 Jun 2019 01:08:56 +0000 (01:08 +0000)]
Add SOCK_SEQPACKET in socket.h

This patch adds the missing SOCK_SEQPACKET to include/socket.h.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd servent and protoent
Vlad-Andrei BĂDOIU (78692) [Thu, 6 Jun 2019 16:39:03 +0000 (16:39 +0000)]
Add servent and protoent

This patch adds the definition of servent and protoent to netdb.h since it is
missing from lwip/netdb.h .

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoFix select and poll wrappers
Mihai Pogonaru [Mon, 3 Jun 2019 19:45:46 +0000 (22:45 +0300)]
Fix select and poll wrappers

Select/poll should return the lwip_select/poll result and release the vfscore_file after each access

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoProvide poll() and select() wrappers around lwip versions
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>
5 years agosockets.c: Refuse to deal with non-sockets
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>
5 years agoProvide lwip socket function interfaces unconditionally
Florian Schmidt [Mon, 20 May 2019 11:29:49 +0000 (13:29 +0200)]
Provide lwip socket function interfaces unconditionally

Considering newlib, as compiled for unikraft, does not provide a socket
API, these should always be provided, not only when nolibc is used.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoDon't provide file status flags when we have a libc
Florian Schmidt [Mon, 20 May 2019 11:29:48 +0000 (13:29 +0200)]
Don't provide file status flags when we have a libc

Instead, trust that they will show up during compilation, just maybe a
bit later. Otherwise, we might very well end up with conflicting
definitions for the values of these flags.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoProvide ioctl
Florian Schmidt [Mon, 20 May 2019 11:29:47 +0000 (13:29 +0200)]
Provide ioctl

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoProvide netinet/in.h
Florian Schmidt [Mon, 20 May 2019 11:29:46 +0000 (13:29 +0200)]
Provide netinet/in.h

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosys/socket.h: Include some libc header files first if available
Florian Schmidt [Mon, 20 May 2019 11:29:45 +0000 (13:29 +0200)]
sys/socket.h: Include some libc header files first if available

In that case, lwip won't try to be helpful and provide conflicting
fallback definitions (which lead to a lot of compiler warnings).

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMove export.syms to exportsyms.uk
Florian Schmidt [Mon, 20 May 2019 11:29:44 +0000 (13:29 +0200)]
Move export.syms to exportsyms.uk

This file was ignored up to now because it followed a superseded naming
standard. This patch also adds lwip_htonl, lwip_htons, and lwip_select
to exportsyms.uk, because those are known to be used by applications,
and provided via #defines of their non-prefixed versions.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoliblwip: Remove vfscore_put_fd from socket_close
Sharan Santhanam [Mon, 27 May 2019 13:00:33 +0000 (15:00 +0200)]
liblwip: Remove vfscore_put_fd from socket_close

This patch fixes a bug in the function sock_net_close. The close
function frees up a descriptor that was removed by fdrop. The fdrop
function invokes the close callback after it had removed the fd
from its list.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
5 years agoAdopt to latest libuklock, libukmpi changes
Simon Kuenzer [Wed, 8 May 2019 09:54:53 +0000 (11:54 +0200)]
Adopt to latest libuklock, libukmpi changes

lwip's semaphores are implemented based on semphores provided by
libuklock and lwip's mailboxes are implemented based on mailboxes
provided by libukmpi. The API of both have changed recently;
originally with commit a48d634 ("lib/uklock: Use timeout equal to 0
for trying down a semaphore"): A passed timeout of `0` is now
immediately returning instead of blocking the current thread until the
according event happened.

This patch also depends on the Unikraft patch 734930 ("lib/ukmpi:
Provide blocking uk_mbox_recv()"):
  https://patchwork.unikraft.org/patch/734930/

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agosockets: add prefix to FWRITE and FREAD RELEASE-0.3.1
Yuri Volchkov [Tue, 5 Mar 2019 13:53:15 +0000 (14:53 +0100)]
sockets: add prefix to FWRITE and FREAD

These are internal vfscore flags. And they got prefixes
recently. Update lwip to match them

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agosockets: Adopt to updated vfscore RELEASE-0.3
Simon Kuenzer [Wed, 20 Feb 2019 13:38:51 +0000 (14:38 +0100)]
sockets: Adopt to updated vfscore

Adopts the sockets glue implementation to the updated vfscore library.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agouknetdev_output: Fix loop iterator
Florian Schmidt [Mon, 18 Feb 2019 09:30:26 +0000 (10:30 +0100)]
uknetdev_output: Fix loop iterator

Setting q to p->next leads to an infinite loop if p has at least two
segments. The correct way is to iterate over q so we actually progress
through the list.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agoNetif status print callback
Simon Kuenzer [Thu, 7 Feb 2019 23:00:35 +0000 (00:00 +0100)]
Netif status print callback

Introduce a status print hook to all netifs operated by the lwIP
stack. State changes (e.g., assigning of an IP, bringing device up or
down) are printed to the standard console. Because the stack is not
printing any message to the console with the default configuration, we
enable this print hook as default.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAttach uknetdev netifs during boot
Simon Kuenzer [Thu, 7 Feb 2019 23:00:34 +0000 (00:00 +0100)]
Attach uknetdev netifs during boot

Scan for uknetdev devices and attach them automatically to the lwIP
stack during initialization. If DHCP support is enabled, the stack
will query for an address on the interfaces.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoNetif driver for libuknetdev devices
Simon Kuenzer [Thu, 7 Feb 2019 23:00:33 +0000 (00:00 +0100)]
Netif driver for libuknetdev devices

Introduces a netif driver for libuknetdev devices. Packet buffers are
allocated on the heap for now. Receive interrupts are supported and
enabled when lwIP is operated in "threaded" mode. Zero-copy receive is
implemented with packet buffers having two personalities: pbuf and netbuf.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoUpdate to lwIP 2.1.2
Simon Kuenzer [Thu, 7 Feb 2019 23:00:32 +0000 (00:00 +0100)]
Update to lwIP 2.1.2

Update lwIP from 2.0.3 to the latest relase 2.1.2 from Dec 2018. We
transform the rather beta state of our glue library to a more stable
implementation based on the latest staging branch of Unikraft towards
release 0.3.

This commit provides the following features as selectable options from
lwIP:
- Two operation modes: "threaded" or as (part of a) "mainloop"
- IPv4 support
- Experimental IPv6 support (incomplete)
- Protocols: UDP, TCP, ICMP, IGMP, SNMP
- DNS resolver
- DHCPv4 client
- Socket API

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAdd .gitignore
Simon Kuenzer [Thu, 7 Feb 2019 23:00:31 +0000 (00:00 +0100)]
Add .gitignore

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoExpose socket header & disable socket polling
Sharan Santhanam [Fri, 15 Jun 2018 20:53:48 +0000 (22:53 +0200)]
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 <sharan.santhanam@neclab.eu>
6 years agoUpdate to latest libukmpi and libuklock configuration system
Sharan Santhanam [Fri, 15 Jun 2018 10:06:42 +0000 (12:06 +0200)]
Update to latest libukmpi and libuklock configuration system

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement getsockname(), getperrname() and sock options
Sharan Santhanam [Wed, 13 Jun 2018 00:26:33 +0000 (02:26 +0200)]
Implement getsockname(), getperrname() and sock options

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement closing of sockets descriptor with libvfscore
Sharan Santhanam [Wed, 13 Jun 2018 00:24:57 +0000 (02:24 +0200)]
Implement closing of sockets descriptor with libvfscore

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement read and write operation for sockets with libvfscore
Sharan Santhanam [Wed, 13 Jun 2018 00:23:31 +0000 (02:23 +0200)]
Implement read and write operation for sockets with libvfscore

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement accept(), listen(), and connect() for libvfscore
Sharan Santhanam [Wed, 13 Jun 2018 00:21:22 +0000 (02:21 +0200)]
Implement accept(), listen(), and connect() for libvfscore

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement bind() for libvfscore
Sharan Santhanam [Wed, 13 Jun 2018 00:17:45 +0000 (02:17 +0200)]
Implement bind() for libvfscore

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoImplement socket() for libvfscore
Sharan Santhanam [Tue, 12 Jun 2018 22:46:01 +0000 (00:46 +0200)]
Implement socket() for libvfscore

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAdd prototype for libvfscore for Sockets
Simon Kuenzer [Thu, 14 Jun 2018 23:14:08 +0000 (01:14 +0200)]
Add prototype for libvfscore for Sockets

Initial implementation for integrating Sockets to libvfscore
in Unikraft.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAdopt to new configuration variable name scheme of Unikraft
Simon Kuenzer [Thu, 14 Jun 2018 23:13:10 +0000 (01:13 +0200)]
Adopt to new configuration variable name scheme of Unikraft

Adopts to the new configuration variable name scheme introduced
with latest Unikraft build system (see patch de27b01: "build:
add prefix CONFIG_ to every kconfig symbol")

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAdopt to new Unikraft libraries: libukmpi and libuklock
Sharan Santhanam [Fri, 8 Jun 2018 13:01:11 +0000 (15:01 +0200)]
Adopt to new Unikraft libraries: libukmpi and libuklock

Add dependency to libukmpi and libuklock libraries that were
recently introduced with Unikraft.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoConvert patches from p0 to p1 format
Simon Kuenzer [Fri, 15 Jun 2018 01:19:49 +0000 (03:19 +0200)]
Convert patches from p0 to p1 format

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoEnable menu-based configuration of sockets and IPv6
Sharan Santhanam [Thu, 7 Jun 2018 13:50:56 +0000 (15:50 +0200)]
Enable menu-based configuration of sockets and IPv6

Removes the hardcoded and enabled lwIP options for sockets and IPv6 that
actually can be configured using Config.uk

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoAdhering to uksched API for thread creation
Sharan Santhanam [Wed, 13 Jun 2018 13:41:46 +0000 (15:41 +0200)]
Adhering to uksched API for thread creation

sys_thread_new was unnecessarily using a static allocated variable for
creating a thread. On failure, uk_printd() was called without specifying
a level which fails. Additonally the code style of this function is updated.

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoCorrect handling of mailbox return values on post and recv
Yuri Volchkov [Wed, 11 Apr 2018 09:07:11 +0000 (11:07 +0200)]
Correct handling of mailbox return values on post and recv

uk_mbox_mt_post_try and uk_mbox_mt_recv_try return a value
smaller than 0 in case of errors.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>