Asynchronous user-space notification of interface address changes?

Ian Lepore ian at FreeBSD.org
Wed Dec 4 15:34:20 UTC 2013


On Wed, 2013-12-04 at 10:18 +0100, Matthias Andree wrote:
> Greetings,
> 
> is there any sensible way to have a user-space application notified of
> interface address changes (in the light of - but not limited to - IPv6
> automatic configuration, with accept_rtadv or similar), preferably
> without the application polling getifaddrs every five-ish seconds?
> 
> It does not appear kevent/kqueue, or devctl, are up to the task.
> 
> I am not asking for turnkey solutions (although I'll gladly take them),
> a rough sketch or pointers will suffice.
> 
> Thanks.
> 
> Best regards
> Matthias

Open a routing socket, select/poll for readability, handle incoming
RTM_NEWADDR/RTM_DELADDR messages.  Example code in dhclient and faithd
and I think ntpd among others.  Some info available in man 4 route.
I've never done this, just remember seeing the code for it in dhclient.

-- Ian




More information about the freebsd-hackers mailing list