Author: rmacklem
Date: Fri May  3 02:17:52 2019
New Revision: 347039
URL: https://svnweb.freebsd.org/changeset/base/347039

Log:
  MFC: r346365
  Fix the NFSv4.0 server so that it does not support NFSv4.1 attributes.
  
  During inspection of a packet trace, I noticed that an NFSv4.0 mount
  reported that it supported attributes that are only defined for NFSv4.1.
  In practice, this bug appears to be benign, since NFSv4.0 clients will
  not use attributes that were added for NFSv4.1.
  However, this was not correct and this patch fixes the NFSv4.0 server
  so that it only supports attributes defined for NFSv4.0.
  It also adds a definition for NFSv4.1 attributes that can only be set,
  although it is only defined as 0 for now.
  This is anticipation of the addition of support for the NFSv4.1 mode+mask
  attribute soon.

Modified:
  stable/11/sys/fs/nfs/nfs.h
  stable/11/sys/fs/nfs/nfs_commonsubs.c
  stable/11/sys/fs/nfs/nfsproto.h
  stable/11/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfs/nfs.h
==============================================================================
--- stable/11/sys/fs/nfs/nfs.h  Fri May  3 02:03:29 2019        (r347038)
+++ stable/11/sys/fs/nfs/nfs.h  Fri May  3 02:17:52 2019        (r347039)
@@ -383,10 +383,14 @@ typedef struct {
        (t)->bits[2] = (f)->bits[2];                                    \
 } while (0)
 
-#define        NFSSETSUPP_ATTRBIT(b) do {                                      
\
+#define        NFSSETSUPP_ATTRBIT(b, n) do {                                   
\
        (b)->bits[0] = NFSATTRBIT_SUPP0;                                \
-       (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY);     \
-       (b)->bits[2] = NFSATTRBIT_SUPP2;                                \
+       (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY1);    \
+       (b)->bits[2] = (NFSATTRBIT_SUPP2 | NFSATTRBIT_SUPPSETONLY2);    \
+       if (((n)->nd_flag & ND_NFSV41) == 0) {                          \
+               (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;                   \
+               (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
+       }                                                               \
 } while (0)
 
 #define        NFSISSET_ATTRBIT(b, p)  ((b)->bits[(p) / 32] & (1 << ((p) % 
32)))
@@ -405,16 +409,22 @@ typedef struct {
        (b)->bits[2] &= ((a)->bits[2]);                                 \
 } while (0)
 
-#define        NFSCLRNOTFILLABLE_ATTRBIT(b) do {                               
\
+#define        NFSCLRNOTFILLABLE_ATTRBIT(b, n) do {                            
\
        (b)->bits[0] &= NFSATTRBIT_SUPP0;                               \
        (b)->bits[1] &= NFSATTRBIT_SUPP1;                               \
        (b)->bits[2] &= NFSATTRBIT_SUPP2;                               \
+       if (((n)->nd_flag & ND_NFSV41) == 0) {                          \
+               (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;                   \
+               (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
+       }                                                               \
 } while (0)
 
-#define        NFSCLRNOTSETABLE_ATTRBIT(b) do {                                
\
+#define        NFSCLRNOTSETABLE_ATTRBIT(b, n) do {                             
\
        (b)->bits[0] &= NFSATTRBIT_SETABLE0;                            \
        (b)->bits[1] &= NFSATTRBIT_SETABLE1;                            \
        (b)->bits[2] &= NFSATTRBIT_SETABLE2;                            \
+       if (((n)->nd_flag & ND_NFSV41) == 0)                            \
+               (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;                   \
 } while (0)
 
 #define        NFSNONZERO_ATTRBIT(b)   ((b)->bits[0] || (b)->bits[1] || 
(b)->bits[2])

Modified: stable/11/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- stable/11/sys/fs/nfs/nfs_commonsubs.c       Fri May  3 02:03:29 2019        
(r347038)
+++ stable/11/sys/fs/nfs/nfs_commonsubs.c       Fri May  3 02:17:52 2019        
(r347039)
@@ -935,7 +935,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
                        if (error)
                            goto nfsmout;
                        if (compare && !(*retcmpp)) {
-                          NFSSETSUPP_ATTRBIT(&checkattrbits);
+                          NFSSETSUPP_ATTRBIT(&checkattrbits, nd);
 
                           /* Some filesystem do not support NFSv4ACL   */
                           if (nfsrv_useacl == 0 || nfs_supportsnfsv4acls(vp) 
== 0) {
@@ -1793,8 +1793,8 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
                        if (error)
                            goto nfsmout;
                        if (compare && !(*retcmpp)) {
-                          NFSSETSUPP_ATTRBIT(&checkattrbits);
-                          NFSCLRNOTSETABLE_ATTRBIT(&checkattrbits);
+                          NFSSETSUPP_ATTRBIT(&checkattrbits, nd);
+                          NFSCLRNOTSETABLE_ATTRBIT(&checkattrbits, nd);
                           NFSCLRBIT_ATTRBIT(&checkattrbits,
                                NFSATTRBIT_TIMEACCESSSET);
                           if (!NFSEQUAL_ATTRBIT(&retattrbits, &checkattrbits)
@@ -2089,10 +2089,10 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
         * reply call.
         */
        if (p == NULL && cred == NULL) {
-               NFSCLRNOTSETABLE_ATTRBIT(retbitp);
+               NFSCLRNOTSETABLE_ATTRBIT(retbitp, nd);
                aclp = saclp;
        } else {
-               NFSCLRNOTFILLABLE_ATTRBIT(retbitp);
+               NFSCLRNOTFILLABLE_ATTRBIT(retbitp, nd);
                naclp = acl_alloc(M_WAITOK);
                aclp = naclp;
        }
@@ -2162,7 +2162,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
            if (NFSISSET_ATTRBIT(retbitp, bitpos)) {
                switch (bitpos) {
                case NFSATTRBIT_SUPPORTEDATTRS:
-                       NFSSETSUPP_ATTRBIT(&attrbits);
+                       NFSSETSUPP_ATTRBIT(&attrbits, nd);
                        if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL)
                            && supports_nfsv4acls == 0)) {
                            NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT);
@@ -2544,8 +2544,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
                        retnum += NFSX_HYPER;
                        break;
                case NFSATTRBIT_SUPPATTREXCLCREAT:
-                       NFSSETSUPP_ATTRBIT(&attrbits);
-                       NFSCLRNOTSETABLE_ATTRBIT(&attrbits);
+                       NFSSETSUPP_ATTRBIT(&attrbits, nd);
+                       NFSCLRNOTSETABLE_ATTRBIT(&attrbits, nd);
                        NFSCLRBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESSSET);
                        retnum += nfsrv_putattrbit(nd, &attrbits);
                        break;

Modified: stable/11/sys/fs/nfs/nfsproto.h
==============================================================================
--- stable/11/sys/fs/nfs/nfsproto.h     Fri May  3 02:03:29 2019        
(r347038)
+++ stable/11/sys/fs/nfs/nfsproto.h     Fri May  3 02:17:52 2019        
(r347039)
@@ -1055,11 +1055,11 @@ struct nfsv3_sattr {
 #define        NFSATTRBIT_SUPP2        NFSATTRBM_SUPPATTREXCLCREAT
 
 /*
- * NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and
- * NFSATTRBIT_TIMEMODIFYSET.
+ * These are the set only attributes.
  */
-#define        NFSATTRBIT_SUPPSETONLY   (NFSATTRBM_TIMEACCESSSET |             
\
+#define        NFSATTRBIT_SUPPSETONLY1  (NFSATTRBM_TIMEACCESSSET |             
\
                                 NFSATTRBM_TIMEMODIFYSET)
+#define        NFSATTRBIT_SUPPSETONLY2 0
 
 /*
  * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
@@ -1076,6 +1076,18 @@ struct nfsv3_sattr {
        NFSATTRBM_TIMEACCESSSET |                                       \
        NFSATTRBM_TIMEMODIFYSET)
 #define        NFSATTRBIT_SETABLE2             0
+
+/*
+ * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.
+ */
+#define        NFSATTRBIT_NFSV41_1                                             
\
+       (NFSATTRBM_FSLAYOUTTYPE)
+#define        NFSATTRBIT_NFSV41_2                                             
\
+       (NFSATTRBM_LAYOUTTYPE |                                         \
+       NFSATTRBM_LAYOUTBLKSIZE |                                       \
+       NFSATTRBM_LAYOUTALIGNMENT |                                     \
+       NFSATTRBM_MODESETMASKED |                                       \
+       NFSATTRBM_SUPPATTREXCLCREAT)
 
 /*
  * Set of attributes that the getattr vnode op needs.

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- stable/11/sys/fs/nfsserver/nfs_nfsdport.c   Fri May  3 02:03:29 2019        
(r347038)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdport.c   Fri May  3 02:17:52 2019        
(r347039)
@@ -1874,7 +1874,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdg
                if (error)
                        goto nfsmout;
                NFSSET_ATTRBIT(&savbits, &attrbits);
-               NFSCLRNOTFILLABLE_ATTRBIT(&attrbits);
+               NFSCLRNOTFILLABLE_ATTRBIT(&attrbits, nd);
                NFSZERO_ATTRBIT(&rderrbits);
                NFSSETBIT_ATTRBIT(&rderrbits, NFSATTRBIT_RDATTRERROR);
        } else {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to