Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getifaddrs syscall #20

Open
qianxichen233 opened this issue Sep 25, 2024 · 0 comments
Open

Fix getifaddrs syscall #20

qianxichen233 opened this issue Sep 25, 2024 · 0 comments
Assignees

Comments

@qianxichen233
Copy link
Contributor

The getifaddrs syscall is not working in lind-wasm since the memory allocation to ifaddrs struct seems to be wrong. The getifaddrs syscall takes a double pointers (struct ifaddrs **ifap), and it is underlying syscall that is responsible for allocating the memory for the ifap struct. In rawposix, getifaddrs_syscall treats the ifap as an one-dimensional pointer (*mut u8), and fill the pointer with the ifaddrs from libc. The correct steps should be something like:

*buf = malloc_wasm_memory(...)
fill(*buf, &ifap_from_libc)
... (malloc_wasm_memory for next ifap struct)

The main difficuly with this approach is that, it has to malloc the wasm memory inside rawposix, but the wasm memory is managed by glibc, so it would be kind tricky to let rawposix malloc the wasm memory.

Another approach would be using the getifaddrs_internal function provided by glibc. This function does not actually use getifaddrs syscall directly, but instead used some other network syscalls to simulate the getifaddrs. Currently this approach would fail since it used bind syscall on socket type that is not directly supported by rawposix (AF_NETLINK socket). However, this is an issue in rawposix (Lind-Project/RawPOSIX#3) and will be likely fixed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants