mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-11 02:51:10 +00:00
* fix(preload): answer NETLINK_ROUTE queries inside a session ip(8) could not run in a session: the app's SELinux domain has no netlink_route_socket bind permission, so iproute2 failed at bind and never saw the link that getifaddrs() and /proc/net already expose. Serve NETLINK_ROUTE from the same etc/droiddeck-net snapshot: an AF_UNIX socketpair backs the netlink fd, link/addr/route dumps and route get are synthesised, writes return EPERM, and multicast subscriptions keep failing with EACCES so consumers that wait for link events keep their fallback. Replies carry the port id reported by getsockname() and recvmsg() rewrites the source address to AF_NETLINK/pid 0. iproute2's dump loop requires both before it accepts a message or NLMSG_DONE; when either is missing every message is skipped silently and the process blocks in recvmsg(). * fix(preload): keep socket() and send() semantics for emulated netlink * fix(preload): deliver netlink replies with the caller's blocking mode * fix(preload): preserve NETLINK_ROUTE protocol and fd semantics - Send ACKs for successful queries and honor NETLINK_CAP_ACK - Reject unsupported subscriptions and apply socket timeouts - Track socket identity and shared references across dup and close - Support kernel connect and rewrite recvfrom source addresses - Resolve local and connected routes before default gateways - Add netlink and iproute2 regression tests * fix(preload): handle netlink request limits and socket lifecycle - Collect large sendmsg requests without falling back to UNIX sockets - Reject oversized replies explicitly instead of returning partial results - Allocate unique port IDs and reject duplicate bindings - Honor socket flags and restore inherited sockets across exec - Validate socket types and report netlink socket identity - Replace the fixed socket table with a dynamic registry - Add regression tests for batching, port conflicts and exec inheritance * fix(preload): optimize netlink tracking and support link name queries - Add lock-free fd tracking to bypass netlink locks on ordinary sockets - Move descriptor restoration to initialization and explicit discovery paths - Support RTM_GETLINK lookups via IFLA_IFNAME with correct error codes - Add regression coverage for hot-path overhead and name-based queries * fix(preload): accept unterminated netlink interface names - Copy IFLA_IFNAME into a bounded, NUL-terminated buffer before lookup - Match kernel string length validation and ERANGE errors - Add regression coverage for unterminated names and boundary cases * fix(preload): pin peers for netlink replies * fix(preload): make autobind idempotent * fix(preload): isolate forked netlink cleanup * fix(preload): avoid interposed fd scans * perf(preload): skip PID checks for untracked fds * fix(preload): verify peer before replay --------- Co-authored-by: uubooster-team <uu.booster@service.netease.com>
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
#include <errno.h>
|
|
#include <sys/socket.h>
|
|
|
|
int bl_nl_socket(int type, int *fd) {
|
|
(void)type;
|
|
*fd = -1;
|
|
errno = ENOSYS;
|
|
return 1;
|
|
}
|
|
|
|
int bl_nl_owns(int fd) {
|
|
(void)fd;
|
|
return 0;
|
|
}
|
|
|
|
int bl_nl_bind(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
|
(void)fd;
|
|
(void)addr;
|
|
(void)len;
|
|
(void)rc;
|
|
return 0;
|
|
}
|
|
|
|
int bl_nl_connect(int fd, const struct sockaddr *addr, socklen_t len, int *rc) {
|
|
return bl_nl_bind(fd, addr, len, rc);
|
|
}
|
|
|
|
int bl_nl_getsockname(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
|
(void)len;
|
|
return bl_nl_bind(fd, addr, 0, rc);
|
|
}
|
|
|
|
int bl_nl_getpeername(int fd, struct sockaddr *addr, socklen_t *len, int *rc) {
|
|
return bl_nl_getsockname(fd, addr, len, rc);
|
|
}
|
|
|
|
int bl_nl_setsockopt(int fd, int level, int option, const void *value, socklen_t len,
|
|
int (*real)(int, int, int, const void *, socklen_t), int *rc) {
|
|
(void)fd;
|
|
(void)level;
|
|
(void)option;
|
|
(void)value;
|
|
(void)len;
|
|
(void)real;
|
|
(void)rc;
|
|
return 0;
|
|
}
|
|
|
|
int bl_nl_getsockopt(int fd, int level, int option, void *value, socklen_t *len,
|
|
int (*real)(int, int, int, void *, socklen_t *), int *rc) {
|
|
(void)fd;
|
|
(void)level;
|
|
(void)option;
|
|
(void)value;
|
|
(void)len;
|
|
(void)real;
|
|
(void)rc;
|
|
return 0;
|
|
}
|