Date: Thu, 30 Apr 2020 18:40:37 +0200 From: Steffen Christgau <mail@s14u.de> To: freebsd-net@freebsd.org Subject: Notification about tentative IPv6 address from route socket Message-ID: <4f3a314a-f938-476b-f75e-e495756a5488@s14u.de>
next in thread | raw e-mail | index | archive | help
Hi everybody, I'm quiet new in developing applications with support for FreeBSD, so please excuse if that question has an obvious answer which I can't see at the moment. I'm developing a small daemon which should detect and handle changes of IP addresses in order to open new sockets and close them when addresses come and go. I implemented this so far by using PF_ROUTE sockets on FreeBSD 12.1. This works quiet well and I'm able to see additions and deletions of addresses. For IPv6, however, I get notified about an address which is tentative (I use ifconfig to add an link-local address manually) and I - understandably - cannot bind a socket to that address. While I assume that I can check for the address being tentative with ioctl(fd, SIOCGIFAFLAG_IN6, ...), I'd like to ask the following: 1) Is there a way to get notified about the address being available for usage (i.e. not tentative anymore, not duplicated) without _polling_ via ioctl? My application is currently almost completely event driven and integrating such a repeated timeout based detection of tentative/duplicated addresses appears a little awkward. In addition blocking until the address state changes is not really an option. 2) I know FreeBSD is not Linux, but on Linux with netlink sockets I get notified about a) the address appearing (including flags) and b) some time later the address being not tentative anymore (detectable via flags). I wonder why the route socket on FreeBSD reports an address that is currently hardly to use. On the other hand, I understand that RTM_NEWADDR does exactly what is documented, i.e. to notify about an "address being added to iface". Nevertheless, wouldn't it make sense to tell an application that a change for an address takes place? I couldn't observe such a behavior for IPv6 on FreeBSD. If there is currently no really such notification, the kernel could emit a new message like RTM_ADDRCHANGE or it may repeats the emission of RTM_NEWADDR (which might confuse existing applications). Also the addition of an address flags field to ifa_msghdr message might be beneficial. It would also avoid additional ioctl calls and the boilerplate required around that. Just thinking aloud... However, if there is already a notification-based mechanism to get informed about a ready-to-use IPv6 address, could you please provide me a pointer to that? Looking forward for your responses. Regards, Steffen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4f3a314a-f938-476b-f75e-e495756a5488>