From owner-freebsd-arch@FreeBSD.ORG Tue Mar 31 20:32:07 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 2D7BF10656D3 for ; Tue, 31 Mar 2009 20:32:07 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outN.internet-mail-service.net (outn.internet-mail-service.net [216.240.47.237]) by mx1.freebsd.org (Postfix) with ESMTP id 0E35D8FC18 for ; Tue, 31 Mar 2009 20:32:06 +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 C021B13DBB; Tue, 31 Mar 2009 13:32:06 -0700 (PDT) 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 8A9E92D60CB; Tue, 31 Mar 2009 13:32:03 -0700 (PDT) Message-ID: <49D27DDF.9@elischer.org> Date: Tue, 31 Mar 2009 13:32:31 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.21 (Macintosh/20090302) MIME-Version: 1.0 To: Rick Macklem References: <49D13E9C.8010005@elischer.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: 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: Tue, 31 Mar 2009 20:32:09 -0000 Rick Macklem wrote: > > > On Mon, 30 Mar 2009, Julian Elischer wrote: > >> >> So you want to do a route lookup so use rtalloc or friends >> (see route.c). >> > > First off, I should say that, if there is a better mailing list for > this kind of thing, please let me know. Also, if this fails, it is > not the end of the world. All that happens is that the server doesn't > issue delegations to the client, since the callbacks aren't working. possibly freebsd-net@ might be a bit better. > > Given that I'd like to avoid having code in nfs fiddling > with *inp's and such, since it would have to worry about what global > vars it can use, locking on them, etc., I haven't worried about what > Max Laier mentioned and just used rtalloc(). > > Would someone like to review this function and see what you think? looks about right (without doing great analysis). You may be able to make it a bit simpler by calling rtalloc1() directly.. also, on might eventually think about the case where one might want to select a different routing table for NFS as one uses for other stuff.. but that can be ignored for now. As there are possibly many addresses on an interface, one needs to look for the one that has the same network as the gateway..(if it's not p2p). e.g. if you have 10.2.2.2/24 and 10.3.3.3/24 on an interface and the gateway is 10.3.3.1, then you obviously need to select the second address on that interface. > > nfscl_getmyip(struct nfsmount *nmp, int *isinet6p) > { > struct route ro; > struct sockaddr_in *sin, *rsin; > struct rtentry *rt; > u_int8_t *retp = NULL; > static struct in_addr laddr; > > *isinet6p = 0; > /* > * Loop up a route for the destination address. > */ > if (nmp->nm_nam->sa_family == AF_INET) { > bzero(&ro, sizeof (ro)); > rsin = (struct sockaddr_in *)&ro.ro_dst; > sin = (struct sockaddr_in *)nmp->nm_nam; > rsin->sin_family = AF_INET; > rsin->sin_len = sizeof (struct sockaddr_in); > rsin->sin_addr = sin->sin_addr; > rtalloc(&ro); > rt = ro.ro_rt; > if (rt != NULL) { > if (rt->rt_ifp != NULL && > rt->rt_ifa != NULL && > ((rt->rt_ifp->if_flags & IFF_LOOPBACK) == 0) && > rt->rt_ifa->ifa_addr->sa_family == AF_INET) { > sin = (struct sockaddr_in *) > rt->rt_ifa->ifa_addr; > laddr = sin->sin_addr; > retp = (u_int8_t *)&laddr; > } > RTFREE(rt); > } > #ifdef INET6 > } else if (nmp->nm_nam->sa_family == AF_INET6) { > struct sockaddr_in6 *sin6, *rsin6; > struct route_in6 ro6; > static struct in6_addr laddr6; > > bzero(&ro6, sizeof (ro6)); > rsin6 = (struct sockaddr_in6 *)&ro6.ro_dst; > sin6 = (struct sockaddr_in6 *)nmp->nm_nam; > rsin6->sin6_family = AF_INET6; > rsin6->sin6_len = sizeof (struct sockaddr_in6); > rsin6->sin6_addr = sin6->sin6_addr; > rtalloc((struct route *)&ro6); > rt = ro6.ro_rt; > if (rt != NULL) { > if (rt->rt_ifp != NULL && > rt->rt_ifa != NULL && > ((rt->rt_ifp->if_flags & IFF_LOOPBACK) == 0) && > rt->rt_ifa->ifa_addr->sa_family == AF_INET6) { > sin6 = (struct sockaddr_in6 *) > rt->rt_ifa->ifa_addr; > laddr6 = sin6->sin6_addr; > retp = (u_int8_t *)&laddr6; > *isinet6p = 1; > } > RTFREE(rt); > } > #endif > } > return (retp); > } > > Thanks everyone, for your help sofar, rick > >