unikraft / lib-lwip Goto Github PK
View Code? Open in Web Editor NEWUnikraft port of the lwip network stack
Unikraft port of the lwip network stack
When building with Musl, an error is printed due to missing __unused
symbol:
CClibmuslglue:__set_thread_area.o
LDlibmuslglue.ld.o
OBJCOPYlibmuslglue.o
CCliblwip:alloc.unikraft.o
CCliblwip:proto.o
CCliblwip:host.o
CCliblwip:serv.o
/home/razvan/projects/unikraft/scripts/unikraft-musl/libs/lwip/serv.c:40:48:error:expected‘;’,‘,’or‘)’before‘__unused’
structservent*getservbyname(constchar*name__unused,
^~~~~~~~
/home/razvan/projects/unikraft/scripts/unikraft-musl/libs/lwip/serv.c:46:40:error:expected‘;’,‘,’or‘)’before‘__unused’
structservent*getservbyport(intport__unused,
^~~~~~~~
/home/razvan/projects/unikraft/scripts/unikraft-musl/libs/lwip/serv.c:52:30:error:expected‘;’,‘,’or‘)’before‘__unused’
intgetservbyport_r(intport__unused,constchar*prots__unused,
^~~~~~~~
make[2]:***[/home/razvan/projects/unikraft/scripts/unikraft-musl/apps/app-helloworld/build/liblwip/serv.o]Error1
/home/razvan/projects/unikraft/scripts/unikraft-musl/unikraft/support/build/Makefile.build:27:recipefortarget'/home/razvan/projects/unikraft/scripts/unikraft-musl/apps/app-helloworld/build/liblwip/serv.o'failed
make[1]:***[sub-make]Error2
Makefile:1016:recipefortarget'sub-make'failed
make:***[_all]Error2
Makefile:32:recipefortarget'_all'failed
When spamming Unikraft HTTPserver with lots of request using curl, the server eventually gets stuck. By inspecting the pcap in Wireshark, we would see last connection would try to "TCP Port reuse" in this case.
Alternatively, instead of spaming with connections, we have a more consistent way to replicate the bug. By using --local-port 42000
(or whatever port) option in curl
and just do three requests we would see a similar behaviour (but without all the clutter before Unirkaft gets stuck): first curl would work just fine. The second one will fail with the message "bind failed with errno 98: Address already in use" (or errno 7 "Failed to connect to 172.44.0.2 port 8123: Connection refused", depending on Unikraft version). After that point all other requests would get stuck.
The cause could be that LWIP does not have support for SO_REUPOSRT
flag and tries to reuse the TCP port by default. Something that helped a bit was enabling LWIP_SO_LINGER
and setting the SO_LINGER
with timeout 0 on the socket. By doing so, we'de get back the response, but the connection is still weird. After receiving the response, the connection would be force reset: curl: (56) Recv failure: Connection reset by peer
.
The function socket.socketpair() is not yet supported.
AFAIR, most of the work has already been done.
Does anyone know the status of this activity?
With Unikraft 0.15, when building unikraft/app-wamr (target: wamr-qemu-x86_64-initrd (qemu/x86_64))
, the following error occurred:
<prefix>/libs/lwip/init.c:330:43: error: macro "uk_lib_initcall" passed 2 arguments, but takes just 1
W 330 | uk_lib_initcall(liblwip_init, liblwip_term);
W | ^
W In file included from <prefix>/libs/lwip/init.c:47:
W <prefix>/unikraft/include/uk/init.h:115: note: macro "uk_lib_initcall" defined here
Source:
lwip/init.c:330
uk_lib_initcall(liblwip_init, liblwip_term);
unikraft/include/uk/init.h:115
#define uk_lib_initcall(fn) uk_lib_initcall_prio(fn, UK_PRIO_LATEST)
on the old 0.9.0 release i'm working on, unikraft has renamed a variable, but lib-lwip has not done so yet. The following patch fixes this. You may want to check if this fix is still needed on current staging/master/0.10.0.
pogobanane@bd92210
I compile the following to send ICMP packets:
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#define ICMP_ECHO 8 /* Echo Request */
int main() {
struct sockaddr_in to;
memset(&to, 0, sizeof(to));
to.sin_family = AF_INET;
//to.sin_addr.s_addr = inet_addr("172.44.0.3");
to.sin_addr.s_addr = inet_addr("1.1.1.1");
to.sin_port = 0;
char packet[150] = { 0 };
packet[0] = ICMP_ECHO;
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
while (1) {
int r = sendto(fd, packet, sizeof(packet), 0, (struct sockaddr *)&to, sizeof(to));
printf("%d %d\n", r, errno);
sleep(4);
}
}
with: gcc -static-pie -fPIC -Wall -o icmp_test icmp_test.c
$ sudo tcpdump -nn -v -i wlp3s0 host 1.1.1.1
tcpdump: listening on wlp3s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
17:26:30.999548 IP (tos 0x0, ttl 64, id 25840, offset 0, flags [DF], proto ICMP (1), length 170)
${my_ip} > 1.1.1.1: ICMP echo request, id 25, seq 0, length 150
...
../../run-app-elfloader/run_elfloader -r rootfs/ -k build/*_kvm-x86_64 -n icmp_test
,[ 6.461028] dbg: [liblwip] <ip4.c @ 1097> IP header:
[ 6.463983] dbg: [liblwip] <ip4.c @ 1098> +-------------------------------+
[ 6.467685] dbg: [liblwip] <ip4.c @ 1099> | 4 | 5 | 0x00 | 178 | (v, hl, tos, len)
[ 6.472054] dbg: [liblwip] <ip4.c @ 1104> +-------------------------------+
[ 6.475470] dbg: [liblwip] <ip4.c @ 1105> | 22 |000| 0 | (id, flags, offset)
[ 6.480519] dbg: [liblwip] <ip4.c @ 1111> +-------------------------------+
[ 6.484549] dbg: [liblwip] <ip4.c @ 1112> | 255 | 17 | 0x0cf5 | (ttl, proto, chksum)
[ 6.489074] dbg: [liblwip] <ip4.c @ 1116> +-------------------------------+
[ 6.493351] dbg: [liblwip] <ip4.c @ 1117> | 172 | 44 | 0 | 2 | (src)
[ 6.498078] dbg: [liblwip] <ip4.c @ 1122> +-------------------------------+
[ 6.501923] dbg: [liblwip] <ip4.c @ 1123> | 1 | 1 | 1 | 1 | (dest)
[ 6.505931] dbg: [liblwip] <ip4.c @ 1128> +-------------------------------+
I can't see any references to IPPROTO_ICMP
in this repo (when built), so I guess that's why.
When remaking my lwip-using unikernel on a new computer the build terminated on this error:
/home/akira/avar_src/app-mongod403/w/libs/lwip/init.c: In function ‘liblwip_init’:
/home/akira/avar_src/app-mongod403/w/libs/lwip/init.c:402:58: error: passing argument 2 of ‘dns_setserver’ from incompatible pointer type [-Wincompatible-pointer-types]
402 | dns_setserver(nb_dns4++, &dns4);
| ^~~~~
| |
| ip4_addr_t * {aka struct ip4_addr *}
It appears that gcc version >= 14 will make -Wincompatible-pointer-types
an error instead of warning by default: https://gcc.gnu.org/gcc-14/porting_to.html
My workaround for now is simply to add -Wno-incompatible-pointer-types
(or -Wno-error=incompatible-pointer-types
?) to the LIBLWIP_CFLAGS line in lwip's Makefile.uk
.
Port the lwip tests to use uktest, the Unikraft testing API.
You can follow the libsodium ported tests as an example and check the USoC testing session for support.
Check the website and the uktest
README and api for instructions on how to write tests.
Hackathon points: 40 points per test suite (e.g. 40 points for porting test/unit/dhcp
).
When building with Musl and enabling ipv6
, the build fails with this error:
liblwip/origin/fork-lwip-UNIKRAFT-2_1_x/src/include/lwip/inet.h:155:82: error: ‘struct in6_addr’ has no member named ‘un’
155 | #define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \
The definition of struct in6_addr
in lwip's in.h
is overriten by the definition in musl's in.h
, wich does not include any member named un
.
This happens in case musl
is places before lwip
in the Makefile
.
Changing the order of the libraries does not seem to work here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.