Esempio n. 1
0
def testBadSeqnum1(t, env):
    """Send too large seqnum
    
    FLAGS: create_session all
    CODE: CSESS7
    """
    c = env.c1.new_client(env.testname(t))
    res1 = create_session(c.c, c.clientid, c.seqid)
    check(res1)
    # REPLAY
    badseqid = nfs4lib.inc_u32(nfs4lib.inc_u32(c.seqid))
    res2 = create_session(c.c, c.clientid, badseqid)
    check(res2, NFS4ERR_SEQ_MISORDERED)
Esempio n. 2
0
def testBadSeqnum1(t, env):
    """Send too large seqnum
    
    FLAGS: create_session all
    CODE: CSESS7
    """
    c = env.c1.new_client(env.testname(t))
    res1 = create_session(c.c, c.clientid, c.seqid)
    check(res1)
    # REPLAY
    badseqid = nfs4lib.inc_u32(nfs4lib.inc_u32(c.seqid))
    res2 = create_session(c.c, c.clientid, badseqid)
    check(res2, NFS4ERR_SEQ_MISORDERED)
Esempio n. 3
0
def testReuseSlotID(t, env):
    """ If client reuses a slot ID and sequence ID for a completely
        different request, server MAY treat the request as if it is
        a retry of what it has already executed. rfc5661 18.46.3

    FLAGS: sequence all
    CODE: SEQ14
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION
    sess1 = c.create_session()

    name = "%s_1" % env.testname(t)
    res = create_file(sess1, name)
    check(res)

    sid = sess1.sessionid
    seqid = nfs4lib.inc_u32(sess1.seqid)
    dir = sess1.c.homedir

    res = c.c.compound([op.sequence(sid, seqid, 0, 0, TRUE)] +
                       nfs4lib.use_obj(dir) + [op.remove(name)])
    check(res)

    # Reuses slot ID and sequence ID for different request
    res = c.c.compound([op.sequence(sid, seqid, 0, 0, TRUE)] +
                       nfs4lib.use_obj(dir) + [op.rename(name, "test")])
    check(res)
    def get_id(self, cb=False):
        """Return stateid4 associated with this state.

        NOTE assumes lock is held.
        """
        if cb:
            # seqid zeroed for callbacks per draft22 8.2.2
            return stateid4(0, self.other)
        else:
            # BUG - only increment if has changed
            # NOTE - careful about only inc if change, see draft22 9.9
            self.seqid = nfs4lib.inc_u32(self.seqid)
            return stateid4(self.seqid, self.other)
Esempio n. 5
0
    def get_id(self, cb=False):
        """Return stateid4 associated with this state.

        NOTE assumes lock is held.
        """
        if cb:
            # seqid zeroed for callbacks per draft22 8.2.2
            return stateid4(0, self.other)
        else:
            # BUG - only increment if has changed
            # NOTE - careful about only inc if change, see draft22 9.9
            self.seqid = nfs4lib.inc_u32(self.seqid)
            return stateid4(self.seqid, self.other)
Esempio n. 6
0
 def op_cb_sequence(self, arg, env):
     log_cb.info("In CB_SEQUENCE")
     if env.index != 0:
         return encode_status(NFS4ERR_SEQUENCE_POS)
     session = self.sessions.get(arg.csa_sessionid, None)
     if session is None:
         return encode_status(NFS4ERR_BADSESSION)
     # STUB - check connectino binding and creds
     channel = session.back_channel
     # STUB bounds checking
     try:
         slot = channel.slots[arg.csa_slotid]
     except IndexError:
         return encode_status(NFS4ERR_BADSLOT)
     env.cache = slot.check_seqid(arg.csa_sequenceid)
     # AT this point we are not allowed to return an error
     env.caching = arg.csa_cachethis
     env.session = session
     res = CB_SEQUENCE4resok(session.sessionid, inc_u32(slot.seqid),
                             arg.csa_slotid,
                             channel.maxrequests, channel.maxrequests)# STUB
     res = self.posthook(arg, env, res)
     return encode_status(NFS4_OK, res)
Esempio n. 7
0
 def _add_session(self, csr):
     self.seqid = inc_u32(csr.csr_sequence) # XXX Do we need to check this?
     sess = SessionRecord(csr, self)
     self.c.sessions[sess.sessionid] = sess
     return sess