From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 4 15:34:20 2013 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 202FD5CD for ; Wed, 4 Dec 2013 15:34:20 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E76801911 for ; Wed, 4 Dec 2013 15:34:18 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1VoESq-0001ha-4K; Wed, 04 Dec 2013 15:34:12 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id rB4FY9xG021978; Wed, 4 Dec 2013 08:34:09 -0700 (MST) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19dBZ6b1ltkYnIw6dGDnLxr Subject: Re: Asynchronous user-space notification of interface address changes? From: Ian Lepore To: Matthias Andree In-Reply-To: <529EF36A.2020906@gmx.de> References: <529EF36A.2020906@gmx.de> Content-Type: text/plain; charset="us-ascii" Date: Wed, 04 Dec 2013 08:34:08 -0700 Message-ID: <1386171248.58852.78.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@FreeBSD.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Dec 2013 15:34:20 -0000 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