Skip to content

[SUBISSUE #2] Implement AF_NETLINK Sockets (NETLINK_ROUTE and NETLINK_KOBJECT_UEVENT) #296

Todo

Description

@marcobuschini

Parent Issue / Epic

#283 (Epic #265)

Prerequisite Sub-Issue

#295

Atomic Deliverable & Implementation Details

Add minimal AF_NETLINK socket support needed by ip/ss, libudev, and Wayland/DRM device enumeration tools:

  • kernel/uapi/socket.hpp: Define AF_NETLINK (16), NETLINK_ROUTE (0), NETLINK_KOBJECT_UEVENT (15), linux_sockaddr_nl (12 bytes), and linux_nlmsghdr (16 bytes) with static_assert checks.
  • kernel/net/: Implement NetlinkSocket backing NETLINK_ROUTE (RTM_GETLINK, RTM_GETADDR returning lo and eth0 metadata) and NETLINK_KOBJECT_UEVENT multicast group subscription/notification.
  • kernel/syscalls/SocketSyscalls.cpp: Dispatch AF_NETLINK through socket, bind, getsockname, sendto/recvfrom, sendmsg/recvmsg, and poll/epoll.
  • tests/host/: Add Snitch ASan/UBSan unit tests covering NETLINK_ROUTE dumps, NLM_F_DUMP/NLMSG_DONE framing, NETLINK_KOBJECT_UEVENT delivery, and cleanup.

Out of scope: dynamic kernel route table mutation (RTM_NEWROUTE) or mount/chroot ([SUBISSUE #3]).

Acceptance Criteria & Edge Cases

  • RTM_GETLINK and RTM_GETADDR queries return valid NLMSG_ALIGN-padded nlmsghdr responses terminated by NLMSG_DONE
  • NETLINK_KOBJECT_UEVENT sockets bind to uevent groups cleanly and integrate with poll/epoll
  • Invalid netlink protocols or truncated messages return negated errno (-EPROTONOSUPPORT, -EINVAL) with zero leaks
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

ipcsubissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions