public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Labiaga, Ricardo" <ricardo.labiaga@netapp.com>
To: Ricardo Labiaga <ricardo.labiaga@netapp.com>,
	Trond Myklebust <Trond.Myklebust@netapp.com>,
	Benny Halevy <bhalevy@panasas.com>
Cc: <linux-nfs@vger.kernel.org>, <pnfs@linux-nfs.org>
Subject: Re: [pnfs] [RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation
Date: Mon, 15 Jun 2009 19:40:09 -0700	[thread overview]
Message-ID: <C65C5419.7CFE%ricardo.labiaga@netapp.com> (raw)
In-Reply-To: <C65C3888.7CB1%ricardo.labiaga@netapp.com>

On 6/15/09 5:42 PM, "Ricardo Labiaga" <ricardo.labiaga@netapp.com> wrote:

> On 6/15/09 5:27 PM, "Trond Myklebust" <Trond.Myklebust@netapp.com> wrote:
> 
>> On Fri, 2009-05-01 at 02:25 +0300, Benny Halevy wrote:
>>> From: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
>>> 
>>> Validates the callback's sessionID, the slot number, and the sequence ID.
>>> Increments the slot's sequence.
>>> 
>>> Detects replays, but simply prints a debug message (if debugging is enabled
>>> since we don't yet implement a duplicate request cache for the backchannel.
>>> This should not present a problem, since only idempotent callbacks are
>>> currently implemented.
>>> 
>>> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
>>> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
>>> ---
>>>  fs/nfs/callback_proc.c |   75
>>> ++++++++++++++++++++++++++++++++++++++++++++----
>>>  1 files changed, 69 insertions(+), 6 deletions(-)
>>> 
>>> diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
>>> index 6b342e8..c85d66f 100644
>>> --- a/fs/nfs/callback_proc.c
>>> +++ b/fs/nfs/callback_proc.c
>>> @@ -105,6 +105,57 @@ out:
>>>  #if defined(CONFIG_NFS_V4_1)
>>>  
>>>  /*
>>> + * Validate the sequenceID sent by the server.
>>> + * Return success if the sequenceID is one more than what we last saw on
>>> + * this slot, accounting for wraparound.  Increments the slot's sequence.
>>> + *
>>> + * We don't yet implement a duplicate request cache, so at this time
>>> + * we will log replays, and process them as if we had not seen them before,
>>> + * but we don't bump the sequence in the slot.  Not too worried about it,
>>> + * since we only currently implement idempotent callbacks anyway.
>>> + *
>>> + * We have a single slot backchannel at this time, so we don't bother
>>> + * checking the used_slots bit array on the table.  The lower layer
>>> guarantees
>>> + * a single outstanding callback request at a time.
>>> + */
>>> +static int
>>> +validate_seqid(struct nfs4_slot_table *tbl, u32 slotid, u32 seqid)
>>> +{
>>> + struct nfs4_slot *slot;
>>> +
>>> + dprintk("%s enter. slotid %d seqid %d\n",
>>> +  __func__, slotid, seqid);
>>> +
>>> + if (slotid > NFS41_BC_MAX_CALLBACKS)
>>> +  return NFS4ERR_BADSLOT;
>> 
>> I thought we agreed to always return error values as _negative_? Why the
>> change here?
>> 
> 
> Will change to negative.
> 

Looking at this more closely, this is the error that we encode into the XDR
result, so it's okay for it to be positive.  I'll change it to use htonl()
in this function to avoid confusion, instead of setting htonl() in its
caller.

- ricardo

> - ricardo
> 
>>> +
>>> + slot = tbl->slots + slotid;
>>> + dprintk("%s slot table seqid: %d\n", __func__, slot->seq_nr);
>>> +
>>> + /* Normal */
>>> + if (likely(seqid == slot->seq_nr + 1)) {
>>> +  slot->seq_nr++;
>>> +  return NFS4_OK;
>>> + }
>>> +
>>> + /* Replay */
>>> + if (seqid == slot->seq_nr) {
>>> +  dprintk("%s seqid %d is a replay - no DRC available\n",
>>> +   __func__, seqid);
>>> +  return NFS4_OK;
>>> + }
>>> +
>>> + /* Wraparound */
>>> + if (seqid == 1 && (slot->seq_nr + 1) == 0) {
>>> +  slot->seq_nr = 1;
>>> +  return NFS4_OK;
>>> + }
>>> +
>>> + /* Misordered request */
>>> + return NFS4ERR_SEQ_MISORDERED;
>>> +}
>>> +
>>> +/*
>>>   * Returns a pointer to a held 'struct nfs_client' that matches the
>>> server's
>>>   * address, major version number, and session ID.  It is the caller's
>>>   * responsibility to release the returned reference.
>>> @@ -140,18 +191,27 @@ out:
>>> return NULL;
>>>  }
>>>  
>>> -/* FIXME: validate args->cbs_{sequence,slot}id */
>>>  /* FIXME: referring calls should be processed */
>>>  unsigned nfs4_callback_sequence(struct cb_sequenceargs *args,
>>> struct cb_sequenceres *res)
>>>  {
>>> - int i;
>>> - unsigned status = 0;
>>> + struct nfs_client *clp;
>>> + int i, status;
>>>  
>>> for (i = 0; i < args->csa_nrclists; i++)
>>> kfree(args->csa_rclists[i].rcl_refcalls);
>>> kfree(args->csa_rclists);
>>>  
>>> + status = NFS4ERR_BADSESSION;
>>> + clp = find_client_with_session(args->csa_addr, 4, &args->csa_sessionid);
>>> + if (clp == NULL)
>>> +  goto out;
>>> +
>>> + status = validate_seqid(&clp->cl_session->bc_slot_table,
>>> +    args->csa_slotid, args->csa_sequenceid);
>>> + if (status)
>>> +  goto out_putclient;
>>> +
>>> memcpy(&res->csr_sessionid, &args->csa_sessionid,
>>>       sizeof(res->csr_sessionid));
>>> res->csr_sequenceid = args->csa_sequenceid;
>>> @@ -159,9 +219,12 @@ unsigned nfs4_callback_sequence(struct cb_sequenceargs
>>> *args,
>>> res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
>>> res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
>>>  
>>> - dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
>>> - res->csr_status = status;
>>> - return status;
>>> +out_putclient:
>>> + nfs_put_client(clp);
>>> +out:
>>> + dprintk("%s: exit with status = %d\n", __func__, status);
>>> + res->csr_status = htonl(status);
>>> + return res->csr_status;
>>>  }
>>>  
>>>  #endif /* CONFIG_NFS_V4_1 */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


      reply	other threads:[~2009-06-16  2:40 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-30 23:17 [RFC 0/39] nfs41 client backchannel for 2.6.31 Benny Halevy
2009-04-30 23:19 ` [RFC 01/39] nfs41: Add ability to read RPC call direction on TCP stream Benny Halevy
2009-04-30 23:19 ` [RFC 02/39] nfs41: Skip past the RPC call direction Benny Halevy
2009-06-03 21:30   ` [pnfs] " Trond Myklebust
     [not found]     ` <1244064624.5603.53.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-03 23:30       ` Labiaga, Ricardo
2009-04-30 23:19 ` [RFC 03/39] nfs41: Refactor nfs4_{init,destroy}_callback for nfs4.0 Benny Halevy
2009-04-30 23:19 ` [RFC 04/39] nfs41: minorversion support for nfs4_{init,destroy}_callback Benny Halevy
2009-06-04  2:39   ` [pnfs] [RFC 04/39] nfs41: minorversion support for nfs4_{init, destroy}_callback Trond Myklebust
     [not found]     ` <1244083198.5603.354.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-04 18:13       ` Labiaga, Ricardo
2009-04-30 23:19 ` [RFC 05/39] nfs41: client callback structures Benny Halevy
2009-04-30 23:20 ` [RFC 06/39] nfs41: Initialize new rpc_xprt callback related fields Benny Halevy
2009-04-30 23:20 ` [RFC 07/39] nfs41: New backchannel helper routines Benny Halevy
2009-04-30 23:20 ` [RFC 08/39] nfs41: New include/linux/sunrpc/bc_xprt.h Benny Halevy
2009-04-30 23:20 ` [RFC 09/39] nfs41: New xs_tcp_read_data() Benny Halevy
2009-04-30 23:20 ` [RFC 10/39] nfs41: Add backchannel processing support to RPC state machine Benny Halevy
2009-06-04 19:54   ` [pnfs] " Trond Myklebust
     [not found]     ` <1244145285.5203.94.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-05 17:44       ` Labiaga, Ricardo
     [not found]         ` <273FE88A07F5D445824060902F7003440612B896-hX7t0kiaRRpT+ZUat5FNkAK/GNPrWCqfQQ4Iyu8u01E@public.gmane.org>
2009-06-11 23:35           ` [pnfs] [RFC 10/39] nfs41: Add backchannel processing support toRPC " Labiaga, Ricardo
2009-04-30 23:20 ` [RFC 11/39] nfs41: Backchannel callback service helper routines Benny Halevy
2009-06-04 20:20   ` [pnfs] " Trond Myklebust
     [not found]     ` <1244146842.5203.101.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-05 18:02       ` Labiaga, Ricardo
2009-04-30 23:21 ` [RFC 12/39] nfs41: Refactor svc_process() Benny Halevy
2009-04-30 23:21 ` [RFC 13/39] nfs41: Backchannel bc_svc_process() Benny Halevy
2009-04-30 23:21 ` [RFC 14/39] nfs41: Implement NFSv4.1 callback service process Benny Halevy
2009-06-04 20:18   ` [pnfs] " Trond Myklebust
     [not found]     ` <1244146681.5203.99.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-05 17:57       ` Labiaga, Ricardo
2009-04-30 23:21 ` [RFC 15/39] nfs41: sunrpc: provide functions to create and destroy a svc_xprt for backchannel use Benny Halevy
2009-04-30 23:21 ` [RFC 16/39] nfs41: sunrpc: add a struct svc_xprt pointer to struct svc_serv " Benny Halevy
2009-04-30 23:22 ` [RFC 17/39] nfs41: create a svc_xprt for nfs41 callback thread and use for incoming callbacks Benny Halevy
2009-04-30 23:22 ` [RFC 18/39] nfs41: save svc_serv in nfs_callback_info Benny Halevy
2009-04-30 23:22 ` [RFC 19/39] nfs41: Allow NFSv4 and NFSv4.1 callback services to coexist Benny Halevy
2009-04-30 23:22 ` [RFC 20/39] nfs41: Setup the backchannel Benny Halevy
2009-04-30 23:22 ` [RFC 21/39] nfs41: Client indicates presence of NFSv4.1 callback channel Benny Halevy
2009-04-30 23:22 ` [RFC 22/39] nfs41: Get the rpc_xprt * from the rpc_rqst instead of the rpc_clnt Benny Halevy
2009-04-30 23:22 ` [RFC 23/39] nfs41: Release backchannel resources associated with session Benny Halevy
2009-04-30 23:23 ` [RFC 24/39] nfs41: store minorversion in cb_compound_hdr_arg Benny Halevy
2009-04-30 23:23 ` [RFC 25/39] nfs41: decode minorversion 1 cb_compound header Benny Halevy
2009-06-16  0:13   ` [pnfs] " Trond Myklebust
2009-06-16  1:07     ` Halevy, Benny
2009-04-30 23:23 ` [RFC 26/39] nfs41: callback numbers definitions Benny Halevy
2009-04-30 23:23 ` [RFC 27/39] nfs41: consider minorversion in callback_xdr:process_op Benny Halevy
2009-06-16  0:15   ` [pnfs] " Trond Myklebust
2009-04-30 23:23 ` [RFC 28/39] nfs41: define CB_NOTIFY_DEVICEID as not supported Benny Halevy
2009-04-30 23:24 ` [RFC 29/39] nfs41: cb_sequence protocol level data structures Benny Halevy
2009-04-30 23:24 ` [RFC 30/39] nfs41: cb_sequence proc implementation Benny Halevy
2009-04-30 23:24 ` [RFC 31/39] nfs41: cb_sequence xdr implementation Benny Halevy
2009-06-16  0:18   ` [pnfs] " Trond Myklebust
2009-06-16  2:25     ` Halevy, Benny
     [not found]       ` <7225594ED4A1304C9E43D030A886D221F4C55A-QcknvLX4j1suWLk7KE+CsC1byIy0dIec@public.gmane.org>
2009-06-16 17:58         ` Trond Myklebust
2009-04-30 23:24 ` [RFC 32/39] nfs41: verify CB_SEQUENCE position in callback compound Benny Halevy
2009-04-30 23:24 ` [RFC 33/39] nfs41: Rename rq_received to rq_reply_bytes_recvd Benny Halevy
2009-04-30 23:25 ` [RFC 34/39] nfs41: Backchannel: update cb_sequence args and results Benny Halevy
2009-04-30 23:25 ` [RFC 35/39] nfs41: Backchannel: Refactor nfs4_reset_slot_table() Benny Halevy
2009-04-30 23:25 ` [RFC 36/39] nfs41: Backchannel: Refactor nfs4_init_slot_table() Benny Halevy
2009-04-30 23:25 ` [RFC 37/39] nfs41: Backchannel: Add a backchannel slot table to the session Benny Halevy
2009-04-30 23:25 ` [RFC 38/39] nfs41: Backchannel: New find_client_with_session() Benny Halevy
2009-04-30 23:25 ` [RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation Benny Halevy
2009-06-16  0:27   ` [pnfs] " Trond Myklebust
     [not found]     ` <1245112062.7470.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-06-16  0:42       ` Labiaga, Ricardo
2009-06-16  2:40         ` Labiaga, Ricardo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C65C5419.7CFE%ricardo.labiaga@netapp.com \
    --to=ricardo.labiaga@netapp.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bhalevy@panasas.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=pnfs@linux-nfs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox