Watch the network over netlink instead of polling operstate #122
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
NetObserver (#111) is a straight port of NetMon's mechanism: poll
/sys/class/net/*/operstateevery 2 seconds and confirm a default gateway before reporting up. It works, but it is polling -- up to 2s of latency on a transition, plus a wakeup every 2s forever.The kernel already broadcasts these events: an
RTMGRP_LINK/RTMGRP_IPV4_ROUTE/RTMGRP_IPV6_ROUTEnetlink socket would make the observer event-driven -- react on the route change itself, no sleep loop, no missed 2s window. Route messages would also replace theip -j routesubprocess calls inobserver.default_routes.Split out of #111 deliberately (poll-first port keeps that diff reviewable). Design points for whoever picks it up:
socket.AF_NETLINK(stdlib, but hand-parsing rtattr) vspyroute2(clean, but a new hard dependency across distros -- check what target distros package).ENOBUFS, re-derive state from a freshdefault_routes()read rather than trusting the event stream (an unbounded watcher that silently loses events is the upstream bug this fork exists to avoid).