Re: [BUG BISECT] NFSv4 client fails on Flush Journal to Persistent Storage

2018-07-25 Thread Chuck Lever



> On Jul 25, 2018, at 9:27 AM, Krzysztof Kozlowski  wrote:
> 
> On 18 June 2018 at 18:20, Chuck Lever  wrote:
>> 
>> The extra serialization appears to have a reproducible performance
>> impact on RDMA, which no longer takes the reserve_lock when allocating
>> a slot.
>> 
>> I could put an xprt_alloc_xid call in xprt_alloc_slot, but that would
>> only work for socket-based transports. Would it be OK if RDMA had its
>> own XID allocation mechanism?
> 
> Hi,
> 
> On recent next the issue appeared again. My boards with NFSv4 root
> timeout on 80% of boots. This time my NFS server is faster - Pi3 B+
> :).
> 
> Is this know? Should I start long bisect or maybe you can point me to
> possible causes?

Hi Krzysztof, I don't know of any recent changes. Bisecting would be
a good place to start.


--
Chuck Lever





Re: general protection fault in encode_rpcb_string

2018-05-08 Thread Chuck Lever


> On May 8, 2018, at 12:15 PM, bfie...@fieldses.org wrote:
> 
> On Tue, Apr 17, 2018 at 09:54:36PM +, Trond Myklebust wrote:
>> Yes, and we can probably convert it, and the other GFP_ATOMIC
>> allocations in the rpcbind client to use GFP_NOFS in order to improve
>> reliability.
> 
> Chuck, I think the GFP_ATOMIC is unnecessary here as well?
> 
> --b.
> 
> diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
> index e8adad33d0bb..de90c6c90cde 100644
> --- a/net/sunrpc/xprtrdma/rpc_rdma.c
> +++ b/net/sunrpc/xprtrdma/rpc_rdma.c
> @@ -228,7 +228,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct 
> xdr_buf *xdrbuf,
>   /* XXX: Certain upper layer operations do
>*  not provide receive buffer pages.
>*/
> - *ppages = alloc_page(GFP_ATOMIC);
> + *ppages = alloc_page(GFP_NOFS);
>   if (!*ppages)
>   return -EAGAIN;
>   }

This code can't sleep, as I understand it. Caller is holding
the transport write lock. This logic was copied from
xdr_partial_copy_from_skb, which uses GFP_ATOMIC.

Recall that this is here because of GETACL. As I've stated in
the past, the correct solution is to ensure that these pages
are provided in every case by the upper layer, making this
alloc_page call site unnecessary.


--
Chuck Lever
chuckle...@gmail.com





Re: KASAN: use-after-free Read in perf_trace_rpc_stats_latency

2018-04-30 Thread Chuck Lever
ient.c:634
> nfs_get_client+0x1065/0x1500 fs/nfs/client.c:425
> nfs_init_server+0x364/0xfb0 fs/nfs/client.c:670
> nfs_create_server+0x86/0x5f0 fs/nfs/client.c:953
> nfs_try_mount+0x177/0xab0 fs/nfs/super.c:1884
> nfs_fs_mount+0x17de/0x2efd fs/nfs/super.c:2695
> mount_fs+0xae/0x328 fs/super.c:1267
> vfs_kern_mount.part.34+0xd4/0x4d0 fs/namespace.c:1037
> vfs_kern_mount fs/namespace.c:1027 [inline]
> do_new_mount fs/namespace.c:2518 [inline]
> do_mount+0x564/0x3070 fs/namespace.c:2848
> ksys_mount+0x12d/0x140 fs/namespace.c:3064
> __do_sys_mount fs/namespace.c:3078 [inline]
> __se_sys_mount fs/namespace.c:3075 [inline]
> __x64_sys_mount+0xbe/0x150 fs/namespace.c:3075
> do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
> 
> Freed by task 6:
> save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> set_track mm/kasan/kasan.c:460 [inline]
> __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
> kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
> __cache_free mm/slab.c:3498 [inline]
> kfree+0xd9/0x260 mm/slab.c:3813
> xs_update_peer_port net/sunrpc/xprtsock.c:309 [inline]
> xs_set_port+0x105/0x180 net/sunrpc/xprtsock.c:1827
> rpcb_getport_done+0x224/0x2d0 net/sunrpc/rpcb_clnt.c:824
> rpc_exit_task+0xc9/0x2d0 net/sunrpc/sched.c:725
> __rpc_execute+0x28a/0xf50 net/sunrpc/sched.c:784
> rpc_async_schedule+0x16/0x20 net/sunrpc/sched.c:857
> process_one_work+0xc1e/0x1b50 kernel/workqueue.c:2145
> worker_thread+0x1cc/0x1440 kernel/workqueue.c:2279
> kthread+0x345/0x410 kernel/kthread.c:238
> ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
> 
> The buggy address belongs to the object at 8801d6f0a1c0
> which belongs to the cache kmalloc-32 of size 32
> The buggy address is located 0 bytes inside of
> 32-byte region [8801d6f0a1c0, 8801d6f0a1e0)
> The buggy address belongs to the page:
> page:ea00075bc280 count:1 mapcount:0 mapping:8801d6f0a000 
> index:0x8801d6f0afc1
> flags: 0x2fffc000100(slab)
> raw: 02fffc000100 8801d6f0a000 8801d6f0afc1 00010024
> raw: ea00075c52a0 8801da801238 8801da8001c0 
> page dumped because: kasan: bad access detected
> 
> Memory state around the buggy address:
> 8801d6f0a080: 01 fc fc fc fc fc fc fc 00 02 fc fc fc fc fc fc
> 8801d6f0a100: 00 02 fc fc fc fc fc fc 00 02 fc fc fc fc fc fc
>> 8801d6f0a180: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>   ^
> 8801d6f0a200: 00 02 fc fc fc fc fc fc 01 fc fc fc fc fc fc fc
> 8801d6f0a280: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
> ==

The rpc_task survived longer than the transport. task->tk_xprt
points to freed memory by the time rpc_count_iostats_metrics
runs.

The naive fix is to remove the references to task->tk_xprt
in the trace point. I'm still checking to see if this is the
fully correct fix.


> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkal...@googlegroups.com.
> 
> syzbot will keep track of this bug report.
> If you forgot to add the Reported-by tag, once the fix for this bug is merged
> into any tree, please reply to this email with:
> #syz fix: exact-commit-title
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> If it's a one-off invalid bug report, please reply with:
> #syz invalid
> Note: if the crash happens again, it will cause creation of a new bug report.
> Note: all commands must start from beginning of the line in the email body.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever





Re: [PATCH][net-next] svcrdma: fix an incorrect check on -E2BIG and -EINVAL

2017-07-13 Thread Chuck Lever

> On Jul 13, 2017, at 1:51 PM, Colin King <colin.k...@canonical.com> wrote:
> 
> From: Colin Ian King <colin.k...@canonical.com>
> 
> The current check will always be true and will always jump to
> err1, this looks dubious to me. I believe && should be used
> instead of ||.
> 
> Detected by CoverityScan, CID#1450120 ("Logically Dead Code")
> 
> Fixes: 107c1d0a991a ("svcrdma: Avoid Send Queue overflow")
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>

Reviewed-by: Chuck Lever <chuck.le...@oracle.com>

Dan reported this today, and I have a similar patch in my
"pending for-rc" series. This one works too.


> ---
> net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c 
> b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 19fd01e4b690..7c3a211e0e9a 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -684,7 +684,7 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
>   return 0;
> 
>  err2:
> - if (ret != -E2BIG || ret != -EINVAL)
> +     if (ret != -E2BIG && ret != -EINVAL)
>   goto err1;
> 
>   ret = svc_rdma_post_recv(rdma, GFP_KERNEL);
> -- 
> 2.11.0
> 

--
Chuck Lever





Re: [PATCH] xprtrdma: Delete an error message for a failed memory allocation in xprt_rdma_bc_setup()

2017-05-22 Thread Chuck Lever

> On May 22, 2017, at 4:24 PM, SF Markus Elfring 
> <elfr...@users.sourceforge.net> wrote:
> 
> From: Markus Elfring <elfr...@users.sourceforge.net>
> Date: Mon, 22 May 2017 22:18:28 +0200
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Link: 
> http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>

Reviewed-by: Chuck Lever <chuck.le...@oracle.com>


> ---
> net/sunrpc/xprtrdma/backchannel.c | 6 ++
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/backchannel.c 
> b/net/sunrpc/xprtrdma/backchannel.c
> index 24fedd4b117e..03f6b5840764 100644
> --- a/net/sunrpc/xprtrdma/backchannel.c
> +++ b/net/sunrpc/xprtrdma/backchannel.c
> @@ -119,11 +119,9 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned 
> int reqs)
> 
>   for (i = 0; i < (reqs << 1); i++) {
>   rqst = kzalloc(sizeof(*rqst), GFP_KERNEL);
> - if (!rqst) {
> - pr_err("RPC:   %s: Failed to create bc rpc_rqst\n",
> -__func__);
> + if (!rqst)
>   goto out_free;
> - }
> +
>   dprintk("RPC:   %s: new rqst %p\n", __func__, rqst);
> 
>   rqst->rq_xprt = _xprt->rx_xprt;
> -- 
> 2.13.0

--
Chuck Lever





Re: [PATCH] xprtrdma: use offset_in_page() macro

2017-04-21 Thread Chuck Lever

> On Apr 21, 2017, at 9:21 PM, Geliang Tang <geliangt...@gmail.com> wrote:
> 
> Use offset_in_page() macro instead of open-coding.
> 
> Signed-off-by: Geliang Tang <geliangt...@gmail.com>
> ---
> net/sunrpc/xprtrdma/rpc_rdma.c| 4 ++--
> net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 +--
> 2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
> index a044be2..429beea 100644
> --- a/net/sunrpc/xprtrdma/rpc_rdma.c
> +++ b/net/sunrpc/xprtrdma/rpc_rdma.c
> @@ -540,7 +540,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct 
> rpcrdma_req *req,
>   goto out;
> 
>   page = virt_to_page(xdr->tail[0].iov_base);
> - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
> + page_base = offset_in_page(xdr->tail[0].iov_base);
> 
>   /* If the content in the page list is an odd length,
>* xdr_write_pages() has added a pad at the beginning
> @@ -587,7 +587,7 @@ rpcrdma_prepare_msg_sges(struct rpcrdma_ia *ia, struct 
> rpcrdma_req *req,
>*/
>   if (xdr->tail[0].iov_len) {
>   page = virt_to_page(xdr->tail[0].iov_base);
> - page_base = (unsigned long)xdr->tail[0].iov_base & ~PAGE_MASK;
> + page_base = offset_in_page(xdr->tail[0].iov_base);
>   len = xdr->tail[0].iov_len;
> 
> map_tail:

There are several other sites that use PAGE_MASK in
rpc_rdma.c. Should those be included in this patch?

Do you have a way to test this change? If not I
can take it (once the above comment is addressed),
run it through the usual battery of NFS/RDMA
testing, and then pass it along to Anna.


> diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c 
> b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> index 1736337..60b3f29 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
> @@ -306,12 +306,11 @@ static int svc_rdma_dma_map_buf(struct svcxprt_rdma 
> *rdma,
>   unsigned char *base,
>   unsigned int len)
> {
> - unsigned long offset = (unsigned long)base & ~PAGE_MASK;
>   struct ib_device *dev = rdma->sc_cm_id->device;
>   dma_addr_t dma_addr;
> 
>   dma_addr = ib_dma_map_page(dev, virt_to_page(base),
> -offset, len, DMA_TO_DEVICE);
> +offset_in_page(base), len, DMA_TO_DEVICE);
>   if (ib_dma_mapping_error(dev, dma_addr))
>   return -EIO;
> 

This hunk conflicts with a rewrite of svc_rdma_sendto.c that
Bruce has already accepted for v4.12. I would prefer this
be dropped.

The rewritten code also has this issue. I can submit a patch
separately that adds offset_in_page in the appropriate place.


--
Chuck Lever





Re: [PATCH rfc 0/4] Introduce a new helper for parsing ipv[4|6]:port to socket address

2017-02-16 Thread Chuck Lever

> On Feb 16, 2017, at 12:53 PM, Sagi Grimberg <s...@grimberg.me> wrote:
> 
> Hey Chuck,
> 
>>> As a side-effect, this set adds ipv6 support for nvme over fabrics.
>>> I also converted iscsi target and plan to convert nfs/cifs next but
>>> wanted to get some feedback before doing that.
>> 
>> At least NFS/RDMA already supports IPv6. You might not need many
>> changes there, but I'll hold off on further comments.
> 
> Yea, I wanted to get all the rpc_pton/rpc_ntop (which handle both
> ipv4 and ipv6 with scopes) converted to use a common helper.

RPC is dealing with universal addresses, which are not quite the
same as IP presentation addresses. The port number is expressed
as:

  hi8.lo8

And universal IPv6 addresses don't have a mechanism for conveying
scope information.


--
Chuck Lever





Re: [PATCH rfc 0/4] Introduce a new helper for parsing ipv[4|6]:port to socket address

2017-02-16 Thread Chuck Lever

> On Feb 16, 2017, at 12:43 PM, Sagi Grimberg <s...@grimberg.me> wrote:
> 
> We have some places in the stack that support ipv4 and ipv6. In
> some cases the user configuration does not reveal which
> address family is given and needs to be parsed from the input string.
> 
> Given that the user-input varies between subsystems, some processing
> is required from the call-site to separate address and port strings.
> 
> As a side-effect, this set adds ipv6 support for nvme over fabrics.
> I also converted iscsi target and plan to convert nfs/cifs next but
> wanted to get some feedback before doing that.

At least NFS/RDMA already supports IPv6. You might not need many
changes there, but I'll hold off on further comments.


> patch #1 is based off roland's patch:
> http://lists.infradead.org/pipermail/linux-nvme/2016-August/005600.html
> 
> Sagi Grimberg (4):
>  net/utils: generic inet_pton_with_scope helper
>  nvmet-rdma: use generic inet_pton_with_scope
>  nvme-rdma: use inet_pton_with_scope helper
>  iscsi-target: use generic inet_pton_with_scope
> 
> drivers/nvme/host/rdma.c | 48 ---
> drivers/nvme/target/rdma.c   | 42 +
> drivers/target/iscsi/iscsi_target_configfs.c | 46 --
> include/linux/inet.h |  6 ++
> net/core/utils.c | 91 
> 5 files changed, 151 insertions(+), 82 deletions(-)
> 
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever





Re: [RFC PATCH] sunrpc: do not allow process to freeze within RPC state machine

2016-08-03 Thread Chuck Lever

> On Aug 3, 2016, at 1:36 PM, Jeff Layton <jlay...@redhat.com> wrote:
> 
> On Wed, 2016-08-03 at 20:54 +0400, Stanislav Kinsburskiy wrote:
>> Otherwise freezer cgroup state might never become "FROZEN".
>> 
>> Here is a deadlock scheme for 2 processes in one freezer cgroup,
>> which is
>> freezing:
>> 
>> CPU 0   CPU 1
>> 
>> do_last
>> inode_lock(dir->d_inode)
>> vfs_create
>> nfs_create
>> ...
>> __rpc_execute
>> rpc_wait_bit_killable
>> __refrigerator
>> do_last
>> inode_lock(dir->d_inode)
>> 
>> So, the problem is that one process takes directory inode mutex,
>> executes
>> creation request and goes to refrigerator.
>> Another one waits till directory lock is released, remains "thawed"
>> and thus
>> freezer cgroup state never becomes "FROZEN".
>> 
>> Notes:
>> 1) Interesting, that this is not a pure deadlock: one can thaw cgroup
>> and then
>> freeze it again.
>> 2) The issue was introduced by commit
>> d310310cbff18ec385c6ab4d58f33b100192a96a.
>> 3) This patch is not aimed to fix the issue, but to show the problem
>> root.
>> Look like this problem moght be applicable to other hunks from the
>> commit,
>> mentioned above.
>> 
>> 
>> Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>
>> ---
>>  net/sunrpc/sched.c |1 -
>>  1 file changed, 1 deletion(-)
>> 
>> diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
>> index 9ae5885..ec7ccc1 100644
>> --- a/net/sunrpc/sched.c
>> +++ b/net/sunrpc/sched.c
>> @@ -253,7 +253,6 @@ EXPORT_SYMBOL_GPL(rpc_destroy_wait_queue);
>>  
>>  static int rpc_wait_bit_killable(struct wait_bit_key *key, int mode)
>>  {
>> -freezable_schedule_unsafe();
>>  if (signal_pending_state(mode, current))
>>  return -ERESTARTSYS;
>>  return 0;
>> 
> 
> Ummm...so what actually does the schedule() with this patch?
> 
> There was a bit of discussion on this recently -- see the thread with
> this subject line in linux-nfs:
> 
> Re: Hang due to nfs letting tasks freeze with locked inodes
> 
> Basically it comes down to this:
> 
> All of the proposals so far to fix this problem just switch out the
> freezable_schedule_unsafe (and similar) calls for those that don't
> allow the process to freeze.
> 
> The problem there is that we originally added that stuff in response to
> bug reports about machines failing to suspend. What often happens is
> that the network interfaces come down, and then the freezer runs over
> all of the processes, which never return because they're blocked
> waiting on the server to reply.
> 
> ...shrug...
> 
> Maybe we should just go ahead and do it (and to CIFS as well). Just be
> prepared for the inevitable complaints about laptops failing to suspend
> once you do.
> 
> Part of the fix, I think is to add a return code (similar to
> ERESTARTSYS) that gets interpreted near the kernel-userland boundary
> as: "allow the process to be frozen, and then retry the call once it's
> resumed".
> 
> With that, filesystems could return the error code when they want to
> redrive the entire syscall from that level. That won't work for non-
> idempotent requests though. We'd need to do something more elaborate
> there.

There is a similar problem with NFS/RDMA.

An IB device driver can be unloaded at any time. The driver performs
an upcall to all consumers to request that they release all RDMA
resources associated with the device.

For RPC-over-RDMA, we could kill all running RPCs at this point. Or,
the RPCs could be suspended in place. The latter is desirable if the
device were re-inserted, or there were an alternate path to the NFS
server: then there would be no workload interruption.

Signals would have to be allowed so that ^C and soft timeouts still
work as expected.


--
Chuck Lever





Re: Cannot use NFS with linux-next 20160429

2016-05-01 Thread Chuck Lever
1138] [] (handle_IPI) from []
> (gic_handle_irq+0x8c/0x9c)
> [   16.138713]  r8:c0d21f80 r7:c0d02c58 r6:ef0a5f58 r5:f400010c
> r4:f4000100 r3:0c04
> [   16.146562] [] (gic_handle_irq) from []
> (__irq_svc+0x58/0x78)
> [   16.154052] Exception stack(0xef0a5f58 to 0xef0a5fa0)
> [   16.159112] 5f40:
>0001 0001
> [   16.167301] 5f60:  c011b920  c0d02984 
>  c0c757b8 c0d029d8
> [   16.175489] 5f80: c0d029d0 ef0a5fb4 ef0a5f78 ef0a5fa8 c016d120
> c01089e0 2013 
> [   16.183672]  r10:c0d029d0 r9:c0d029d8 r8:c0c757b8 r7:ef0a5f8c
> r6: r5:2013
> [   16.191601]  r4:c01089e0 r3:ef0a8000
> [   16.195230] [] (arch_cpu_idle) from []
> (default_idle_call+0x28/0x38)
> [   16.203334] [] (default_idle_call) from []
> (cpu_startup_entry+0x1c8/0x24c)
> [   16.211959] [] (cpu_startup_entry) from []
> (secondary_start_kernel+0x130/0x154)
> [   16.221010]  r7:c0d6e388 r3:0004
> [   16.224633] [] (secondary_start_kernel) from [<101016cc>]
> (0x101016cc)
> [   16.232035]  r5:0051 r4:3f08806a
> [   16.235656] CPU1: stopping
> [   16.238378] CPU: 1 PID: 0 Comm: swapper/1 Not tainted
> 4.6.0-rc5-next-20160429 #349
> [   16.245954] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> [   16.252487] Backtrace:
> [   16.254970] [] (dump_backtrace) from []
> (show_stack+0x18/0x1c)
> [   16.262545]  r6:6193 r5: r4: r3:
> [   16.268291] [] (show_stack) from []
> (dump_stack+0xb0/0xe8)
> [   16.275529] [] (dump_stack) from []
> (handle_IPI+0x174/0x1a4)
> [   16.282931]  r8:ef0a3f58 r7:c0c746ec r6: r5:c0d02b10
> r4:0001 r3:ef076c00
> [   16.290777] [] (handle_IPI) from []
> (gic_handle_irq+0x8c/0x9c)
> [   16.298353]  r8:c0d21f80 r7:c0d02c58 r6:ef0a3f58 r5:f400010c
> r4:f4000100 r3:0c04
> [   16.306199] [] (gic_handle_irq) from []
> (__irq_svc+0x58/0x78)
> [   16.313688] Exception stack(0xef0a3f58 to 0xef0a3fa0)
> [   16.318747] 3f40:
>0001 0001
> [   16.326935] 3f60:  c011b920  c0d02984 
>  c0c757b8 c0d029d8
> [   16.335123] 3f80: c0d029d0 ef0a3fb4 ef0a3f78 ef0a3fa8 c016d120
> c01089e0 2013 
> [   16.343304]  r10:c0d029d0 r9:c0d029d8 r8:c0c757b8 r7:ef0a3f8c
> r6: r5:2013
> [   16.351230]  r4:c01089e0 r3:ef076c00
> [   16.354856] [] (arch_cpu_idle) from []
> (default_idle_call+0x28/0x38)
> [   16.362961] [] (default_idle_call) from []
> (cpu_startup_entry+0x1c8/0x24c)
> [   16.371585] [] (cpu_startup_entry) from []
> (secondary_start_kernel+0x130/0x154)
> [   16.380635]  r7:c0d6e388 r3:0002
> [   16.384256] [] (secondary_start_kernel) from [<101016cc>]
> (0x101016cc)
> [   16.391657]  r5:0051 r4:3f08806a
> [   16.395300] ---[ end Kernel panic - not syncing: VFS: Unable to
> mount root fs on unknown-block(2,0)
> 
> Any ideas? Thanks
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever





Re: [Lsf] [Lsf-pc] [LSF/MM TOPIC] Generic page-pool recycle facility?

2016-04-07 Thread Chuck Lever

> On Apr 7, 2016, at 7:38 AM, Christoph Hellwig <h...@infradead.org> wrote:
> 
> This is also very interesting for storage targets, which face the same
> issue.  SCST has a mode where it caches some fully constructed SGLs,
> which is probably very similar to what NICs want to do.

+1 for NFS server.


--
Chuck Lever





Re: [PATCH 00/25] RFC: AF_INET6 family support for the NFS client

2007-11-14 Thread Chuck Lever

On Nov 13, 2007, at 8:14 PM, David Miller wrote:

From: Chuck Lever [EMAIL PROTECTED]
Date: Tue, 13 Nov 2007 13:30:59 -0500

These 25 patches add support for AF_INET6 addresses to the NFS  
client.

This is a request for review of the proposed changes.


Please start using the [EMAIL PROTECTED] mailing list
for future submissions instead of the sourceforge one.

Thank you.


Hi David-

Neil Brown has discussed a transition plan.  There were no objections  
to moving to vger, but we don't have a timeframe yet.


--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com


-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/25] NFS: eliminate NIPQUAD(clp-cl_addr.sin_addr)

2007-11-14 Thread Chuck Lever

YOSHIFUJI Hideaki / 吉藤英明 wrote:

In article [EMAIL PROTECTED] (at Tue, 13 Nov 2007 13:31:27 -0500), Chuck Lever 
[EMAIL PROTECTED] says:


   clp-rpc_ops-version,
-  NIPQUAD(clp-cl_addr.sin_addr),
-  ntohs(clp-cl_addr.sin_port),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_PORT),
   atomic_read(clp-cl_count),


Is this really safe?


What's unsafe about it?  rpc_peeraddr2str() is designed to be called 
this way.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
version:2.1
end:vcard



[PATCH 00/25] RFC: AF_INET6 family support for the NFS client

2007-11-13 Thread Chuck Lever
These 25 patches add support for AF_INET6 addresses to the NFS client.
This is a request for review of the proposed changes.

This series does not add support for AF_INET6 addresses to the Linux
NLM or NSM implementations, nor does it add support in the NFS server.

To use an IPv6 NFS server, the mount.nfs command will pass in an IPv6
server address via the addr option.  IPv6 support in mount.nfs is yet
to be implemented.

This series has been tested only with IPv4 addresses to ensure there are no
regressions.  Groupe Bull has tested earlier versions of these changes with
other IPv6 NFS server implementations to sanity check the architecture.

-- 
corporate:chuck dot lever at oracle dot com
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/25] NFS: eliminate NIPQUAD(clp-cl_addr.sin_addr)

2007-11-13 Thread Chuck Lever
To ensure the NFS client displays IPv6 addresses properly, replace
address-specific NIPQUAD() invocations with a call to the RPC client to
get a formatted string representing the remote peer's address.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |   12 ++--
 fs/nfs/delegation.c |   10 ++
 fs/nfs/nfs4state.c  |9 +
 fs/nfs/super.c  |5 +++--
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index b24b6db..5ab1ca1 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1265,10 +1265,10 @@ static int nfs_server_list_show(struct seq_file *m, 
void *v)
/* display one transport per line on subsequent lines */
clp = list_entry(v, struct nfs_client, cl_share_link);
 
-   seq_printf(m, v%u %02x%02x%02x%02x %4hx %3d %s\n,
+   seq_printf(m, v%u %s %s %3d %s\n,
   clp-rpc_ops-version,
-  NIPQUAD(clp-cl_addr.sin_addr),
-  ntohs(clp-cl_addr.sin_port),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_PORT),
   atomic_read(clp-cl_count),
   clp-cl_hostname);
 
@@ -1344,10 +1344,10 @@ static int nfs_volume_list_show(struct seq_file *m, 
void *v)
 (unsigned long long) server-fsid.major,
 (unsigned long long) server-fsid.minor);
 
-   seq_printf(m, v%u %02x%02x%02x%02x %4hx %-7s %-17s\n,
+   seq_printf(m, v%u %s %s %-7s %-17s\n,
   clp-rpc_ops-version,
-  NIPQUAD(clp-cl_addr.sin_addr),
-  ntohs(clp-cl_addr.sin_port),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
+  rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_HEX_PORT),
   dev,
   fsid);
 
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 11833f4..b03dcd8 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -156,8 +156,9 @@ int nfs_inode_set_delegation(struct inode *inode, struct 
rpc_cred *cred, struct
if (memcmp(delegation-stateid, nfsi-delegation-stateid,
sizeof(delegation-stateid)) != 0 ||
delegation-type != nfsi-delegation-type) {
-   printk(%s: server %u.%u.%u.%u, handed out a duplicate 
delegation!\n,
-   __FUNCTION__, 
NIPQUAD(clp-cl_addr.sin_addr));
+   printk(KERN_WARNING %s: server %s handed out 
+   a duplicate delegation!\n,
+   __FUNCTION__, clp-cl_hostname);
status = -EIO;
}
}
@@ -314,8 +315,9 @@ void nfs_expire_all_delegations(struct nfs_client *clp)
__module_get(THIS_MODULE);
atomic_inc(clp-cl_count);
task = kthread_run(nfs_do_expire_all_delegations, clp,
-   %u.%u.%u.%u-delegreturn,
-   NIPQUAD(clp-cl_addr.sin_addr));
+   %s-delegreturn,
+   rpc_peeraddr2str(clp-cl_rpcclient,
+   RPC_DISPLAY_ADDR));
if (!IS_ERR(task))
return;
nfs_put_client(clp);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 23a9a36..86f95d4 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -755,8 +755,9 @@ static void nfs4_recover_state(struct nfs_client *clp)
 
__module_get(THIS_MODULE);
atomic_inc(clp-cl_count);
-   task = kthread_run(reclaimer, clp, %u.%u.%u.%u-reclaim,
-   NIPQUAD(clp-cl_addr.sin_addr));
+   task = kthread_run(reclaimer, clp, %s-reclaim,
+   rpc_peeraddr2str(clp-cl_rpcclient,
+   RPC_DISPLAY_ADDR));
if (!IS_ERR(task))
return;
nfs4_clear_recover_bit(clp);
@@ -967,8 +968,8 @@ out:
module_put_and_exit(0);
return 0;
 out_error:
-   printk(KERN_WARNING Error: state recovery failed on NFSv4 server 
%u.%u.%u.%u with error %d\n,
-   NIPQUAD(clp-cl_addr.sin_addr), -status);
+   printk(KERN_WARNING Error: state recovery failed on NFSv4 server %s
+with error %d\n, clp-cl_hostname, -status);
set_bit(NFS4CLNT_LEASE_EXPIRED, clp-cl_state);
goto out;
 }
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 91e26e2..5a742a8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -467,8 +467,9 @@ static int nfs_show_options(struct seq_file *m, struct 
vfsmount *mnt)
 
nfs_show_mount_options(m, nfss, 0);
 
-   seq_printf(m, ,addr=NIPQUAD_FMT,
-   NIPQUAD(nfss-nfs_client-cl_addr.sin_addr

[PATCH 06/25] NFS: Clean-up: move dprintks from callback.c to callback_proc.c

2007-11-13 Thread Chuck Lever
The client side peer address is available in callback_proc.c, so move
a dprintk out of fs/nfs/callback.c and into fs/nfs/callback_proc.c.

This is more consistent with other debugging messages, and the proc
routines have more information about each request to display.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/callback.c  |4 
 fs/nfs/callback_proc.c |   12 +++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index a796be5..bbf67f1 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -73,8 +73,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
complete(nfs_callback_info.started);
 
for(;;) {
-   char buf[RPC_MAX_ADDRBUFLEN];
-
if (signalled()) {
if (nfs_callback_info.users == 0)
break;
@@ -92,8 +90,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
__FUNCTION__, -err);
break;
}
-   dprintk(%s: request from %s\n, __FUNCTION__,
-   svc_print_addr(rqstp, buf, sizeof(buf)));
svc_process(rqstp);
}
 
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 72e55d8..019d939 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -12,7 +12,9 @@
 #include delegation.h
 #include internal.h
 
+#ifdef NFS_DEBUG
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
+#endif
  
 __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres 
*res)
 {
@@ -20,12 +22,16 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args, 
struct cb_getattrres *
struct nfs_delegation *delegation;
struct nfs_inode *nfsi;
struct inode *inode;
-   
+
res-bitmap[0] = res-bitmap[1] = 0;
res-status = htonl(NFS4ERR_BADHANDLE);
clp = nfs_find_client(args-addr, 4);
if (clp == NULL)
goto out;
+
+   dprintk(NFS: GETATTR callback request from %s\n, 
+   rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_ADDR));
+
inode = nfs_delegation_find_inode(clp, args-fh);
if (inode == NULL)
goto out_putclient;
@@ -65,6 +71,10 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void 
*dummy)
clp = nfs_find_client(args-addr, 4);
if (clp == NULL)
goto out;
+
+   dprintk(NFS: RECALL callback request from %s\n, 
+   rpc_peeraddr2str(clp-cl_rpcclient, RPC_DISPLAY_ADDR));
+
inode = nfs_delegation_find_inode(clp, args-fh);
if (inode == NULL)
goto out_putclient;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/25] NFS: Ensure NFSv4 SETCLIENTID send buffer is large enough

2007-11-13 Thread Chuck Lever
Ensure that the RPC buffer size specified for NFSv4 SETCLIENTID procedures
matches what we are encoding into the buffer.  See the definition of
struct nfs4_setclientid {} and the encode_setclientid() function.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 fs/nfs/nfs4xdr.c|   10 ++
 include/linux/nfs_xdr.h |   13 +++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index eae46f0..93e8ebf 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -116,10 +116,12 @@ static int nfs4_stat_to_errno(int);
 #define decode_renew_maxsz (op_decode_hdr_maxsz)
 #define encode_setclientid_maxsz \
(op_encode_hdr_maxsz + \
-   4 /*server-ip_addr*/ + \
-   1 /*Netid*/ + \
-   6 /*uaddr*/ + \
-   6 + (NFS4_VERIFIER_SIZE  2))
+   XDR_QUADLEN(NFS4_VERIFIER_SIZE) + \
+   XDR_QUADLEN(48) /* sc_name */ + \
+   1 /* sc_prog */ + \
+   XDR_QUADLEN(RPCBIND_MAXNETIDLEN) + \
+   XDR_QUADLEN(RPCBIND_MAXUADDRLEN) + \
+   1 /* sc_cb_ident */ )
 #define decode_setclientid_maxsz \
(op_decode_hdr_maxsz + \
2 + \
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 58751f3..d740dfa 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -666,16 +666,17 @@ struct nfs4_rename_res {
struct nfs_fattr *  new_fattr;
 };
 
+#define NFS4_SETCLIENTID_NAMELEN   (48)
 struct nfs4_setclientid {
-   const nfs4_verifier *   sc_verifier;  /* request */
+   const nfs4_verifier *   sc_verifier;
unsigned intsc_name_len;
-   charsc_name[48];  /* request */
-   u32 sc_prog;  /* request */
+   charsc_name[NFS4_SETCLIENTID_NAMELEN];
+   u32 sc_prog;
unsigned intsc_netid_len;
-   charsc_netid[4];  /* request */
+   charsc_netid[RPCBIND_MAXNETIDLEN];
unsigned intsc_uaddr_len;
-   charsc_uaddr[24]; /* request */
-   u32 sc_cb_ident;  /* request */
+   charsc_uaddr[RPCBIND_MAXUADDRLEN];
+   u32 sc_cb_ident;
 };
 
 struct nfs4_statfs_arg {

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/25] NFS: Enable NFS client to generate CLIENTID strings with IPv6 addresses

2007-11-13 Thread Chuck Lever
We recently added methods to RPC transports that provide string versions of
the remote peer address information.  Convert the NFSv4 SETCLIENTID
procedure to use those methods instead of building the client ID out of
whole cloth.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/nfs4proc.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f03d9d5..ec58d1e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2912,14 +2912,18 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 
program, unsigned short po
 
for(;;) {
setclientid.sc_name_len = scnprintf(setclientid.sc_name,
-   sizeof(setclientid.sc_name), %s/%u.%u.%u.%u %s 
%u,
-   clp-cl_ipaddr, NIPQUAD(clp-cl_addr.sin_addr),
+   sizeof(setclientid.sc_name), %s/%s %s %u,
+   clp-cl_ipaddr,
+   rpc_peeraddr2str(clp-cl_rpcclient,
+   RPC_DISPLAY_ADDR),
cred-cr_ops-cr_name,
clp-cl_id_uniquifier);
setclientid.sc_netid_len = scnprintf(setclientid.sc_netid,
-   sizeof(setclientid.sc_netid), tcp);
+   sizeof(setclientid.sc_netid),
+   rpc_peeraddr2str(clp-cl_rpcclient,
+   RPC_DISPLAY_NETID));
setclientid.sc_uaddr_len = scnprintf(setclientid.sc_uaddr,
-   sizeof(setclientid.sc_uaddr), %s.%d.%d,
+   sizeof(setclientid.sc_uaddr), %s.%u.%u,
clp-cl_ipaddr, port  8, port  255);
 
status = rpc_call_sync(clp-cl_rpcclient, msg, 0);

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/25] NFS: Expand server address storage in nfs_client struct

2007-11-13 Thread Chuck Lever
Prepare for managing larger addresses in the NFS client by widening the
nfs_client struct's cl_addr field and adding a field to store the address's
length.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c   |   11 +++
 fs/nfs/super.c|9 ++---
 include/linux/nfs_fs_sb.h |3 ++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5ab1ca1..53bf8ab 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -117,7 +117,8 @@ static struct nfs_client *nfs_alloc_client(const char 
*hostname,
atomic_set(clp-cl_count, 1);
clp-cl_cons_state = NFS_CS_INITING;
 
-   memcpy(clp-cl_addr, addr, sizeof(clp-cl_addr));
+   clp-cl_addrlen = sizeof(*addr);/* for now */
+   memcpy(clp-cl_addr, addr, clp-cl_addrlen);
 
if (hostname) {
clp-cl_hostname = kstrdup(hostname, GFP_KERNEL);
@@ -214,6 +215,8 @@ static struct nfs_client *__nfs_find_client(const struct 
sockaddr_in *addr,
struct nfs_client *clp;
 
list_for_each_entry(clp, nfs_client_list, cl_share_link) {
+   struct sockaddr_in *clap = (struct sockaddr_in *)clp-cl_addr;
+
/* Don't match clients that failed to initialise properly */
if (clp-cl_cons_state  0)
continue;
@@ -222,10 +225,10 @@ static struct nfs_client *__nfs_find_client(const struct 
sockaddr_in *addr,
if (clp-rpc_ops-version != nfsversion)
continue;
 
-   if (clp-cl_addr.sin_addr.s_addr != addr-sin_addr.s_addr)
+   if (clap-sin_addr.s_addr != addr-sin_addr.s_addr)
continue;
 
-   if (!match_port || clp-cl_addr.sin_port == addr-sin_port)
+   if (!match_port || clap-sin_port == addr-sin_port)
goto found;
}
 
@@ -380,7 +383,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp, 
int proto,
struct rpc_create_args args = {
.protocol   = proto,
.address= (struct sockaddr *)clp-cl_addr,
-   .addrsize   = sizeof(clp-cl_addr),
+   .addrsize   = clp-cl_addrlen,
.timeout= timeparms,
.servername = clp-cl_hostname,
.program= nfs_program,
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 5a742a8..6258a19 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1332,10 +1332,13 @@ static int nfs_compare_super(struct super_block *sb, 
void *data)
struct nfs_server *server = sb_mntdata-server, *old = NFS_SB(sb);
int mntflags = sb_mntdata-mntflags;
 
-   if (memcmp(old-nfs_client-cl_addr,
-   server-nfs_client-cl_addr,
-   sizeof(old-nfs_client-cl_addr)) != 0)
+   /* Check family, address, and port */
+   if (old-nfs_client-cl_addrlen != server-nfs_client-cl_addrlen)
return 0;
+   if (memcmp(old-nfs_client-cl_addr, server-nfs_client-cl_addr,
+  old-nfs_client-cl_addrlen) != 0)
+   return 0;
+
/* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
if (old-flags  NFS_MOUNT_UNSHARED)
return 0;
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index f2a0f20..5e3a43b 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -20,7 +20,8 @@ struct nfs_client {
 #define NFS_CS_IDMAP   2   /* - idmap started */
 #define NFS_CS_RENEWD  3   /* - renewd started */
 
-   struct sockaddr_in  cl_addr;/* server identifier */
+   struct sockaddr_storage cl_addr;/* server identifier */
+   size_t  cl_addrlen;
char *  cl_hostname;/* hostname of server */
struct list_headcl_share_link;  /* link in global client list */
struct list_headcl_superblocks; /* List of nfs_server structs */

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/25] NFS: Change cb_getattrargs to pass struct sockaddr * instead of sockaddr_in

2007-11-13 Thread Chuck Lever
Change the addr field in the cb_getattrargs struct to a struct sockaddr *
to support non-IPv4 addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/callback.h  |2 +-
 fs/nfs/callback_proc.c |2 +-
 fs/nfs/callback_xdr.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index c2bb14e..ec0ffd9 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -38,7 +38,7 @@ struct cb_compound_hdr_res {
 };
 
 struct cb_getattrargs {
-   struct sockaddr_in *addr;
+   struct sockaddr *addr;
struct nfs_fh fh;
uint32_t bitmap[2];
 };
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 019d939..2a1b14f 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -25,7 +25,7 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args, 
struct cb_getattrres *
 
res-bitmap[0] = res-bitmap[1] = 0;
res-status = htonl(NFS4ERR_BADHANDLE);
-   clp = nfs_find_client(args-addr, 4);
+   clp = nfs_find_client((struct sockaddr_in *)args-addr, 4);
if (clp == NULL)
goto out;
 
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 97abd82..3eda1bc 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -176,7 +176,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp, 
struct xdr_stream *xdr
status = decode_fh(xdr, args-fh);
if (unlikely(status != 0))
goto out;
-   args-addr = svc_addr_in(rqstp);
+   args-addr = svc_addr(rqstp);
status = decode_bitmap(xdr, args-bitmap);
 out:
dprintk(%s: exit with status = %d\n, __FUNCTION__, ntohl(status));

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/25] NFS: Change cb_recallargs to pass struct sockaddr * instead of sockaddr_in

2007-11-13 Thread Chuck Lever
Change the addr field in the cb_recallargs struct to a struct sockaddr *
to support IPv6 addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/callback.h  |2 +-
 fs/nfs/callback_proc.c |2 +-
 fs/nfs/callback_xdr.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index ec0ffd9..bb25d21 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -53,7 +53,7 @@ struct cb_getattrres {
 };
 
 struct cb_recallargs {
-   struct sockaddr_in *addr;
+   struct sockaddr *addr;
struct nfs_fh fh;
nfs4_stateid stateid;
uint32_t truncate;
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 2a1b14f..00082cf 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -68,7 +68,7 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void 
*dummy)
__be32 res;

res = htonl(NFS4ERR_BADHANDLE);
-   clp = nfs_find_client(args-addr, 4);
+   clp = nfs_find_client((struct sockaddr_in *)args-addr, 4);
if (clp == NULL)
goto out;
 
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 3eda1bc..c63eb72 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -188,7 +188,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, 
struct xdr_stream *xdr,
__be32 *p;
__be32 status;
 
-   args-addr = svc_addr_in(rqstp);
+   args-addr = svc_addr(rqstp);
status = decode_stateid(xdr, args-stateid);
if (unlikely(status != 0))
goto out;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/25] NFS: Make nfs_alloc_client() take (sockaddr, len) instead of sockaddr_in

2007-11-13 Thread Chuck Lever
To support non-IPv4 addresses, adjust the arguments and callers of
nfs_alloc_client() to pass in a struct sockaddr * and length instead of
a struct sockaddr_in *.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 53bf8ab..c1ee3d3 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -100,7 +100,8 @@ struct rpc_program  nfsacl_program = {
  * bother putting them in a slab cache...
  */
 static struct nfs_client *nfs_alloc_client(const char *hostname,
-  const struct sockaddr_in *addr,
+  const struct sockaddr *addr,
+  size_t addrlen,
   unsigned int nfsversion)
 {
struct nfs_client *clp;
@@ -117,7 +118,7 @@ static struct nfs_client *nfs_alloc_client(const char 
*hostname,
atomic_set(clp-cl_count, 1);
clp-cl_cons_state = NFS_CS_INITING;
 
-   clp-cl_addrlen = sizeof(*addr);/* for now */
+   clp-cl_addrlen = addrlen;
memcpy(clp-cl_addr, addr, clp-cl_addrlen);
 
if (hostname) {
@@ -285,7 +286,9 @@ static struct nfs_client *nfs_get_client(const char 
*hostname,
 
spin_unlock(nfs_client_lock);
 
-   new = nfs_alloc_client(hostname, addr, nfsversion);
+   new = nfs_alloc_client(hostname,
+  (const struct sockaddr *)addr,
+  sizeof(*addr), nfsversion);
} while (new);
 
return ERR_PTR(-ENOMEM);

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/25] NFS: Address a couple of nits in nfs_follow_referral()

2007-11-13 Thread Chuck Lever
Fix an outdated block comment, and address a comparison between a signed
and unsigned integer.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 fs/nfs/nfs4namespace.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index dd5fef2..bd1b161 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -114,10 +114,7 @@ static inline int valid_ipaddr4(const char *buf)
  * nfs_follow_referral - set up mountpoint when hitting a referral on moved 
error
  * @mnt_parent - mountpoint of parent directory
  * @dentry - parent directory
- * @fspath - fs path returned in fs_locations
- * @mntpath - mount path to new server
- * @hostname - hostname of new server
- * @addr - host addr of new server
+ * @locations - array of NFSv4 server location information
  *
  */
 static struct vfsmount *nfs_follow_referral(const struct vfsmount *mnt_parent,
@@ -131,7 +128,8 @@ static struct vfsmount *nfs_follow_referral(const struct 
vfsmount *mnt_parent,
.authflavor = 
NFS_SB(mnt_parent-mnt_sb)-client-cl_auth-au_flavor,
};
char *page = NULL, *page2 = NULL;
-   int loc, s, error;
+   unsigned int s;
+   int loc, error;
 
if (locations == NULL || locations-nlocations = 0)
goto out;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/25] NFS: Change __nfs_find_client() to take struct sockaddr *

2007-11-13 Thread Chuck Lever
Adjust the arguments and callers of __nfs_find_client() to pass a struct
sockaddr * instead of a struct sockaddr_in * so that non-IPv4 addresses
can be passed into __nfs_find_client().

A subsequent patch adds support for IPv6 addresses to __nfs_find_client().

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |   14 +-
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index c1ee3d3..8eff0b2 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -209,10 +209,11 @@ void nfs_put_client(struct nfs_client *clp)
  * Find a client by address
  * - caller must hold nfs_client_lock
  */
-static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr,
+static struct nfs_client *__nfs_find_client(const struct sockaddr *addr,
unsigned int nfsversion,
int match_port)
 {
+   struct sockaddr_in *ap = (struct sockaddr_in *)addr;
struct nfs_client *clp;
 
list_for_each_entry(clp, nfs_client_list, cl_share_link) {
@@ -226,10 +227,13 @@ static struct nfs_client *__nfs_find_client(const struct 
sockaddr_in *addr,
if (clp-rpc_ops-version != nfsversion)
continue;
 
-   if (clap-sin_addr.s_addr != addr-sin_addr.s_addr)
+   if (((struct sockaddr *)clap)-sa_family != addr-sa_family)
continue;
 
-   if (!match_port || clap-sin_port == addr-sin_port)
+   if (clap-sin_addr.s_addr != ap-sin_addr.s_addr)
+   continue;
+
+   if (!match_port || clap-sin_port == ap-sin_port)
goto found;
}
 
@@ -250,7 +254,7 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in 
*addr,
struct nfs_client *clp;
 
spin_lock(nfs_client_lock);
-   clp = __nfs_find_client(addr, nfsversion, 0);
+   clp = __nfs_find_client((struct sockaddr *)addr, nfsversion, 0);
spin_unlock(nfs_client_lock);
if (clp != NULL  clp-cl_cons_state != NFS_CS_READY) {
nfs_put_client(clp);
@@ -278,7 +282,7 @@ static struct nfs_client *nfs_get_client(const char 
*hostname,
do {
spin_lock(nfs_client_lock);
 
-   clp = __nfs_find_client(addr, nfsversion, 1);
+   clp = __nfs_find_client((struct sockaddr *)addr, nfsversion, 1);
if (clp)
goto found_client;
if (new)

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/25] NFS: Distinguish IPv6 addresses in __nfs_find_client

2007-11-13 Thread Chuck Lever
Add support for the AF_INET6 family of IP addresses in __nfs_find_client.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |   34 +++---
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 8eff0b2..67a5a53 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -34,6 +34,8 @@
 #include linux/nfs_idmap.h
 #include linux/vfs.h
 #include linux/inet.h
+#include linux/in6.h
+#include net/ipv6.h
 #include linux/nfs_xdr.h
 
 #include asm/system.h
@@ -213,11 +215,10 @@ static struct nfs_client *__nfs_find_client(const struct 
sockaddr *addr,
unsigned int nfsversion,
int match_port)
 {
-   struct sockaddr_in *ap = (struct sockaddr_in *)addr;
struct nfs_client *clp;
 
list_for_each_entry(clp, nfs_client_list, cl_share_link) {
-   struct sockaddr_in *clap = (struct sockaddr_in *)clp-cl_addr;
+   struct sockaddr *clap = (struct sockaddr *)clp-cl_addr;
 
/* Don't match clients that failed to initialise properly */
if (clp-cl_cons_state  0)
@@ -227,14 +228,33 @@ static struct nfs_client *__nfs_find_client(const struct 
sockaddr *addr,
if (clp-rpc_ops-version != nfsversion)
continue;
 
-   if (((struct sockaddr *)clap)-sa_family != addr-sa_family)
+   if (clap-sa_family != addr-sa_family)
continue;
 
-   if (clap-sin_addr.s_addr != ap-sin_addr.s_addr)
+   switch (addr-sa_family) {
+   case AF_INET: {
+   struct sockaddr_in *sap = (struct sockaddr_in *)clap;
+   struct sockaddr_in *ap = (struct sockaddr_in *)addr;
+   if (sap-sin_addr.s_addr != ap-sin_addr.s_addr)
+   continue;
+   if (!match_port || sap-sin_port == ap-sin_port)
+   goto found;
continue;
-
-   if (!match_port || clap-sin_port == ap-sin_port)
-   goto found;
+   }
+   case AF_INET6: {
+   struct sockaddr_in6 *sap = (struct sockaddr_in6 *)clap;
+   struct sockaddr_in6 *ap = (struct sockaddr_in6 *)addr;
+   if (!ipv6_addr_equal(sap-sin6_addr, ap-sin6_addr))
+   continue;
+   if (!match_port || sap-sin6_port == ap-sin6_port)
+   goto found;
+   continue;
+   }
+   default:
+   printk(KERN_ERR %s: address family not supported\n,
+   __FUNCTION__);
+   return NULL;
+   }
}
 
return NULL;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/25] NFS: Change nfs_find_client() to take struct sockaddr *

2007-11-13 Thread Chuck Lever
Adjust arguments and callers of nfs_find_client() to pass a
struct sockaddr * instead of struct sockaddr_in * to support non-IPv4
addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/callback.c  |3 +--
 fs/nfs/callback_proc.c |4 ++--
 fs/nfs/client.c|4 ++--
 fs/nfs/internal.h  |2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index bbf67f1..9b6bbf1 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -164,12 +164,11 @@ void nfs_callback_down(void)
 
 static int nfs_callback_authenticate(struct svc_rqst *rqstp)
 {
-   struct sockaddr_in *addr = svc_addr_in(rqstp);
struct nfs_client *clp;
char buf[RPC_MAX_ADDRBUFLEN];
 
/* Don't talk to strangers */
-   clp = nfs_find_client(addr, 4);
+   clp = nfs_find_client(svc_addr(rqstp), 4);
if (clp == NULL)
return SVC_DROP;
 
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 00082cf..019d939 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -25,7 +25,7 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args, 
struct cb_getattrres *
 
res-bitmap[0] = res-bitmap[1] = 0;
res-status = htonl(NFS4ERR_BADHANDLE);
-   clp = nfs_find_client((struct sockaddr_in *)args-addr, 4);
+   clp = nfs_find_client(args-addr, 4);
if (clp == NULL)
goto out;
 
@@ -68,7 +68,7 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void 
*dummy)
__be32 res;

res = htonl(NFS4ERR_BADHANDLE);
-   clp = nfs_find_client((struct sockaddr_in *)args-addr, 4);
+   clp = nfs_find_client(args-addr, 4);
if (clp == NULL)
goto out;
 
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 67a5a53..7b45ed0 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -268,13 +268,13 @@ found:
  * Find a client by IP address and protocol version
  * - returns NULL if no such client
  */
-struct nfs_client *nfs_find_client(const struct sockaddr_in *addr,
+struct nfs_client *nfs_find_client(const struct sockaddr *addr,
   unsigned int nfsversion)
 {
struct nfs_client *clp;
 
spin_lock(nfs_client_lock);
-   clp = __nfs_find_client((struct sockaddr *)addr, nfsversion, 0);
+   clp = __nfs_find_client(addr, nfsversion, 0);
spin_unlock(nfs_client_lock);
if (clp != NULL  clp-cl_cons_state != NFS_CS_READY) {
nfs_put_client(clp);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 3d5e587..ef40539 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -64,7 +64,7 @@ extern struct rpc_program nfs_program;
 
 extern void nfs_put_client(struct nfs_client *);
 extern struct nfs_client *nfs_find_client(
-   const struct sockaddr_in *,
+   const struct sockaddr *,
unsigned int);
 extern struct nfs_server *nfs_create_server(
const struct nfs_parsed_mount_data *,

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/25] NFS: Change nfs_get_client() to take (sockaddr *, len)

2007-11-13 Thread Chuck Lever
Adjust arguments and callers of nfs_get_client() to pass a
struct sockaddr * and length instead of struct sockaddr_in * to support
non-IPv4 addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |   21 +++--
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 7b45ed0..f03a742 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -288,21 +288,21 @@ struct nfs_client *nfs_find_client(const struct sockaddr 
*addr,
  * - creates a new record if one doesn't yet exist
  */
 static struct nfs_client *nfs_get_client(const char *hostname,
-const struct sockaddr_in *addr,
+const struct sockaddr *addr,
+size_t addrlen,
 unsigned int nfsversion)
 {
struct nfs_client *clp, *new = NULL;
int error;
 
-   dprintk(-- nfs_get_client(%s,NIPQUAD_FMT:%d,%u)\n,
-   hostname ?: , NIPQUAD(addr-sin_addr),
-   addr-sin_port, nfsversion);
+   dprintk(-- nfs_get_client(%s,v%u)\n,
+   hostname ?: , nfsversion);
 
/* see if the client already exists */
do {
spin_lock(nfs_client_lock);
 
-   clp = __nfs_find_client((struct sockaddr *)addr, nfsversion, 1);
+   clp = __nfs_find_client(addr, nfsversion, 1);
if (clp)
goto found_client;
if (new)
@@ -310,9 +310,7 @@ static struct nfs_client *nfs_get_client(const char 
*hostname,
 
spin_unlock(nfs_client_lock);
 
-   new = nfs_alloc_client(hostname,
-  (const struct sockaddr *)addr,
-  sizeof(*addr), nfsversion);
+   new = nfs_alloc_client(hostname, addr, addrlen, nfsversion);
} while (new);
 
return ERR_PTR(-ENOMEM);
@@ -588,7 +586,9 @@ static int nfs_init_server(struct nfs_server *server,
 
/* Allocate or find a client reference we can use */
clp = nfs_get_client(data-nfs_server.hostname,
-   data-nfs_server.address, nfsvers);
+   (struct sockaddr *)data-nfs_server.address,
+   sizeof(data-nfs_server.address),
+   nfsvers);
if (IS_ERR(clp)) {
dprintk(-- nfs_init_server() = error %ld\n, PTR_ERR(clp));
return PTR_ERR(clp);
@@ -925,7 +925,8 @@ static int nfs4_set_client(struct nfs_server *server,
dprintk(-- nfs4_set_client()\n);
 
/* Allocate or find a client reference we can use */
-   clp = nfs_get_client(hostname, addr, 4);
+   clp = nfs_get_client(hostname, (struct sockaddr *)addr,
+   sizeof(*addr), 4);
if (IS_ERR(clp)) {
error = PTR_ERR(clp);
goto error;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/25] NFS: Adjust nfs_clone_mount structure to store struct sockaddr *

2007-11-13 Thread Chuck Lever
Change the addr field in the nfs_clone_mount structure to store a struct
sockaddr * to support non-IPv4 addresses in the NFS client.

Note this is mostly a cosmetic change, and does not actually allow
referrals using IPv6 addresses.  The existing referral code assumes that
the server returns a string that represents an IPv4 address.  This code
needs to support hostnames and IPv6 addresses as well as IPv4 addresses,
thus it will need to be restructured in order to handle DNS resolution in
user space.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c|3 ++-
 fs/nfs/internal.h  |2 +-
 fs/nfs/nfs4namespace.c |   11 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index f03a742..5e53892 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1072,7 +1072,8 @@ struct nfs_server *nfs4_create_referral_server(struct 
nfs_clone_mount *data,
 
/* Get a client representation.
 * Note: NFSv4 always uses TCP, */
-   error = nfs4_set_client(server, data-hostname, data-addr,
+   error = nfs4_set_client(server, data-hostname,
+   (struct sockaddr_in *)data-addr,
parent_client-cl_ipaddr,
data-authflavor,
parent_server-client-cl_xprt-prot,
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index ef40539..40f2619 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -21,7 +21,7 @@ struct nfs_clone_mount {
struct nfs_fattr *fattr;
char *hostname;
char *mnt_path;
-   struct sockaddr_in *addr;
+   struct sockaddr *addr;
rpc_authflavor_t authflavor;
 };
 
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index bd1b161..65dcbfd 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -172,7 +172,10 @@ static struct vfsmount *nfs_follow_referral(const struct 
vfsmount *mnt_parent,
 
s = 0;
while (s  location-nservers) {
-   struct sockaddr_in addr = {};
+   struct sockaddr_in addr = {
+   .sin_family = AF_INET,
+   .sin_port   = htons(NFS_PORT),
+   };
 
if (location-servers[s].len = 0 ||
valid_ipaddr4(location-servers[s].data)  0) {
@@ -181,10 +184,8 @@ static struct vfsmount *nfs_follow_referral(const struct 
vfsmount *mnt_parent,
}
 
mountdata.hostname = location-servers[s].data;
-   addr.sin_addr.s_addr = in_aton(mountdata.hostname);
-   addr.sin_family = AF_INET;
-   addr.sin_port = htons(NFS_PORT);
-   mountdata.addr = addr;
+   addr.sin_addr.s_addr = in_aton(mountdata.hostname),
+   mountdata.addr = (struct sockaddr *)addr;
 
snprintf(page, PAGE_SIZE, %s:%s,
mountdata.hostname,

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/25] NFS: Change nfs4_set_client() to accept (sockaddr *, len)

2007-11-13 Thread Chuck Lever
Adjust the arguments and callers of nfs4_set_client() to pass a struct
sockaddr * and a length instead of a struct sockaddr_in * to support
non-IPv4 addresses in the NFS client.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5e53892..37b63a6 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -914,7 +914,9 @@ error:
  * Set up an NFS4 client
  */
 static int nfs4_set_client(struct nfs_server *server,
-   const char *hostname, const struct sockaddr_in *addr,
+   const char *hostname,
+   const struct sockaddr *addr,
+   const size_t addrlen,
const char *ip_addr,
rpc_authflavor_t authflavour,
int proto, int timeo, int retrans)
@@ -925,8 +927,7 @@ static int nfs4_set_client(struct nfs_server *server,
dprintk(-- nfs4_set_client()\n);
 
/* Allocate or find a client reference we can use */
-   clp = nfs_get_client(hostname, (struct sockaddr *)addr,
-   sizeof(*addr), 4);
+   clp = nfs_get_client(hostname, addr, addrlen, 4);
if (IS_ERR(clp)) {
error = PTR_ERR(clp);
goto error;
@@ -997,7 +998,8 @@ struct nfs_server *nfs4_create_server(const struct 
nfs_parsed_mount_data *data,
/* Get a client record */
error = nfs4_set_client(server,
data-nfs_server.hostname,
-   data-nfs_server.address,
+   (struct sockaddr *)data-nfs_server.address,
+   sizeof(data-nfs_server.address),
data-client_address,
data-auth_flavors[0],
data-nfs_server.protocol,
@@ -1073,7 +1075,8 @@ struct nfs_server *nfs4_create_referral_server(struct 
nfs_clone_mount *data,
/* Get a client representation.
 * Note: NFSv4 always uses TCP, */
error = nfs4_set_client(server, data-hostname,
-   (struct sockaddr_in *)data-addr,
+   data-addr,
+   sizeof(*data-addr),
parent_client-cl_ipaddr,
data-authflavor,
parent_server-client-cl_xprt-prot,

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/25] NFS: Increase size of cl_ipaddr field to hold IPv6 addresses

2007-11-13 Thread Chuck Lever
The nfs_client's cl_ipaddr field needs to be larger to hold strings that
represent IPv6 addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 include/linux/nfs_fs_sb.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 8a3061c..f2a0f20 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -63,7 +63,7 @@ struct nfs_client {
/* Our own IP address, as a null-terminated string.
 * This is used to generate the clientid, and the callback address.
 */
-   charcl_ipaddr[16];
+   charcl_ipaddr[64];
unsigned char   cl_id_uniquifier;
 #endif
 };

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/25] NFS: Remove the NIPQUAD from nfs_try_mount

2007-11-13 Thread Chuck Lever
In the name of address family compatibility, we can't have the NIP_FMT and
NIPQUAD macros in nfs_try_mount().  Instead, we can make use of an unused
mount option to display the mount server's hostname.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/super.c |   23 ++-
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6258a19..262adb4 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -87,7 +87,7 @@ enum {
Opt_nfsvers,
 
/* Mount options that take string arguments */
-   Opt_sec, Opt_proto, Opt_mountproto,
+   Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
Opt_addr, Opt_mountaddr, Opt_clientaddr,
 
/* Mount options that are ignored */
@@ -146,7 +146,7 @@ static match_table_t nfs_mount_option_tokens = {
{ Opt_mountproto, mountproto=%s },
{ Opt_addr, addr=%s },
{ Opt_clientaddr, clientaddr=%s },
-   { Opt_userspace, mounthost=%s },
+   { Opt_mounthost, mounthost=%s },
{ Opt_mountaddr, mountaddr=%s },
 
{ Opt_err, NULL }
@@ -953,6 +953,12 @@ static int nfs_parse_mount_options(char *raw,
goto out_nomem;
mnt-client_address = string;
break;
+   case Opt_mounthost:
+   string = match_strdup(args);
+   if (string == NULL)
+   goto out_nomem;
+   mnt-mount_server.hostname = string;
+   break;
case Opt_mountaddr:
string = match_strdup(args);
if (string == NULL)
@@ -1000,6 +1006,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
 {
struct sockaddr_in sin;
int status;
+   char *hostname;
 
if (args-mount_server.version == 0) {
if (args-flags  NFS_MOUNT_VER3)
@@ -1008,6 +1015,11 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
args-mount_server.version = NFS_MNT_VERSION;
}
 
+   if (args-mount_server.hostname)
+   hostname = args-mount_server.hostname;
+   else
+   hostname = args-nfs_server.hostname;
+
/*
 * Construct the mount server's address.
 */
@@ -1026,7 +1038,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
 */
status = nfs_mount((struct sockaddr *) sin,
   sizeof(sin),
-  args-nfs_server.hostname,
+  hostname,
   args-nfs_server.export_path,
   args-mount_server.version,
   args-mount_server.protocol,
@@ -1034,8 +1046,8 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
if (status == 0)
return 0;
 
-   dfprintk(MOUNT, NFS: unable to mount server  NIPQUAD_FMT
-   , error %d\n, NIPQUAD(sin.sin_addr.s_addr), status);
+   dfprintk(MOUNT, NFS: unable to mount server %s, error %d,
+   hostname, status);
return status;
 }
 
@@ -1407,6 +1419,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
 
 out:
kfree(data.nfs_server.hostname);
+   kfree(data.mount_server.hostname);
return error;
 
 out_err_nosb:

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/25] SUNRPC: Move universal address definitions to global header

2007-11-13 Thread Chuck Lever
Universal addresses are defined in RFC 1833 and clarified in RFC 3530.  We
need to use them in several places in the NFS and RPC clients, so move the
relevant definition and block comment to an appropriate global include
file.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 include/linux/sunrpc/msg_prot.h |   39 ++
 net/sunrpc/rpcb_clnt.c  |   45 +++
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index c4beb57..70df4f1 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -152,5 +152,44 @@ typedef __be32 rpc_fraghdr;
  */
 #define RPCBIND_MAXNETIDLEN(4u)
 
+/*
+ * Universal addresses are introduced in RFC 1833 and further spelled
+ * out in RFC 3530.  RPCBIND_MAXUADDRLEN defines a maximum byte length
+ * of a universal address for use in allocating buffers and character
+ * arrays.
+ *
+ * Quoting RFC 3530, section 2.2:
+ *
+ * For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the
+ * US-ASCII string:
+ *
+ * h1.h2.h3.h4.p1.p2
+ *
+ * The prefix, h1.h2.h3.h4, is the standard textual form for
+ * representing an IPv4 address, which is always four octets long.
+ * Assuming big-endian ordering, h1, h2, h3, and h4, are respectively,
+ * the first through fourth octets each converted to ASCII-decimal.
+ * Assuming big-endian ordering, p1 and p2 are, respectively, the first
+ * and second octets each converted to ASCII-decimal.  For example, if a
+ * host, in big-endian order, has an address of 0x0A010307 and there is
+ * a service listening on, in big endian order, port 0x020F (decimal
+ * 527), then the complete universal address is 10.1.3.7.2.15.
+ *
+ * ...
+ *
+ * For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the
+ * US-ASCII string:
+ *
+ * x1:x2:x3:x4:x5:x6:x7:x8.p1.p2
+ *
+ * The suffix p1.p2 is the service port, and is computed the same way
+ * as with universal addresses for TCP and UDP over IPv4.  The prefix,
+ * x1:x2:x3:x4:x5:x6:x7:x8, is the standard textual form for
+ * representing an IPv6 address as defined in Section 2.2 of [RFC2373].
+ * Additionally, the two alternative forms specified in Section 2.2 of
+ * [RFC2373] are also acceptable.
+ */
+#define RPCBIND_MAXUADDRLEN(56u)
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SUNRPC_MSGPROT_H_ */
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index a05493a..593d1ad 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -55,45 +55,6 @@ enum {
 #define RPCB_HIGHPROC_4RPCBPROC_GETSTAT
 
 /*
- * r_addr
- *
- * Quoting RFC 3530, section 2.2:
- *
- * For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the
- * US-ASCII string:
- *
- * h1.h2.h3.h4.p1.p2
- *
- * The prefix, h1.h2.h3.h4, is the standard textual form for
- * representing an IPv4 address, which is always four octets long.
- * Assuming big-endian ordering, h1, h2, h3, and h4, are respectively,
- * the first through fourth octets each converted to ASCII-decimal.
- * Assuming big-endian ordering, p1 and p2 are, respectively, the first
- * and second octets each converted to ASCII-decimal.  For example, if a
- * host, in big-endian order, has an address of 0x0A010307 and there is
- * a service listening on, in big endian order, port 0x020F (decimal
- * 527), then the complete universal address is 10.1.3.7.2.15.
- *
- * ...
- *
- * For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the
- * US-ASCII string:
- *
- * x1:x2:x3:x4:x5:x6:x7:x8.p1.p2
- *
- * The suffix p1.p2 is the service port, and is computed the same way
- * as with universal addresses for TCP and UDP over IPv4.  The prefix,
- * x1:x2:x3:x4:x5:x6:x7:x8, is the standard textual form for
- * representing an IPv6 address as defined in Section 2.2 of [RFC2373].
- * Additionally, the two alternative forms specified in Section 2.2 of
- * [RFC2373] are also acceptable.
- *
- * XXX: Currently this implementation does not explicitly convert the
- *  stored address to US-ASCII on non-ASCII systems.
- */
-#define RPCB_MAXADDRLEN(128u)
-
-/*
  * r_owner
  *
  * The owner is allowed to unset a service in the rpcbind database.
@@ -113,7 +74,7 @@ struct rpcbind_args {
u32 r_prot;
unsigned short  r_port;
char *  r_netid;
-   charr_addr[RPCB_MAXADDRLEN];
+   charr_addr[RPCBIND_MAXUADDRLEN];
char *  r_owner;
 };
 
@@ -518,7 +479,7 @@ static int rpcb_decode_getaddr(struct rpc_rqst *req, __be32 
*p,
 * Simple sanity check.  The smallest possible universal
 * address is an IPv4 address string containing 11 bytes.
 */
-   if (addr_len  11 || addr_len  RPCB_MAXADDRLEN)
+   if (addr_len  11 || addr_len  RPCBIND_MAXUADDRLEN)
goto

[PATCH 19/25] NFS: Make setting a port number agostic

2007-11-13 Thread Chuck Lever
We'll need to set the port number of an AF_INET or AF_INET6 address in
several places in fs/nfs/super.c, so introduce a helper that can manage
this for us.  We put this helper to immediate use.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 fs/nfs/super.c |   34 --
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 262adb4..7dc56ce 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -45,6 +45,7 @@
 #include linux/nfs_idmap.h
 #include linux/vfs.h
 #include linux/inet.h
+#include linux/in6.h
 #include linux/nfs_xdr.h
 #include linux/magic.h
 #include linux/parser.h
@@ -574,6 +575,28 @@ static void nfs_umount_begin(struct vfsmount *vfsmnt, int 
flags)
 }
 
 /*
+ * Set the port number in an address.  Be agnostic about the address family.
+ */
+static int nfs_set_address_port(struct sockaddr *sap, unsigned short port)
+{
+   switch (sap-sa_family) {
+   case AF_INET: {
+   struct sockaddr_in *ap = (struct sockaddr_in *)sap;
+   ap-sin_port = htons(port);
+   return 0;
+   }
+   case AF_INET6: {
+   struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
+   ap-sin6_port = htons(port);
+   return 0;
+   }
+   default:
+   dfprintk(MOUNT, NFS: unrecognized address family\n);
+   return -EAFNOSUPPORT;
+   }
+}
+
+/*
  * Sanity-check a server address provided by the mount command
  */
 static int nfs_verify_server_address(struct sockaddr *addr)
@@ -691,6 +714,7 @@ static int nfs_parse_mount_options(char *raw,
   struct nfs_parsed_mount_data *mnt)
 {
char *p, *string;
+   unsigned short port = 0;
 
if (!raw) {
dfprintk(MOUNT, NFS: mount options string was NULL.\n);
@@ -793,7 +817,7 @@ static int nfs_parse_mount_options(char *raw,
return 0;
if (option  0 || option  65535)
return 0;
-   mnt-nfs_server.address.sin_port = htons(option);
+   port = option;
break;
case Opt_rsize:
if (match_int(args, mnt-rsize))
@@ -978,6 +1002,10 @@ static int nfs_parse_mount_options(char *raw,
}
}
 
+   if (nfs_set_address_port((struct sockaddr *)
+mnt-nfs_server.address, port))
+   return 0;
+
return 1;
 
 out_nomem:
@@ -1030,7 +1058,9 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
/*
 * autobind will be used if mount_server.port == 0
 */
-   sin.sin_port = htons(args-mount_server.port);
+   if (nfs_set_address_port((struct sockaddr *)sin,
+   args-mount_server.port))
+   return -EAFNOSUPPORT;
 
/*
 * Now ask the mount server to map our export path

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/25] NFS: Set default port for NFSv4, with support for AF_INET6

2007-11-13 Thread Chuck Lever
Move more address family dependencies to a helper function.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 fs/nfs/super.c |   40 
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 7dc56ce..1831394 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1573,6 +1573,31 @@ static void nfs4_fill_super(struct super_block *sb)
 }
 
 /*
+ * If the user didn't specify a port, set the port number to
+ * the NFS version 4 default port.
+ */
+static int nfs4_default_port(struct sockaddr *sap)
+{
+   switch (sap-sa_family) {
+   case AF_INET: {
+   struct sockaddr_in *ap = (struct sockaddr_in *)sap;
+   if (ap-sin_port == 0)
+   ap-sin_port = htons(NFS_PORT);
+   return 0;
+   }
+   case AF_INET6: {
+   struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
+   if (ap-sin6_port == 0)
+   ap-sin6_port = htons(NFS_PORT);
+   return 0;
+   }
+   default:
+   dfprintk(MOUNT, NFS: unrecognized address family\n);
+   return -EAFNOSUPPORT;
+   }
+}
+
+/*
  * Validate NFSv4 mount options
  */
 static int nfs4_validate_mount_data(void *options,
@@ -1580,6 +1605,7 @@ static int nfs4_validate_mount_data(void *options,
const char *dev_name)
 {
struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
+   struct sockaddr *sap = (struct sockaddr *)args-nfs_server.address;
char *c;
 
if (data == NULL)
@@ -1604,10 +1630,9 @@ static int nfs4_validate_mount_data(void *options,
   data-host_addr,
   sizeof(args-nfs_server.address)))
return -EFAULT;
-   if (args-nfs_server.address.sin_port == 0)
-   args-nfs_server.address.sin_port = htons(NFS_PORT);
-   if (!nfs_verify_server_address((struct sockaddr *)
-   args-nfs_server.address))
+   if (nfs4_default_port(sap))
+   goto out_no_address;
+   if (!nfs_verify_server_address(sap))
goto out_no_address;
 
switch (data-auth_flavourlen) {
@@ -1663,10 +1688,9 @@ static int nfs4_validate_mount_data(void *options,
if (nfs_parse_mount_options((char *)options, args) == 0)
return -EINVAL;
 
-   if (args-nfs_server.address.sin_port == 0)
-   args-nfs_server.address.sin_port = htons(NFS_PORT);
-   if (!nfs_verify_server_address((struct sockaddr *)
-   args-nfs_server.address))
+   if (nfs4_default_port(sap))
+   return -EINVAL;
+   if (!nfs_verify_server_address(sap))
return -EINVAL;
 
switch (args-auth_flavor_len) {

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/25] NFS: Refactor mount option address parsing into separate function

2007-11-13 Thread Chuck Lever
Some mount options pass in a string IP address.  Let's parse these strings
in a separate function since this is done for at least two different mount
options.

This allows us to support IPv6 string addresses more easily in a subsequent
patch

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/super.c |   20 ++--
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 1831394..c09c045 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -614,6 +614,16 @@ static int nfs_verify_server_address(struct sockaddr *addr)
 }
 
 /*
+ * Parse string addresses passed in via a mount option.
+ */
+static void nfs_parse_server_address(char *value,
+struct sockaddr_in *addr)
+{
+   addr-sin_family = AF_INET;
+   addr-sin_addr.s_addr = in_aton(value);
+}
+
+/*
  * Parse the value of the 'sec=' option.
  */
 static int nfs_parse_security_flavors(char *value,
@@ -966,9 +976,8 @@ static int nfs_parse_mount_options(char *raw,
string = match_strdup(args);
if (string == NULL)
goto out_nomem;
-   mnt-nfs_server.address.sin_family = AF_INET;
-   mnt-nfs_server.address.sin_addr.s_addr =
-   in_aton(string);
+   nfs_parse_server_address(string,
+mnt-nfs_server.address);
kfree(string);
break;
case Opt_clientaddr:
@@ -987,9 +996,8 @@ static int nfs_parse_mount_options(char *raw,
string = match_strdup(args);
if (string == NULL)
goto out_nomem;
-   mnt-mount_server.address.sin_family = AF_INET;
-   mnt-mount_server.address.sin_addr.s_addr =
-   in_aton(string);
+   nfs_parse_server_address(string,
+mnt-mount_server.address);
kfree(string);
break;
 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/25] NFS: Support non-IPv4 addresses in nfs_parsed_mount_data

2007-11-13 Thread Chuck Lever
Replace the nfs_server and mount_server address fields in the
nfs_parsed_mount_data structure with a struct sockaddr_storage and a
length, instead of a struct sockaddr_in.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/client.c   |   11 +-
 fs/nfs/internal.h |6 --
 fs/nfs/super.c|   56 +
 3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 37b63a6..3ee0f0d 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -573,6 +573,7 @@ error:
 static int nfs_init_server(struct nfs_server *server,
   const struct nfs_parsed_mount_data *data)
 {
+   struct sockaddr *sap = (struct sockaddr *)data-nfs_server.address;
struct nfs_client *clp;
unsigned int nfsvers = 2;
int error;
@@ -585,10 +586,8 @@ static int nfs_init_server(struct nfs_server *server,
 #endif
 
/* Allocate or find a client reference we can use */
-   clp = nfs_get_client(data-nfs_server.hostname,
-   (struct sockaddr *)data-nfs_server.address,
-   sizeof(data-nfs_server.address),
-   nfsvers);
+   clp = nfs_get_client(data-nfs_server.hostname, sap,
+data-nfs_server.addrlen, nfsvers);
if (IS_ERR(clp)) {
dprintk(-- nfs_init_server() = error %ld\n, PTR_ERR(clp));
return PTR_ERR(clp);
@@ -985,6 +984,7 @@ static int nfs4_init_server(struct nfs_server *server,
 struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
  struct nfs_fh *mntfh)
 {
+   struct sockaddr *sap = (struct sockaddr *)data-nfs_server.address;
struct nfs_fattr fattr;
struct nfs_server *server;
int error;
@@ -998,8 +998,7 @@ struct nfs_server *nfs4_create_server(const struct 
nfs_parsed_mount_data *data,
/* Get a client record */
error = nfs4_set_client(server,
data-nfs_server.hostname,
-   (struct sockaddr *)data-nfs_server.address,
-   sizeof(data-nfs_server.address),
+   sap, data-nfs_server.addrlen,
data-client_address,
data-auth_flavors[0],
data-nfs_server.protocol,
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 40f2619..f8ccba9 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -44,7 +44,8 @@ struct nfs_parsed_mount_data {
char*client_address;
 
struct {
-   struct sockaddr_in  address;
+   struct sockaddr_storage address;
+   size_t  addrlen;
char*hostname;
unsigned intversion;
unsigned short  port;
@@ -52,7 +53,8 @@ struct nfs_parsed_mount_data {
} mount_server;
 
struct {
-   struct sockaddr_in  address;
+   struct sockaddr_storage address;
+   size_t  addrlen;
char*hostname;
char*export_path;
int protocol;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c09c045..3ea4a4f 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -599,8 +599,10 @@ static int nfs_set_address_port(struct sockaddr *sap, 
unsigned short port)
 /*
  * Sanity-check a server address provided by the mount command
  */
-static int nfs_verify_server_address(struct sockaddr *addr)
+static int nfs_verify_server_address(struct sockaddr_storage *ssp)
 {
+   struct sockaddr *addr = (struct sockaddr *)ssp;
+
switch (addr-sa_family) {
case AF_INET: {
struct sockaddr_in *sa = (struct sockaddr_in *) addr;
@@ -617,10 +619,14 @@ static int nfs_verify_server_address(struct sockaddr 
*addr)
  * Parse string addresses passed in via a mount option.
  */
 static void nfs_parse_server_address(char *value,
-struct sockaddr_in *addr)
+struct sockaddr_storage *ssp,
+size_t *len)
 {
-   addr-sin_family = AF_INET;
-   addr-sin_addr.s_addr = in_aton(value);
+   struct sockaddr_in *ap = (struct sockaddr_in *)ssp;
+
+   ap-sin_family = AF_INET;
+   ap-sin_addr.s_addr = in_aton(value);
+   *len = sizeof(*ap);
 }
 
 /*
@@ -977,7 +983,8 @@ static int nfs_parse_mount_options(char *raw,
if (string == NULL)
goto out_nomem;
nfs_parse_server_address(string,
-mnt-nfs_server.address);
+mnt

[PATCH 23/25] NFS: Add AF_INET6 support to nfs_try_mount()

2007-11-13 Thread Chuck Lever
Update nfs_try_mount() to support AF_INET6 family addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 fs/nfs/super.c |   19 ++-
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 3ea4a4f..2abef88 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1048,7 +1048,7 @@ out_unknown:
 static int nfs_try_mount(struct nfs_parsed_mount_data *args,
 struct nfs_fh *root_fh)
 {
-   struct sockaddr_in sin;
+   struct sockaddr *sap = (struct sockaddr *)args-mount_server.address;
int status;
char *hostname;
 
@@ -1067,24 +1067,25 @@ static int nfs_try_mount(struct nfs_parsed_mount_data 
*args,
/*
 * Construct the mount server's address.
 */
-   if (args-mount_server.addrlen != 0)
-   memcpy(sin, args-mount_server.address, sizeof(sin));
-   else
-   memcpy(sin, args-nfs_server.address, sizeof(sin));
+   if (args-mount_server.addrlen == 0) {
+   memcpy(args-mount_server.address,
+  args-nfs_server.address,
+  args-nfs_server.addrlen);
+   args-mount_server.addrlen = args-nfs_server.addrlen;
+   }
 
/*
 * autobind will be used if mount_server.port == 0
 */
-   if (nfs_set_address_port((struct sockaddr *)sin,
-   args-mount_server.port))
+   if (nfs_set_address_port(sap, args-mount_server.port))
return -EAFNOSUPPORT;
 
/*
 * Now ask the mount server to map our export path
 * to a file handle.
 */
-   status = nfs_mount((struct sockaddr *) sin,
-  sizeof(sin),
+   status = nfs_mount(sap,
+  args-mount_server.addrlen,
   hostname,
   args-nfs_server.export_path,
   args-mount_server.version,

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/25] NFS: Parse IPv6 addresses in nfs_parse_server_address

2007-11-13 Thread Chuck Lever
Add the ability to parse IPv6 addresses passed in via the 'addr=' and
'mountaddr=' mount options.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/super.c |   24 +++-
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 2abef88..c066016 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -622,11 +622,25 @@ static void nfs_parse_server_address(char *value,
 struct sockaddr_storage *ssp,
 size_t *len)
 {
-   struct sockaddr_in *ap = (struct sockaddr_in *)ssp;
-
-   ap-sin_family = AF_INET;
-   ap-sin_addr.s_addr = in_aton(value);
-   *len = sizeof(*ap);
+   if (strchr(value, ':') == NULL) {
+   struct sockaddr_in *ap = (struct sockaddr_in *)ssp;
+   u8 buf[4];
+
+   if (in4_pton(value, -1, buf, '\0', NULL)) {
+   ap-sin_family = AF_INET;
+   memcpy(ap-sin_addr.s_addr, buf, sizeof(buf));
+   *len = sizeof(*ap);
+   }
+   } else {
+   struct sockaddr_in6 *ap = (struct sockaddr_in6 *)ssp;
+   u8 buf[16];
+
+   if (in6_pton(value, -1, buf, '\0', NULL)) {
+   ap-sin6_family = AF_INET6;
+   memcpy(ap-sin6_addr.in6_u, buf, sizeof(buf));
+   *len = sizeof(*ap);
+   }
+   }
 }
 
 /*

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/25] NFS: Verify IPv6 addresses properly

2007-11-13 Thread Chuck Lever
Add support to nfs_verify_server_address for recognizing AF_INET6 addresses.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfs/super.c |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c066016..f0af79b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -46,6 +46,7 @@
 #include linux/vfs.h
 #include linux/inet.h
 #include linux/in6.h
+#include net/ipv6.h
 #include linux/nfs_xdr.h
 #include linux/magic.h
 #include linux/parser.h
@@ -601,14 +602,14 @@ static int nfs_set_address_port(struct sockaddr *sap, 
unsigned short port)
  */
 static int nfs_verify_server_address(struct sockaddr_storage *ssp)
 {
-   struct sockaddr *addr = (struct sockaddr *)ssp;
-
-   switch (addr-sa_family) {
+   switch (ssp-ss_family) {
case AF_INET: {
-   struct sockaddr_in *sa = (struct sockaddr_in *) addr;
-   if (sa-sin_addr.s_addr != INADDR_ANY)
-   return 1;
-   break;
+   struct sockaddr_in *sa = (struct sockaddr_in *)ssp;
+   return sa-sin_addr.s_addr != INADDR_ANY;
+   }
+   case AF_INET6: {
+   struct in6_addr *sa = ((struct sockaddr_in6 *)ssp)-sin6_addr;
+   return !ipv6_addr_any(sa);
}
}
 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NET: Fix skb_truesize_check() assertion

2007-11-08 Thread Chuck Lever
The intent of the assertion in skb_truesize_check() is to check
for skb-truesize being decremented too much by other code,
resulting in a wraparound below zero.

The type of the right side of the comparison causes the compiler to
promote the left side to an unsigned type, despite the presence of an
explicit type cast.  This defeats the check for negativity.

Ensure both sides of the comparison are a signed type to prevent the
implicit type conversion.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 include/linux/skbuff.h |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 94e4991..91140fe 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -387,7 +387,9 @@ extern void   skb_truesize_bug(struct sk_buff *skb);
 
 static inline void skb_truesize_check(struct sk_buff *skb)
 {
-   if (unlikely((int)skb-truesize  sizeof(struct sk_buff) + skb-len))
+   int len = sizeof(struct sk_buff) + skb-len;
+
+   if (unlikely((int)skb-truesize  len))
skb_truesize_bug(skb);
 }
 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] NET: Remove unneeded type cast in skb_truesize_check()

2007-11-07 Thread Chuck Lever

David Miller wrote:

From: Chuck Lever [EMAIL PROTECTED]
Date: Mon, 05 Nov 2007 18:59:26 -0500


If that's truly the case, document the requirement (perhaps using
something the compiler itself can verify) instead of using a clever
type cast trick.


Feel free to submit such a change.


Here's what I propose.

skb-truesize should be an int, not an unsigned int, since you expect 
that it may go below zero.


Explicitly assert that skb-truesize is greater than zero in 
skb_truesize_check().


Explicitly assert that skb-len + sizeof(sk_buff) is less than INT_MAX.

Leave the assertion that's already there, but ensure that the types on 
both side of the comparison are as we expect.


Thoughts?

Here's the problem with leaving these little surprises in commonly used 
kernel headers.  Suppose the developer of a network driver or network 
file system that uses one of these headers wants to employ static code 
analysis to identify issues introduced by new patches to their 
subsystem.  The tool warnings generated in kernel headers are just 
noise, and make using such code analysis difficult.


Here's the problem with submitting patches fixing non-bugs and
removing useful assertions from kernel.  I won't apply them.


removing useful assertions

The (int) type cast in that assertion is nothing more than a comment. 
The compiler promotes that side of the comparison to match the type on 
the right side, and the explicit type cast is entirely ignored.  So in 
fact, my patch removed nothing but a mistaken assumption.  The assertion 
behaves the same after my patch as it did before.


Thus anyone might be confused at what exactly was being asserted in 
skb_truesize_check().  It's not a question of whether or not I reviewed 
the logic that uses skb-truesize before crafting my patch; I did review 
it.  The fact that skb_truesize_check() never before asserted that 
skb-truesize is greater than zero is not my fault.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
email;internet:chuck dot lever at nospam oracle dot com
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
version:2.1
end:vcard



Re: [PATCH] NET: Remove unneeded type cast in skb_truesize_check()

2007-11-05 Thread Chuck Lever

David Miller wrote:

From: Chuck Lever [EMAIL PROTECTED]
Date: Fri, 02 Nov 2007 15:14:26 -0400


The (int) type cast in skb_truesize_check() is unneeded: without it, all
the variable types in the conditional expression are unsigned integers.  As
it stands, the type cast causes a comparison between a signed and an
unsigned integer, which can produce unexpected results.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]


This is checking for skb-truesize being decremented too much by other
code, which could cause a wraparound below zero, so we do want
negaitve checks here.


If that's truly the case, document the requirement (perhaps using
something the compiler itself can verify) instead of using a clever
type cast trick.

Here's the problem with leaving these little surprises in commonly used 
kernel headers.  Suppose the developer of a network driver or network 
file system that uses one of these headers wants to employ static code 
analysis to identify issues introduced by new patches to their 
subsystem.  The tool warnings generated in kernel headers are just 
noise, and make using such code analysis difficult.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
version:2.1
end:vcard



[PATCH] NET: Remove unneeded type cast in skb_truesize_check()

2007-11-02 Thread Chuck Lever
The (int) type cast in skb_truesize_check() is unneeded: without it, all
the variable types in the conditional expression are unsigned integers.  As
it stands, the type cast causes a comparison between a signed and an
unsigned integer, which can produce unexpected results.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
---

 include/linux/skbuff.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 94e4991..7965216 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -387,7 +387,7 @@ extern void   skb_truesize_bug(struct sk_buff *skb);
 
 static inline void skb_truesize_check(struct sk_buff *skb)
 {
-   if (unlikely((int)skb-truesize  sizeof(struct sk_buff) + skb-len))
+   if (unlikely(skb-truesize  sizeof(struct sk_buff) + skb-len))
skb_truesize_bug(skb);
 }
 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NET: Make ts_recent_stamp and tw_ts_recent_stamp unsigned long

2007-11-02 Thread Chuck Lever
The get_seconds() function now returns an unsigned long.  KR states
that comparing a signed long with an unsigned long implicitly converts
the signed long to unsigned long [1].

Thus ts_recent_stamp and tw_ts_recent_stamp are already implicitly
converted to unsigned long in every comparison with get_seconds() or
other unsigned longs (such as tcp_ts_stamp).

Code review shows that ts_recent_stamp is compared only to get_seconds() or
zero.  It is set only to zero, the return value of get_seconds(), or the
value of tw_ts_recent_stamp.  Thus changing ts_recent_stamp to an unsigned
long does not change current behavior in any way, and eliminates implicit
type conversions in several places, including some comparisons.

Review shows that tw_ts_recent_stamp is set only to the return value of
get_seconds() or to the value of ts_recent_stamp.  It is compared to the
return value of get_seconds(), the value of tcp_ts_stamp (an unsigned
long), one, or zero.  Thus changing tw_ts_recent_stamp to an unsigned long
also does not change current behavior in any way.

It might improve matters even further if these open-coded timestamp
comparisons were replaced with something similar to the time_after_eq
macro from include/linux/jiffies.h.

[1] Kernighan  Ritchie, The C Programming Language, 2nd. ed., appendix
A, sec. 6.5.

Signed-off-by: Chuck Lever [EMAIL PROTECTED]
Cc: netdev@vger.kernel.org
---

 include/linux/tcp.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index bac17c5..0122374 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -206,7 +206,7 @@ struct tcp_sack_block {
 
 struct tcp_options_received {
 /* PAWS/RTTM data  */
-   longts_recent_stamp;/* Time we stored ts_recent (for aging) */
+   unsigned long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
u32 ts_recent;  /* Time stamp to echo next  */
u32 rcv_tsval;  /* Time stamp value */
u32 rcv_tsecr;  /* Time stamp echo reply*/
@@ -419,7 +419,7 @@ struct tcp_timewait_sock {
u32   tw_snd_nxt;
u32   tw_rcv_wnd;
u32   tw_ts_recent;
-   long  tw_ts_recent_stamp;
+   unsigned long tw_ts_recent_stamp;
 #ifdef CONFIG_TCP_MD5SIG
u16   tw_md5_keylen;
u8tw_md5_key[TCP_MD5SIG_MAXKEYLEN];

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [2.6 patch] make sunrpc/xprtsock.c:xs_setup_{udp,tcp}() static

2007-10-24 Thread Chuck Lever

Adrian Bunk wrote:

xs_setup_{udp,tcp}() can now become static.


ACK.  Sorry this was overlooked.


Signed-off-by: Adrian Bunk [EMAIL PROTECTED]

---

 include/linux/sunrpc/xprtsock.h |6 --
 net/sunrpc/xprtsock.c   |4 ++--
 2 files changed, 2 insertions(+), 8 deletions(-)

833a31c8caef70589f33be8e3a1fc9d8e01ce3c2 
diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h

index 2c6c2c2..c2a46c4 100644
--- a/include/linux/sunrpc/xprtsock.h
+++ b/include/linux/sunrpc/xprtsock.h
@@ -9,12 +9,6 @@
 
 #ifdef __KERNEL__
 
-/*

- * Socket transport setup operations
- */
-struct rpc_xprt *xs_setup_udp(struct xprt_create *args);
-struct rpc_xprt *xs_setup_tcp(struct xprt_create *args);
-
 intinit_socket_xprt(void);
 void   cleanup_socket_xprt(void);
 
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c

index 02298f5..2f630a5 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1828,7 +1828,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create 
*args,
  * @args: rpc transport creation arguments
  *
  */
-struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
+static struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
 {
struct sockaddr *addr = args-dstaddr;
struct rpc_xprt *xprt;
@@ -1894,7 +1894,7 @@ struct rpc_xprt *xs_setup_udp(struct xprt_create *args)
  * @args: rpc transport creation arguments
  *
  */
-struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
+static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
 {
struct sockaddr *addr = args-dstaddr;
struct rpc_xprt *xprt;



begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
email;internet:chuck dot lever at nospam oracle dot com
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
version:2.1
end:vcard



Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses

2007-08-23 Thread Chuck Lever

Hi Aurélien-

Aurélien Charbon wrote:

According to Neil's comments, I have tried to correct the mistakes of my first 
sending
Thank you for these comments Neil.

This is a small part of missing pieces of IPv6 support for the server.
It deals with the ip_map caching code part.

It changes the ip_map structure to be able to store INET6 addresses.
It adds also the changes in address hashing, and mapping to test it with INET 
addresses.

Signed-off-by: Aurelien Charbon [EMAIL PROTECTED]
---

 fs/nfsd/export.c   |   10 ++-
 fs/nfsd/nfsctl.c   |   21 ++-
 include/linux/sunrpc/svcauth.h |4 -
 include/net/ipv6.h |   17 +
 net/sunrpc/svcauth_unix.c  |  121 
-

 5 files changed, 129 insertions(+), 44 deletions(-)


diff -p -u -r -N linux-2.6.23-rc3/fs/nfsd/export.c 
linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/export.c

--- linux-2.6.23-rc3/fs/nfsd/export.c2007-08-23 13:18:16.0 +0200
+++ linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/export.c2007-08-23 
13:51:08.0 +0200

@@ -35,6 +35,7 @@
 #include linux/lockd/bind.h
 #include linux/sunrpc/msg_prot.h
 #include linux/sunrpc/gss_api.h
+#include net/ipv6.h
 
 #define NFSDDBG_FACILITYNFSDDBG_EXPORT
 
@@ -1559,6 +1560,7 @@ exp_addclient(struct nfsctl_client *ncp)

 {
 struct auth_domain*dom;
 inti, err;
+struct in6_addr addr6;
 
 /* First, consistency check. */

 err = -EINVAL;
@@ -1577,9 +1579,11 @@ exp_addclient(struct nfsctl_client *ncp)
 goto out_unlock;
 
 /* Insert client into hashtable. */

-for (i = 0; i  ncp-cl_naddr; i++)
-auth_unix_add_addr(ncp-cl_addrlist[i], dom);
-
+for (i = 0; i  ncp-cl_naddr; i++) {
+/* Mapping address */
+ipv6_addr_map(ncp-cl_addrlist[i], addr6);
+auth_unix_add_addr(addr6, dom);
+}
 auth_unix_forget_old(dom);
 auth_domain_put(dom);
 
diff -p -u -r -N linux-2.6.23-rc3/fs/nfsd/nfsctl.c 
linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c

--- linux-2.6.23-rc3/fs/nfsd/nfsctl.c2007-08-23 13:18:16.0 +0200
+++ linux-2.6.23-rc3-IPv6-ipmap-cache/fs/nfsd/nfsctl.c2007-08-23 
13:25:28.0 +0200

@@ -222,7 +222,7 @@ static ssize_t write_getfs(struct file *
 struct auth_domain *clp;
 int err = 0;
 struct knfsd_fh *res;
-
+struct in6_addr in6;
 if (size  sizeof(*data))
 return -EINVAL;
 data = (struct nfsctl_fsparm*)buf;
@@ -236,7 +236,14 @@ static ssize_t write_getfs(struct file *
 res = (struct knfsd_fh*)buf;
 
 exp_readlock();

-if (!(clp = auth_unix_lookup(sin-sin_addr)))
+
+/* IPv6 address mapping */
+in6.s6_addr32[0] = 0;
+in6.s6_addr32[1] = 0;
+in6.s6_addr32[2] = htonl(0x);
+in6.s6_addr32[3] = (uint32_t)sin-sin_addr.s_addr;
+
+if (!(clp = auth_unix_lookup(in6)))
 err = -EPERM;
 else {
 err = exp_rootfh(clp, data-gd_path, res, data-gd_maxlen);
@@ -253,6 +260,7 @@ static ssize_t write_getfd(struct file *
 {
 struct nfsctl_fdparm *data;
 struct sockaddr_in *sin;
+struct in6_addr in6;
 struct auth_domain *clp;
 int err = 0;
 struct knfsd_fh fh;
@@ -271,7 +279,14 @@ static ssize_t write_getfd(struct file *
 res = buf;
 sin = (struct sockaddr_in *)data-gd_addr;
 exp_readlock();
-if (!(clp = auth_unix_lookup(sin-sin_addr)))
+
+/* IPv6 address mapping */
+in6.s6_addr32[0] = 0;
+in6.s6_addr32[1] = 0;
+in6.s6_addr32[2] = htonl(0x);
+in6.s6_addr32[3] = (uint32_t)sin-sin_addr.s_addr;


The code canonicalizes IPv4 addresses in several places.  Is there 
already a generic function defined somewhere to do this?  If not, it 
might make sense to add one.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: [RFT] r8169 changes against 2.6.23-rc3

2007-08-20 Thread Chuck Lever

Francois Romieu wrote:

The latest serie of r8169 changes is available against 2.6.23-rc3 as:
http://www.fr.zoreil.com/people/francois/misc/20070818-2.6.23-rc3-r8169-test.patch 


or (tarball sits one level higher):

http://www.fr.zoreil.com/linux/kernel/2.6.x/2.6.23-rc3/r8169-20070818/

or (rebase prone branch)

git://electric-eye.fr.zoreil.com/home/romieu/linux-2.6.git#r8169
 
Please do not clone your whole git kernel tree from here, thanks.


Changes (most recent first):

- eeprom read support
- phy init cleanup
- PHY init for the 8168
- make room for more PHY init changes
- remove dead wood
- add MAC identifiers
- MSI support
- correct phy parameters for the 8110SC

The first patch of the serie (correct phy parameters for the 8110SC) has
been elaborated with Edward Hsu from Realtek and it should help some owners
of 8169 chipsets. If there is no report of regression for it on any
chispet and it is reported to fix someone's problems, I will send it to
Jeff Garzik for inclusion in 2.6.23 as a bugfix.

Anything else in this serie has not been tested on a wide scale nor acked
by the manufacturer: I consider it post 2.6.23 material. That being said,
the MSI changes seem fine and the PHY init for the 8168 patch could make
a difference for the users of the 8168 whose link is not properly
negotiated.

Success and failure reports or patches will be welcome. Please Cc: netdev
and include r8169 in the Subject.


Tested 2.6.23-rc3 plus your patch on my dual-R8169 mini-ITX Jetway 
J7F4K1G2E mainboard.  No problems to report.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: [NFS] [Bugme-new] [Bug 8891] New: in-kernel rpc generates broken RPCBPROC_GETVERSADDR v4 requests

2007-08-15 Thread Chuck Lever

Andrew Morton wrote:

On Wed, 15 Aug 2007 12:22:51 -0700 (PDT)
[EMAIL PROTECTED] wrote:


http://bugzilla.kernel.org/show_bug.cgi?id=8891

   Summary: in-kernel rpc generates broken RPCBPROC_GETVERSADDR v4
requests
   Product: Networking
   Version: 2.5
 KernelVersion: 2.6.22.1
  Platform: All
OS/Version: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: Other
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]


Most recent kernel where this bug did not occur: 2.6.20


Apparently a regression.


RPCBIND v4 requests are an experimental feature.  They can be disabled 
via a kernel build option (CONFIG_SUNRPC_BIND34).  I think these are 
left enabled in Fedora to find just the type of problem before v3 and v4 
becomes the default.



Distribution: Fedora Core 6
Hardware Environment: x86_64
Software Environment: NFS
Problem Description: When locking a file, an invalid RPCBPROC_GETVERSADDR
procedure call is sent out

Steps to reproduce:
on the NFS server, run: tcpdump -xX -pni eth0 -s0 port 111 and src host
theNFSclient
on a client running 2.6.22.1, run: flock -x /nfsmount/somefile ls
tcpdump will show:

17:10:01.290655 IP 141.2.15.141.34572  141.2.1.1.sunrpc: P 0:168(168) ack 1
win 183 nop,nop,timestamp 966695 115079499
0x:  4500 00dc 53ad 4000 3f06 bcdc 8d02 0f8d  [EMAIL PROTECTED]
0x0010:  8d02 0101 870c 006f cdcd 938d db00 c8a7 
...o

0x0020:  8018 00b7 e59d  0101 080a 000e c027  ...'
0x0030:  06db f94b 8000 00a4 fd48 2a07    ...K.H*.
0x0040:   0002 0001 86a0  0004  0009  
0x0050:   0001  0054  03c6  0007  ...T
0x0060:  6572 6964 796b 6500      eridyke.
0x0070:   000e    0001  0002  
0x0080:   0003  0004  0005  0006  
0x0090:   0007  0007  0009  000a  
0x00a0:   000c  0014  001c    
0x00b0:    0001 86b5  0004  0003  
0x00c0:  7463 7000  0009 3134 312e 322e 312e  tcp.141.2.1.
0x00d0:  3100   0004 7270 63621...rpcb

Note the 141.2.1.1 in the output.

According to RFC 1833, you can read here the following fields:

RPCBPROC_GETVERSADDR version 4 procedure is being called
r_prog == 0x000186b5 == 100021 == nfs.lockd
r_vers == 4
r_netid == (length 3) tcp
r_addr == (length 9) 141.2.1.1
r_owner == (length 4) rpcb

This r_addr member is supposed to contain an universal address. Although I have
no source for that, the RFC clearly says a service can listen to an address,
and RPCBPROC_GETVERSADDR is supposed to return an universal address too. From
this I can conclude that an universal address is supposed to contain the port
number, and other operating systems are using the format
a.b.c.d.PortHighByte.PortLowByte (like in FTP, but with . instead of ,). I
interpret the RFC 1833 so that the port number of the rpcbind, that is, 111, is
to be appended, so the correct value of r_addr would be 141.2.1.1.0.111. This
matches other implementations.


That RFC is unclear on exactly what a universal address should look 
like.  However speidel's interpretation is not unreasonable, and I'm 
glad he was able to check this against other implementations that I 
don't have.  My unit testing against Solaris did not reveal this issue.


I'll look into the problem.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: RealTek 8169 support question

2007-08-13 Thread Chuck Lever

Francois Romieu wrote:

Chuck Lever [EMAIL PROTECTED] :
[...]
Not yet.  I wanted to check with the Maintainer to see if it was worth 
trying.  :-)  The last time I tried a kernel build on one of these 


It is worth trying.


FYI: I tested a 2.6.23-rc2 kernel over the weekend, and the NICs worked 
without issue.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



RealTek 8169 support question

2007-08-10 Thread Chuck Lever

Hello Francois-

I just bought a new Jetway mainboard with a pair of RTL 8169 NICs. 
After installing Fedora 7, and upgrading to 2.6.22.1-41.fc7, I still 
can't get either of the NICs to recognize a link beat from my switch.


lspci -v output:

00:09.0 Ethernet controller: Realtek Semiconductor Co., Ltd. 
RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

Subsystem: Jetway Information Co., Ltd. Unknown device 10ec
Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 18
I/O ports at ee00 [size=256]
Memory at fdffe000 (32-bit, non-prefetchable) [size=256]
[virtual] Expansion ROM at 1002 [disabled] [size=64K]
Capabilities: [dc] Power Management version 2

00:0b.0 Ethernet controller: Realtek Semiconductor Co., Ltd. 
RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

Subsystem: Jetway Information Co., Ltd. Unknown device 10ec
Flags: bus master, 66MHz, medium devsel, latency 32, IRQ 19
I/O ports at f000 [size=256]
Memory at fdffd000 (32-bit, non-prefetchable) [size=256]
[virtual] Expansion ROM at 1003 [disabled] [size=64K]
Capabilities: [dc] Power Management version 2

I assume Unknown device indicates that the driver doesn't recognize 
the model string?


Thanks in advance for any advice.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: RealTek 8169 support question

2007-08-10 Thread Chuck Lever

Francois Romieu wrote:

Chuck Lever [EMAIL PROTECTED] :
[...]
I just bought a new Jetway mainboard with a pair of RTL 8169 NICs. 


Mini-ITX J7F4 ?


Yes.  I wanted a low-power DSL router that will support IPv6 and have a 
familiar GUI.



Have your tried 2.6.23-git-latest or at least a post 2.6.23-rc1 kernel ?


Not yet.  I wanted to check with the Maintainer to see if it was worth 
trying.  :-)  The last time I tried a kernel build on one of these 
little Via processors, it took forever.  Will give it a shot.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses

2007-08-09 Thread Chuck Lever

Aurélien Charbon wrote:

Here is a small part of missing pieces of IPv6 support for the server.
It deals with the ip_map caching code part.

It changes the ip_map structure to be able to store INET6 addresses.
It adds also the changes in address hashing, and mapping to test it with 
INET addresses.


Thanks for posting your patch.

Your strategy is to convert all incoming IPv4 addresses in the ip_map 
cache to IPv6 addresses, and use only IPv6 internally (often suggested 
by IPv6 books I've encountered).  For NFS, that is problematic because 
these addresses are used as the target of access control rules for 
exports; thus sys admins will expect to see IPv4 addresses in the output 
of NFS utilities if they specified IPv4 addresses in their /etc/exports 
file, for example.


Some naive questions:

1.  If IPv6 support is not configured into the kernel, how does an 
IPv6-only cache work?


2.  I seem to recall (only quite vaguely) that at some point the server 
might need to use one of the stored addresses to, say, open a socket to 
the client?  In that case, on a system with NICs configured only with 
IPv4, is the cached IPv6 address properly converted back to IPv4 
somehow?  Can the cache code tell the difference between a cached IPv6 
address that was converted from IPv4 and one that was added to the cache 
as IPv6?  Sorry I can't remember more clearly.


3.  Would it be better to make the m_addr field a struct sockaddr, store 
a whole address (with address family), and switch on the sa_family field?


diff -u -r -N linux-2.6.23-rc1/fs/nfsd/export.c 
linux-2.6.23-rc1-IPv6-ip_map/fs/nfsd/export.c

--- linux-2.6.23-rc1/fs/nfsd/export.c2007-08-08 17:52:58.0 +0200
+++ linux-2.6.23-rc1-IPv6-ip_map/fs/nfsd/export.c2007-08-08 
17:49:09.0 +0200

@@ -1558,6 +1558,7 @@
 {
 struct auth_domain*dom;
 inti, err;
+struct in6_addr addr6;
 
 /* First, consistency check. */

 err = -EINVAL;
@@ -1576,9 +1577,14 @@
 goto out_unlock;
 
 /* Insert client into hashtable. */

-for (i = 0; i  ncp-cl_naddr; i++)
-auth_unix_add_addr(ncp-cl_addrlist[i], dom);
-
+for (i = 0; i  ncp-cl_naddr; i++) {
+/* Mapping address */
+addr6.s6_addr32[0] = 0;
+addr6.s6_addr32[1] = 0;
+addr6.s6_addr32[2] = htonl(0x);
+addr6.s6_addr32[3] = (uint32_t)ncp-cl_addrlist[i].s_addr;
+auth_unix_add_addr(addr6, dom);
+}
 auth_unix_forget_old(dom);
 auth_domain_put(dom);


This converts IPv4 addresses to canonical IPv6 as it stores them.  What 
happens if a full-blown IPv6 address is encountered?  Likewise, in nfsctl.c?



@@ -112,12 +112,16 @@
 return (hash ^ (hash8))  0xff;
 }
 #endif
+static inline int hash_ip6(struct in6_addr ip)
+{
+return (hash_ip(ip.s6_addr32[0]) ^ hash_ip(ip.s6_addr32[1]) ^ 
hash_ip(ip.s6_addr32[2]) ^ hash_ip(ip.s6_addr32[3])) ;

+}


How have you tested the effectiveness of the new hash function?


@@ -151,20 +155,28 @@
 {
 char text_addr[20];
 struct ip_map *im = container_of(h, struct ip_map, h);
-__be32 addr = im-m_addr.s_addr;
+   
+__be32 addr[4];

+int i;
+for (i=0;i4;i++)
+addr[i] = im-m_addr.s6_addr[i];
 
-snprintf(text_addr, 20, %u.%u.%u.%u,

- ntohl(addr)  24  0xff,
- ntohl(addr)  16  0xff,
- ntohl(addr)   8  0xff,
- ntohl(addr)   0  0xff);
+snprintf(text_addr, 20, %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x,
+ntohl(addr[3])  16  0xff,
+ntohl(addr[3])   0  0xff,
+ntohl(addr[2])  16  0xff,
+ntohl(addr[2])   0  0xff,
+ntohl(addr[1])  16  0xff,
+ntohl(addr[1])   0  0xff,
+ntohl(addr[0])  16  0xff,
+ntohl(addr[0])   0  0xff);


The snprintf() format strings should use NIP6_FMT.


@@ -197,8 +209,21 @@
 len = qword_get(mesg, buf, mlen);
 if (len = 0) return -EINVAL;
 
-if (sscanf(buf, %u.%u.%u.%u%c, b1, b2, b3, b4, c) != 4)

-return -EINVAL;
+if (sscanf(buf, %d.%d.%d.%d%c, b1, b2, b3, b4, c) == 4) {
+   addr.s6_addr32[0] = 0;
+   addr.s6_addr32[1] = 0;
+   addr.s6_addr32[2] = htonl(0x);
+   addr.s6_addr32[3] =
+   htonl((b18)|b2)8)|b3)8)|b4);
+   } else if (sscanf(buf, %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x%c,
+ b1, b2, b3, b4, b5, b6, b7, b8, c) == 
8) {

+   addr.s6_addr32[0] = htonl((b116)|b2);
+   addr.s6_addr32[1] = htonl((b316)|b4);
+   addr.s6_addr32[2] = htonl((b516)|b6);
+   addr.s6_addr32[3] = htonl((b716)|b8);
+   } else
+return -EINVAL;
+


Likewise, the sscanf() format strings should use NIP6_FMT.


@@ -247,18 +269,22 @@
 }
 im = container_of(h, struct ip_map, h);
 /* class addr domain */
-addr = im-m_addr;
+memcpy(addr, im-m_addr, sizeof(struct in6_addr));
 
 if 

Re: [PATCH 1/1] NFS: change the ip_map cache code to handle IPv6 addresses

2007-08-09 Thread Chuck Lever

Aurélien Charbon wrote:

@@ -112,12 +112,16 @@
 return (hash ^ (hash8))  0xff;
 }
 #endif
+static inline int hash_ip6(struct in6_addr ip)
+{
+return (hash_ip(ip.s6_addr32[0]) ^ hash_ip(ip.s6_addr32[1]) 
^ hash_ip(ip.s6_addr32[2]) ^ hash_ip(ip.s6_addr32[3])) ;

+}



How have you tested the effectiveness of the new hash function?


I have not tested that point but I can easily imagine there are better 
solutions.
Perhaps we can keep the same function for an IPv4 address (only taking 
the 32 bits of IPv4 addr), and then design one for IPv6 addresses.


I see that, to generate the hash, you would be xor-ing the FF and 00 
bytes in the canonicalized IPv4 address.  Yes, perhaps a better function 
is needed, or as you say, one specifically for IPv6 and one for 
canonicalized IPv4.



Do you have any suggestion on that ?


I don't have anything specific, but you may find something useful if you 
poke around elsewhere under net/.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard



Re: [2.6 patch] net/sunrpc/rpcb_clnt.c: make struct rpcb_program static

2007-06-12 Thread Chuck Lever

Adrian Bunk wrote:

This patch makes the needlessly global struct rpcb_program static.

Signed-off-by: Adrian Bunk [EMAIL PROTECTED]


Acked-by: Chuck Lever [EMAIL PROTECTED]


---

 net/sunrpc/rpcb_clnt.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.22-rc4-mm2/net/sunrpc/rpcb_clnt.c.old 2007-06-12 
23:25:01.0 +0200
+++ linux-2.6.22-rc4-mm2/net/sunrpc/rpcb_clnt.c 2007-06-12 23:25:19.0 
+0200
@@ -118,7 +118,7 @@
 #define RPCB_MAXOWNERLEN   sizeof(RPCB_OWNER_STRING)
 
 static void			rpcb_getport_done(struct rpc_task *, void *);

-extern struct rpc_program  rpcb_program;
+static struct rpc_program  rpcb_program;
 
 struct rpcbind_args {

struct rpc_xprt *   r_xprt;
@@ -616,7 +616,7 @@
 
 static struct rpc_stat rpcb_stats;
 
-struct rpc_program rpcb_program = {

+static struct rpc_program rpcb_program = {
.name   = rpcbind,
.number = RPCBIND_PROGRAM,
.nrvers = ARRAY_SIZE(rpcb_version),



begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group
adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA
title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel/
version:2.1
end:vcard



choosing IPv4 or IPv6 when creating a listening socket

2006-03-03 Thread Chuck Lever

hello all-

i'm helping implement support for IPv6 in the Linux RPC server.  i have 
a couple of naive questions about creating a listening socket on a 
kernel that has IPv6 support.


normally you will specify a sockaddr_in with address INADDR_ANY when 
setting up an IPv4 listener.


what address do you specify for creating an IPv6 listener?  it looks 
like all zeroes is the right answer...?


if the host has both IPv4 and IPv6 addresses assigned to it, how should 
the RPC server determine whether to create an IPv6 listener or an IPv4 
listener?


the specific code i'm attempting to update is net/sunrpc/svcsock.c:
svc_makesock().

thanks for any advice.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Network Appliance, Incorporated;Open Source NFS Client Engineering
email;internet:[EMAIL PROTECTED]
title:Member of Technical Staff
x-mozilla-html:FALSE
url:http://www.monkey.org/~cel
version:2.1
end:vcard