From owner-freebsd-arch@FreeBSD.ORG Mon Apr 6 04:25:42 2009 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A96D10656C6 for ; Mon, 6 Apr 2009 04:25:42 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outE.internet-mail-service.net (oute.internet-mail-service.net [216.240.47.228]) by mx1.freebsd.org (Postfix) with ESMTP id F10B38FC1E for ; Mon, 6 Apr 2009 04:25:41 +0000 (UTC) (envelope-from julian@elischer.org) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id A8C3F961D1; Sun, 5 Apr 2009 21:25:41 -0700 (PDT) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id DD59C2D60B6; Sun, 5 Apr 2009 21:25:37 -0700 (PDT) Message-ID: <49D98461.4000002@elischer.org> Date: Sun, 05 Apr 2009 21:26:09 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 To: Robert Watson References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Rick Macklem , freebsd-arch@freebsd.org Subject: Re: getting a callback ip address for nfsv4 client X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2009 04:25:42 -0000 Robert Watson wrote: > On Mon, 30 Mar 2009, Rick Macklem wrote: > >> Well, since the last one turned out to be too easy, here's one I think >> is a little tougher... >> >> The nfsv4 client needs to know an ip address for the machine, that can >> be used by servers to do callbacks on the client. I currently use the >> following, which I know isn't correct, but usually works ok: >> >> loopb = htonl(INADDR_LOOPBACK); >> TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) { >> if (IA_SIN(ia)->sin_addr.s_addr != loopb) >> return (&(IA_SIN(ia)->sin_addr.s_addr)); >> } >> return (NULL); >> >> Now, I could just make it a constant set by an rc script (argument to >> the callback daemon or a sysctl variable), but that's a bother for >> laptops using dhcp and similar. I think allowing an argument to the >> callback daemon is a good fallback, but it would be nice if it didn't >> normally have to be set for things to work ok. >> >> Any ideas on how to do this? >> >> Thanks in advance for any help, rick ps: Part of the reason that the >> above loop doesn't seem to be good >> enough is that it requires "options VIMAGE_GLOBALS" to build. > > One possibility is to connect() a socket to the server address, then > call getsockaddr() to query what address the network stack is using. If > the connection completed, then the address could at least send packets > to the server, even if it isn't reachable from the server. > > (Obviously, kernel versions of the above...) we ended up with him doing "whatever the connect code would have done" since as he is in fact inside the kernel, he can just do the same.. > > Robert N M Watson > Computer Laboratory > University of Cambridge > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"