{"record":{"id":"d88598c6bc176568","repo":"ruvnet/RuView","slug":"enomem-d88598","errorCode":"ENOMEM","errorMessage":"veil: nl_socket_alloc failed\n","messagePattern":"veil: nl_socket_alloc failed\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wifi-veil/firmware/openwrt/veil_shieldd.c","lineNumber":71,"sourceCode":"    struct nl_sock *sock;   /* generic-netlink socket to nl80211            */\n    int             family; /* resolved \"nl80211\" genl family id           */\n    int             ifindex;/* target AP interface (e.g. phy0-ap0)         */\n    uint64_t        key;    /* shared session key for the keyed rotation    */\n    size_t          passes; /* Givens passes                                */\n    volatile sig_atomic_t running;\n};\n\nstatic struct veil_ctx g_ctx;\n\nstatic void on_signal(int sig) { (void)sig; g_ctx.running = 0; }\n\n/* ---------------------------------------------------------------------- */\n/* nl80211 bring-up — all REAL libnl-genl-3 API names.                     */\n/* ---------------------------------------------------------------------- */\nstatic int veil_nl_connect(struct veil_ctx *c) {\n    c->sock = nl_socket_alloc();\n    if (!c->sock) {\n        fprintf(stderr, \"veil: nl_socket_alloc failed\\n\");\n        return -ENOMEM;\n    }\n    if (genl_connect(c->sock)) {\n        fprintf(stderr, \"veil: genl_connect failed\\n\");\n        return -EIO;\n    }\n    c->family = genl_ctrl_resolve(c->sock, \"nl80211\");\n    if (c->family < 0) {\n        fprintf(stderr, \"veil: genl_ctrl_resolve(nl80211) failed: %d\\n\",\n                c->family);\n        return c->family;\n    }\n    /* Observe MLME events (auth/assoc, and — where the driver forwards them —\n     * action-frame notifications). Real multicast group name is \"mlme\". */\n    int grp = genl_ctrl_resolve_grp(c->sock, \"nl80211\", \"mlme\");\n    if (grp >= 0) {\n        (void)nl_socket_add_membership(c->sock, grp);\n    }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/wifi-veil/firmware/openwrt/veil_shieldd.c#L53-L89","documentation":"Identical daemon, vendored copy: `wifi-veil/` is the standalone workspace and its `firmware/openwrt/veil_shieldd.c` is byte-identical to `firmware/privshield/openwrt/veil_shieldd.c`. `veil_nl_connect` allocates a libnl socket with `nl_socket_alloc()`; a NULL return maps to `-ENOMEM`, aborting bring-up before any netlink traffic. The cause is heap exhaustion or a memory rlimit, not the netlink subsystem itself.","triggerScenarios":"Memory-constrained target at boot; cgroup/`ulimit -v` caps on the daemon; supervisor restart loops under OOM pressure; ABI-mismatched libnl runtime.","commonSituations":"Small-RAM OpenWrt devices; zram absent and many services enabled; binaries built against one libnl3 version and run against another.","solutions":["Free memory or raise limits (stop unneeded services, install zram-swap, raise the cgroup cap) and restart.","Check `dmesg` for OOM-killer activity around the start time.","Verify `ldd` on this copy's binary matches the libnl3/libnl-genl3 packages present."],"exampleFix":"# before\n./veil_shieldd -i 2        # veil: nl_socket_alloc failed\n# after\nulimit -v unlimited; /etc/init.d/veil_shieldd restart","handlingStrategy":"validation","validationCode":"/* headroom check before daemon start */\n#include <sys/resource.h>\nstatic int heap_headroom_ok(void) {\n    struct rlimit rl;\n    if (getrlimit(RLIMIT_AS, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY\n        && rl.rlim_cur < (32ull << 20)) return 0;\n    return 1;\n}","typeGuard":null,"tryCatchPattern":"if (veil_nl_connect(&g_ctx) != 0) {\n    fprintf(stderr, \"veil: bring-up failed (memory?) — restarting via procd\\n\");\n    return 1; /* let the supervisor respawn with thresholds */\n}","preventionTips":["Run under procd with respawn thresholds; enable zram on small targets.","Match libnl3 runtime packages to the build SDK (check with ldd).","Prefer building this vendored copy from the same workspace version you deploy."],"tags":["c","openwrt","nl80211","libnl","memory","daemon-startup"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}