nx_udp_rv.nx
buildroot/runtime/nx_udp_rv.nx
about
nx_udp_rv.nx -- native-lane UDP socket primitives.
Twin of nx_udp.nx, but imports nx_syscalls.nx (RV64-numbered, @ifdef
TARGET_X86_64) instead of nx_syscalls_x86_64.nx (raw x86_64 numbers).
WHY THIS EXISTS: the native compiler (_offc/nx_compile_x86_native.elf)
translates RV64 syscall numbers -> x86_64 at codegen time
(nx_x86_64_ctx.nx: 198->41 socket, 200->49 bind, 206->44 sendto,
207->45 recvfrom, 73->7 poll, ...). Code that feeds it raw x86_64
numbers (nx_udp.nx -> nx_syscalls_x86_64.nx) hits a collision:
x86_64 socket=41 == RV64 unshare=41, so socket() silently became
unshare() and every UDP daemon died with -EINVAL before its banner.
This is the same syscall-duality class as the documented
fork()->openat() leak. Using nx_syscalls.nx (which yields RV64
numbers when TARGET_X86_64 is undefined, i.e. the native lane) makes
the translation correct. This is the recipe the gated nx_netscope
UDP code already uses successfully on the native lane.
Use nx_udp_rv.* for daemons built via the native lane; use nx_udp.*
for the nxc2.exe --target x86_64 (non-translating) lane.
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_media_transport.nxnx_route_probe.nx
structs
| none |
consts
| none |
functions
| 25 | func nx_udpr_open() -> i64 calls 1: sys_socket |
| 30 | func nx_udpr_sa_any(out: *u8, port: i64) -> i64 called by 1: nx_udpr_bind_any |
| 40 | func nx_udpr_bind_any(fd: i64, port: i64) -> i64 |
| 47 | func nx_udpr_sa_dest(out: *u8, a: i64, b: i64, c: i64, d: i64, port: i64) -> i64 |
| 58 | func nx_udpr_send(fd: i64, buf: *u8, n: i64, addr16: *u8) -> i64 |
| 64 | func nx_udpr_recv(fd: i64, buf: *u8, n: i64, from: *u8, fromlen: *i64) -> i64 |