From owner-freebsd-net@freebsd.org Sun May 3 08:42:13 2020 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DD40F2D8043 for ; Sun, 3 May 2020 08:42:13 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward500o.mail.yandex.net (forward500o.mail.yandex.net [37.140.190.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49FKH745LXz4Qmg for ; Sun, 3 May 2020 08:42:10 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from mxback12o.mail.yandex.net (mxback12o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::63]) by forward500o.mail.yandex.net (Yandex) with ESMTP id 5F560602ED; Sun, 3 May 2020 11:42:08 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback12o.mail.yandex.net (mxback/Yandex) with ESMTP id Q1qZiVptDn-g7jWLDCl; Sun, 03 May 2020 11:42:07 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1588495327; bh=fDpYQtSeXknnvl3HkajWlEbWaruzo3SsI7yN7h3icxw=; h=Message-Id:Subject:In-Reply-To:Date:References:To:From; b=HwCelyX2muKx9jZBOU/X8hoEbGbsoDw7ZUiyldlvqnZlgz3gKcM7j5aY/jk9WowU6 fc3U9ATpzYGTc4PFzxOvVyC6wf3Nst1ktuefGQKfwH+FySx9v01555/aLM1MjgBj3k 31ULtNDJg8u6Y80Q9FeTu/ZPYbNTXQxL0cFIBhWU= Received: by myt4-d12e6d6cc867.qloud-c.yandex.net with HTTP; Sun, 03 May 2020 11:42:07 +0300 From: Alexander V. Chernikov Envelope-From: melifaro@ipfw.ru To: Steffen Christgau , "freebsd-net@freebsd.org" In-Reply-To: <4f3a314a-f938-476b-f75e-e495756a5488@s14u.de> References: <4f3a314a-f938-476b-f75e-e495756a5488@s14u.de> Subject: Re: Notification about tentative IPv6 address from route socket MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Sun, 03 May 2020 09:42:07 +0100 Message-Id: <718441588495188@mail.yandex.ru> Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Rspamd-Queue-Id: 49FKH745LXz4Qmg X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ipfw.ru header.s=mail header.b=HwCelyX2; dmarc=none; spf=pass (mx1.freebsd.org: domain of melifaro@ipfw.ru designates 37.140.190.195 as permitted sender) smtp.mailfrom=melifaro@ipfw.ru X-Spamd-Result: default: False [-4.04 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[ipfw.ru:s=mail]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:37.140.128.0/18]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; RCVD_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[ipfw.ru:+]; RCPT_COUNT_TWO(0.00)[2]; IP_SCORE(-1.74)[ipnet: 37.140.128.0/18(-4.88), asn: 13238(-3.85), country: RU(0.01)]; FORGED_SENDER(0.30)[melifaro@freebsd.org,melifaro@ipfw.ru]; RCVD_IN_DNSWL_LOW(-0.10)[195.190.140.37.list.dnswl.org : 127.0.5.1]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:13238, ipnet:37.140.128.0/18, country:RU]; FROM_NEQ_ENVFROM(0.00)[melifaro@freebsd.org,melifaro@ipfw.ru] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 08:42:13 -0000 30.04.2020, 17:40, "Steffen Christgau" : > Hi everybody, Hi Steffen, > > 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 Not that I'm aware of :-( > 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 It makes total sense. I have plans to update some rtsock internals and will take a look at this one. Thank you for your suggestion! > 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 > _______________________________________________ > freebsd-net@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"