]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfs.h
xnu-4570.71.2.tar.gz
[apple/xnu.git] / bsd / nfs / nfs.h
index 370ddaa832451120255b3d98017eab728a6c2cdf..2277221c4e870a6464a1673bb3575fe7f47f74dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -106,7 +106,6 @@ extern int nfs_ticks;
 #define        NFS_ASYNCTHREADMAXIDLE  60      /* Seconds before idle nfsiods are reaped */
 #define        NFS_DEFSTATFSRATELIMIT  10      /* Def. max # statfs RPCs per second */
 #define NFS_REQUESTDELAY       10      /* ms interval to check request queue */
-#define NFSRV_DEADSOCKDELAY    5       /* Seconds before dead sockets are reaped */
 #define NFSRV_MAXWGATHERDELAY  100     /* Max. write gather delay (msec) */
 #ifndef NFSRV_WGATHERDELAY
 #define NFSRV_WGATHERDELAY     1       /* Default write gather delay (msec) */
@@ -186,6 +185,8 @@ extern int nfs_ticks;
 #define NFS_MATTR_REALM                        24      /* Realm to authenticate with */
 #define NFS_MATTR_PRINCIPAL            25      /* GSS principal to authenticate with */
 #define NFS_MATTR_SVCPRINCIPAL         26      /* GSS principal to authenticate to, the server principal */
+#define NFS_MATTR_NFS_VERSION_RANGE    27      /* Packed version range to try */
+#define NFS_MATTR_KERB_ETYPE           28      /* Enctype to use for kerberos mounts */
 
 /* NFS mount flags */
 #define NFS_MFLAG_SOFT                 0       /* soft mount (requests fail if unresponsive) */
@@ -199,7 +200,7 @@ extern int nfs_ticks;
 #define NFS_MFLAG_MUTEJUKEBOX          8       /* don't treat jukebox errors as unresponsive */
 #define NFS_MFLAG_EPHEMERAL            9       /* ephemeral (mirror) mount */
 #define NFS_MFLAG_NOCALLBACK           10      /* don't provide callback RPC service */
-#define NFS_MFLAG_NONAMEDATTR          11      /* don't use named attributes */
+#define NFS_MFLAG_NAMEDATTR            11      /* don't use named attributes */
 #define NFS_MFLAG_NOACL                        12      /* don't support ACLs */
 #define NFS_MFLAG_ACLONLY              13      /* only support ACLs - not mode */
 #define NFS_MFLAG_NFC                  14      /* send NFC strings */
@@ -207,11 +208,32 @@ extern int nfs_ticks;
 #define NFS_MFLAG_MNTUDP               16      /* MOUNT protocol should use UDP */
 #define NFS_MFLAG_MNTQUICK             17      /* use short timeouts while mounting */
 
+/* Macros for packing and unpacking packed versions */
+#define PVER2MAJOR(M) ((uint32_t)(((M) >> 16) & 0xffff))
+#define PVER2MINOR(m) ((uint32_t)((m) & 0xffff))
+#define VER2PVER(M, m) ((uint32_t)((M) << 16) | ((m) & 0xffff))
+
 /* NFS advisory file locking modes */
 #define NFS_LOCK_MODE_ENABLED          0       /* advisory file locking enabled */
 #define NFS_LOCK_MODE_DISABLED         1       /* do not support advisory file locking */
 #define NFS_LOCK_MODE_LOCAL            2       /* perform advisory file locking locally */
 
+
+/* Supported encryption types for kerberos session keys */
+typedef enum  nfs_supported_kerberos_etypes {
+       NFS_DES3_CBC_SHA1_KD = 16,
+       NFS_AES128_CTS_HMAC_SHA1_96 = 17,
+       NFS_AES256_CTS_HMAC_SHA1_96 = 18
+} nfs_supported_kerberos_etypes;
+
+/* Structure to hold an array of kerberos enctypes to allow on a mount */
+#define NFS_MAX_ETYPES 3
+struct nfs_etype {
+       uint32_t count;
+       uint32_t selected;  /* index in etypes that is being used. Set to count if nothing has been selected */
+       nfs_supported_kerberos_etypes etypes[NFS_MAX_ETYPES];
+};
+
 /*
  * Old-style arguments to mount NFS
  */
@@ -565,7 +587,7 @@ struct nfs_export_stat_counters {
        struct nfsstatcount64 ops;              /* Count of NFS Requests received for this export  */
        struct nfsstatcount64 bytes_read;       /* Count of bytes read from this export */
        struct nfsstatcount64 bytes_written;    /* Count of bytes written to his export */
-}__attribute__((__packed__));
+};
 
 /* Macro for updating nfs export stat counters */
 #define NFSStatAdd64(PTR, VAL) \
@@ -749,14 +771,19 @@ struct nfsstats {
 #include <sys/_types/_guid_t.h> /* for guid_t below */
 #define MAXIDNAMELEN           1024
 struct nfs_testmapid {
-       uint32_t                ntm_name2id;    /* lookup name 2 id or id 2 name */
+       uint32_t                ntm_lookup;     /* lookup name 2 id or id 2 name */
        uint32_t                ntm_grpflag;    /* Is this a group or user maping */
        uint32_t                ntm_id;         /* id to map or return */
        uint32_t                pad;    
        guid_t                  ntm_guid;       /* intermidiate guid used in conversion */
        char                    ntm_name[MAXIDNAMELEN]; /* name to map or return */
 };
-       
+
+#define NTM_ID2NAME    0
+#define NTM_NAME2ID    1
+#define NTM_NAME2GUID  2
+#define NTM_GUID2NAME  3
+
 /*
  * fs.nfs sysctl(3) identifiers
  */
@@ -931,8 +958,6 @@ extern lck_grp_t *nfs_request_grp;
 
 #define NFSNOLIST      ((void *)0x0badcafe)    /* sentinel value for nfs lists */
 #define NFSREQNOLIST   NFSNOLIST               /* sentinel value for nfsreq lists */
-#define NFSIODCOMPLETING       ((void *)0x10d) /* sentinel value for iod processing
-                                                  async I/O w/callback being completed */
 
 /* Flag values for r_flags */
 #define R_TIMING       0x00000001      /* timing request (in mntp) */
@@ -952,6 +977,7 @@ extern lck_grp_t *nfs_request_grp;
 #define R_RESENDQ      0x00004000      /* async request currently on resendq */
 #define R_SENDING      0x00008000      /* request currently being sent */
 #define R_SOFT         0x00010000      /* request is soft - don't retry or reconnect */
+#define R_IOD          0x00020000      /* request is being managed by an IOD */
 
 #define R_NOINTR       0x20000000      /* request should not be interupted by a signal */
 #define R_RECOVER      0x40000000      /* a state recovery RPC - during NFSSTA_RECOVER */
@@ -966,20 +992,17 @@ extern lck_grp_t *nfs_request_grp;
 extern u_int32_t nfs_xid, nfs_xidwrap;
 extern int nfs_iosize, nfs_allow_async, nfs_statfs_rate_limit;
 extern int nfs_access_cache_timeout, nfs_access_delete, nfs_access_dotzfs, nfs_access_for_getattr;
-extern int nfs_lockd_mounts, nfs_lockd_request_sent, nfs_single_des;
+extern int nfs_lockd_mounts, nfs_lockd_request_sent;
 extern int nfs_tprintf_initial_delay, nfs_tprintf_delay;
 extern int nfsiod_thread_count, nfsiod_thread_max, nfs_max_async_writes;
 extern int nfs_idmap_ctrl, nfs_callback_port;
-extern int nfs_is_mobile, nfs_readlink_nocache;
+extern int nfs_is_mobile, nfs_readlink_nocache, nfs_root_steals_ctx;
 extern uint32_t nfs_squishy_flags;
 extern uint32_t nfs_debug_ctl;
 
 /* bits for nfs_idmap_ctrl: */
 #define NFS_IDMAP_CTRL_USE_IDMAP_SERVICE               0x00000001 /* use the ID mapping service */
 #define NFS_IDMAP_CTRL_FALLBACK_NO_COMMON_IDS          0x00000002 /* fallback should NOT handle common IDs like "root" and "nobody" */
-#define NFS_IDMAP_CTRL_FALLBACK_NO_WELLKNOWN_IDS       0x00000004 /* fallback should NOT handle the well known "XXX@" IDs */
-#define NFS_IDMAP_CTRL_UNKNOWN_IS_99                   0x00000008 /* for unknown IDs use uid/gid 99 instead of -2/nobody */
-#define NFS_IDMAP_CTRL_COMPARE_RESULTS                 0x00000010 /* compare results of ID mapping service and fallback */
 #define NFS_IDMAP_CTRL_LOG_FAILED_MAPPINGS             0x00000020 /* log failed ID mapping attempts */
 #define NFS_IDMAP_CTRL_LOG_SUCCESSFUL_MAPPINGS         0x00000040 /* log successful ID mapping attempts */
 
@@ -1050,8 +1073,8 @@ extern struct nfsrv_sock *nfsrv_udpsock, *nfsrv_udp6sock;
  * nfsrv_sockwork - sockets being worked on which may have more work to do (ns_svcq)
  * nfsrv_sockwg - sockets with pending write gather input (ns_wgq)
  */
-extern TAILQ_HEAD(nfsrv_sockhead, nfsrv_sock) nfsrv_socklist, nfsrv_deadsocklist,
-                                               nfsrv_sockwg, nfsrv_sockwait, nfsrv_sockwork;
+extern TAILQ_HEAD(nfsrv_sockhead, nfsrv_sock) nfsrv_socklist, nfsrv_sockwg,
+                                               nfsrv_sockwait, nfsrv_sockwork;
 
 /* lock groups for nfsrv_sock's */
 extern lck_grp_t *nfsrv_slp_rwlock_group;
@@ -1104,6 +1127,9 @@ struct nfsrv_descript {
 
 extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head, nfsd_queue;
 
+typedef int (*nfsrv_proc_t)(struct nfsrv_descript *, struct nfsrv_sock *,
+                         vfs_context_t, mbuf_t *);
+
 /* mutex for nfs server */
 extern lck_mtx_t *nfsd_mutex;
 extern int nfsd_thread_count, nfsd_thread_max;
@@ -1123,11 +1149,14 @@ extern in_port_t nfs4_cb_port, nfs4_cb_port6;
 extern thread_call_t   nfs_request_timer_call;
 extern thread_call_t   nfs_buf_timer_call;
 extern thread_call_t   nfs4_callback_timer_call;
-extern thread_call_t   nfsrv_deadsock_timer_call;
+extern thread_call_t   nfsrv_idlesock_timer_call;
 #if CONFIG_FSE
 extern thread_call_t   nfsrv_fmod_timer_call;
 #endif
 
+/* nfs 4 default domain for user mapping */
+extern char nfs4_default_domain[MAXPATHLEN];
+
 __BEGIN_DECLS
 
 nfstype        vtonfs_type(enum vtype, int);
@@ -1237,7 +1266,7 @@ uint32_t nfs4_ace_vfsflags_to_nfsflags(uint32_t);
 uint32_t nfs4_ace_nfsmask_to_vfsrights(uint32_t);
 uint32_t nfs4_ace_vfsrights_to_nfsmask(uint32_t);
 int nfs4_id2guid(char *, guid_t *, int);
-int nfs4_guid2id(guid_t *, char *, int *, int);
+int nfs4_guid2id(guid_t *, char *, size_t *, int);
 
 int    nfs_parsefattr(struct nfsm_chain *, int, struct nfs_vattr *);
 int    nfs4_parsefattr(struct nfsm_chain *, struct nfs_fsattr *, struct nfs_vattr *, fhandle_t *, struct dqblk *, struct nfs_fs_locations *);
@@ -1392,13 +1421,14 @@ void    nfsrv_cleancache(void);
 void   nfsrv_cleanup(void);
 int    nfsrv_credcheck(struct nfsrv_descript *, vfs_context_t, struct nfs_export *,
                        struct nfs_export_options *);
-void   nfsrv_deadsock_timer(void *, void *);
+void   nfsrv_idlesock_timer(void *, void *);
 int    nfsrv_dorec(struct nfsrv_sock *, struct nfsd *, struct nfsrv_descript **);
 int    nfsrv_errmap(struct nfsrv_descript *, int);
 int    nfsrv_export(struct user_nfs_export_args *, vfs_context_t);
 int    nfsrv_fhmatch(struct nfs_filehandle *, struct nfs_filehandle *);
 int    nfsrv_fhtovp(struct nfs_filehandle *, struct nfsrv_descript *, vnode_t *,
                        struct nfs_export **, struct nfs_export_options **);
+int    nfsrv_check_exports_allow_address(mbuf_t);
 #if CONFIG_FSE
 void   nfsrv_fmod_timer(void *, void *);
 #endif