git: a6f3979ad192 - stable/13 - nfscl: Fix handling of nd_slotid while handling NFSERR_BADSESSION

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Fri, 02 Sep 2022 01:56:05 UTC
The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=a6f3979ad1923b7e742a6b4464917c9baea5b058

commit a6f3979ad1923b7e742a6b4464917c9baea5b058
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-08-27 23:03:18 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-09-02 01:52:59 +0000

    nfscl: Fix handling of nd_slotid while handling NFSERR_BADSESSION
    
    When the NFSv4.1/4.2 client is handling a server error
    of NFSERR_BADSESSION, it retries RPCs with a new session.
    Without this patch, the nd_slotid was not being updated
    for the new session.
    
    This would result in a bogus console message like
    "Wrong session srvslot=X slot=Y" and then it would
    free the incorrect slot, often generating a
    "freeing free slot!!" console message as well.
    
    This patch fixes the problem.
    
    Note that FreeBSD NFSv4.1/4.2 servers only
    generate a NFSERR_BADSESSION error after a reboot
    or after a client does a DestroySession operation.
    
    PR:     260011
    (cherry picked from commit fb29f817586972444d65b1548287a51f27891639)
---
 sys/fs/nfs/nfs_commonkrpc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c
index 150d92414e7a..81df586879c5 100644
--- a/sys/fs/nfs/nfs_commonkrpc.c
+++ b/sys/fs/nfs/nfs_commonkrpc.c
@@ -1169,6 +1169,8 @@ tryagain:
 						*tl++ = txdr_unsigned(slotseq);
 						*tl++ = txdr_unsigned(slotpos);
 						*tl = txdr_unsigned(maxslot);
+						nd->nd_slotid = slotpos;
+						nd->nd_flag |= ND_HASSLOTID;
 					}
 					if (reterr == NFSERR_BADSESSION ||
 					    reterr == 0) {