Return-Path: linux-nfs-owner@vger.kernel.org Received: from mx1.redhat.com ([209.132.183.28]:13064 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155Ab3A1VGU (ORCPT ); Mon, 28 Jan 2013 16:06:20 -0500 Date: Mon, 28 Jan 2013 16:06:17 -0500 From: Jeff Layton To: Chuck Lever Cc: bfields@fieldses.org, linux-nfs@vger.kernel.org Subject: Re: [PATCH v1 01/16] nfsd: fix IPv6 address handling in the DRC Message-ID: <20130128160617.3288501c@tlielax.poochiereds.net> In-Reply-To: References: <1359402082-29195-1-git-send-email-jlayton@redhat.com> <1359402082-29195-2-git-send-email-jlayton@redhat.com> <5AD4F061-69A6-47F5-B20A-34B8DCC2EB5E@oracle.com> <20130128150502.4c5f497b@tlielax.poochiereds.net> <321A7110-AD03-49EB-A158-246FC8BD24E1@oracle.com> <20130128152643.2b136d37@tlielax.poochiereds.net> <615875E4-820D-487E-99CF-9ABD46121966@oracle.com> <20130128154555.3a93c6dc@tlielax.poochiereds.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-nfs-owner@vger.kernel.org List-ID: On Mon, 28 Jan 2013 15:54:26 -0500 Chuck Lever wrote: > > On Jan 28, 2013, at 3:45 PM, Jeff Layton wrote: > > > On Mon, 28 Jan 2013 15:34:49 -0500 > > Chuck Lever wrote: > > > >> > >> On Jan 28, 2013, at 3:26 PM, Jeff Layton wrote: > >> > >>> On Mon, 28 Jan 2013 12:16:17 -0800 (PST) > >>> Chuck Lever wrote: > >>> > >>>> > >>>> On Jan 28, 2013, at 3:05 PM, Jeff Layton wrote: > >>>> > >>>>> On Mon, 28 Jan 2013 11:51:13 -0800 (PST) > >>>>> Chuck Lever wrote: > >>>>> > >>>>>> > >>>>>> On Jan 28, 2013, at 2:41 PM, Jeff Layton wrote: > >>>>>> > >>>>>>> Currently, it only stores the first 16 bytes of any address. struct > >>>>>>> sockaddr_in6 is 28 bytes however, so we're currently ignoring the last > >>>>>>> 12 bytes of the address. > >>>>>>> > >>>>>>> Expand the c_addr field to a sockaddr_in6, > >>>>>> > >>>>>> What do you do about link-local addresses? > >>>>>> > >>>>> > >>>>> I use rpc_cmp_addr() which should handle the scope correctly for > >>>>> link-local addrs. Now that you mention it though, I think we may have a > >>>>> bug in __rpc_copy_addr6. It doesn't touch the scope_id at all -- > >>>>> shouldn't we be setting the scopeid in that function as well? > >>>> > >>>> It looks like rpc_copy_addr() is invoked to copy only source addresses, so the scope ID probably doesn't apply. The comment over rpc_copy_addr() says it explicitly ignores port and scope ID. > >>>> > >>> > >>> Well, it copies the source address of the client, but all of the > >>> callers are in nfsd code. So I think it probably does matter: > >>> > >>> Consider a server that has 2 interfaces, and 2 clients with identical > >>> link-local addresses hitting the link local address of each interface. > >>> The only way to distinguish them at that point is to look at their > >>> scope_ids. > >> > >> Yes, but we want to use the server's scope IDs in this case, don't we? Copying the client's scope IDs may not be the right thing to do. That's why __rpc_copy_addr6() doesn't copy the scope ID. > >> > > > > Is there any real distinction between the two? Whenever we start > > discussing scopeids I mentally substitute "interface index", since it's > > the same thing on linux. > > > > AIUI, scopeids only have a meaning on the host itself. When a > > link-local address gets used, the sockaddr_in6 in question gets the > > sin6_scope_id set to the index of the interface to which it is > > associated. > > > > So if we have a client and server "pair" using link-local addresses, > > then they should have equivalent scope IDs since they are associated > > with the same interface on the local machine. > > I don't think we can assume that the interface indices are the same on both the client and server. There is no co-ordination of that number space between separate hosts. > > What may be the case is that the server's network layer copies in the correct scope ID for the server when it exposes source addresses to its upper layers. In that case, the ID's probably safe to use when comparing addresses locally on the server. > I wasn't suggesting they were the same on client and server. They are most definitely *not*. I look at it this way... A link-local address must have a scope ID (aka interface index) attached, since without that the address has no real meaning. At the same time scopeIDs are never passed around on the wire -- they don't have any meaning outside of a single host. Ultimately scopeids are always generated by the local host, so it's OK to copy them between client and server addresses within the host's kernel. When I have a socket with link-local addresses, the scopeids of both sockaddrs must be the same since they are associated with the same interface. > Since we don't know for sure how this works, we should have someone create unit tests to explore this, fix any bugs that are discovered, and ensure that it continues to work. > I'm fairly sure I understand how it works (though I did need to go back and refresh my memory here). I'm not sure how you'd go about writing such a test for this, but let me know if you do and I'll be happy to take a look. In the meantime, I'll take a look at where we're copying and comparing ipv6 addrs and see whether we're missing scopeids in any of these places. -- Jeff Layton