Print this page
2988 nfssrv: need ability to go to submounts for v3 and v2 protocols
Portions contributed by: Marcel Telka <marcel.telka@nexenta.com>
Portions contributed by: Jean McCormack <jean.mccormack@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Change-Id: I6fdf110cc17e789353c4442b83a46cb80643456e
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/nfs/export.h
+++ new/usr/src/uts/common/nfs/export.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 - * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
24 23 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
25 25 * Copyright 2016 Jason King.
26 26 */
27 27
28 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 29 /* All Rights Reserved */
30 30
31 31 #ifndef _NFS_EXPORT_H
32 32 #define _NFS_EXPORT_H
33 33
34 34 #include <nfs/nfs_sec.h>
35 35 #include <nfs/auth.h>
36 36 #include <sys/vnode.h>
37 37 #include <nfs/nfs4.h>
38 38 #include <sys/kiconv.h>
39 39 #include <sys/avl.h>
40 40
41 41 #ifdef __cplusplus
42 42 extern "C" {
43 43 #endif
44 44
45 45 /*
46 46 * nfs pseudo flavor number is owned by IANA. Need to make sure the
47 47 * Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any
48 48 * new IANA defined pseudo flavor numbers. The chance for the overlap
49 49 * is very small since the growth of new flavor numbers is expected
50 50 * to be limited.
51 51 */
52 52 #define NFS_FLAVOR_NOMAP 999999 /* no nfs flavor mapping */
53 53
54 54 /*
55 55 * As duplicate flavors can be passed into exportfs in the arguments, we
56 56 * allocate a cleaned up array with non duplicate flavors on the stack.
57 57 * So we need to know how much to allocate.
58 58 */
59 59 #define MAX_FLAVORS 6 /* none, sys, dh, krb5, krb5i krb5p */
60 60
|
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
61 61 /*
62 62 * Note: exported_lock is currently used to ensure the integrity of
63 63 * the secinfo fields.
64 64 */
65 65 struct secinfo {
66 66 seconfig_t s_secinfo; /* /etc/nfssec.conf entry */
67 67 unsigned int s_flags; /* flags (see below) */
68 68 int32_t s_refcnt; /* reference count for tracking */
69 69 /* how many children (self included) */
70 70 /* use this flavor. */
71 - int s_window; /* window */
71 + int s_window; /* window */
72 72 uint_t s_rootid; /* UID to use for authorized roots */
73 73 int s_rootcnt; /* count of root names */
74 74 caddr_t *s_rootnames; /* array of root names */
75 75 /* they are strings for AUTH_DES and */
76 76 /* rpc_gss_principal_t for RPCSEC_GSS */
77 77 };
78 78
79 79 #ifdef _SYSCALL32
80 80 struct secinfo32 {
81 81 seconfig32_t s_secinfo; /* /etc/nfssec.conf entry */
82 82 uint32_t s_flags; /* flags (see below) */
83 83 int32_t s_refcnt; /* reference count for tracking */
84 84 /* how many children (self included) */
85 85 /* use this flavor. */
86 - int32_t s_window; /* window */
86 + int32_t s_window; /* window */
87 87 uint32_t s_rootid; /* UID to use for authorized roots */
88 88 int32_t s_rootcnt; /* count of root names */
89 89 caddr32_t s_rootnames; /* array of root names */
90 90 /* they are strings for AUTH_DES and */
91 91 /* rpc_gss_principal_t for RPCSEC_GSS */
92 92 };
93 93 #endif /* _SYSCALL32 */
94 94
95 95 /*
96 96 * security negotiation related
97 97 */
98 98
99 99 #define SEC_QUERY 0x01 /* query sec modes */
100 100
101 101 struct sec_ol {
102 102 int sec_flags; /* security nego flags */
103 103 uint_t sec_index; /* index into sec flavor array */
104 104 };
105 105
106 106 /*
107 107 * Per-mode flags (secinfo.s_flags)
108 108 */
109 109 #define M_RO 0x01 /* exported ro to all */
110 110 #define M_ROL 0x02 /* exported ro to all listed */
111 111 #define M_RW 0x04 /* exported rw to all */
112 112 #define M_RWL 0x08 /* exported ro to all listed */
113 113 #define M_ROOT 0x10 /* root list is defined */
114 114 #define M_4SEC_EXPORTED 0x20 /* this is an explicitly shared flavor */
115 115 #define M_NONE 0x40 /* none list is defined */
116 116 #define M_MAP 0x80 /* uidmap and/or gidmap is defined */
117 117
118 118 /* invalid secinfo reference count */
119 119 #define SEC_REF_INVALID(p) ((p)->s_refcnt < 1)
120 120
121 121 /* last secinfo reference */
122 122 #define SEC_REF_LAST(p) ((p)->s_refcnt == 1)
123 123
124 124 /* sec flavor explicitly shared for the exported node */
125 125 #define SEC_REF_EXPORTED(p) ((p)->s_flags & M_4SEC_EXPORTED)
126 126
127 127 /* the only reference count left is for referring itself */
128 128 #define SEC_REF_SELF(p) (SEC_REF_LAST(p) && SEC_REF_EXPORTED(p))
129 129
130 130 /*
131 131 * The export information passed to exportfs() (Version 2)
132 132 */
133 133 #define EX_CURRENT_VERSION 2 /* current version of exportdata struct */
134 134
135 135 struct exportdata {
136 136 int ex_version; /* structure version */
137 137 char *ex_path; /* exported path */
138 138 size_t ex_pathlen; /* path length */
139 139 int ex_flags; /* flags */
140 140 unsigned int ex_anon; /* uid for unauthenticated requests */
141 141 int ex_seccnt; /* count of security modes */
142 142 struct secinfo *ex_secinfo; /* security mode info */
143 143 char *ex_index; /* index file for public filesystem */
144 144 char *ex_log_buffer; /* path to logging buffer file */
145 145 size_t ex_log_bufferlen; /* buffer file path len */
146 146 char *ex_tag; /* tag used to identify log config */
147 147 size_t ex_taglen; /* tag length */
148 148 };
149 149
150 150 #ifdef _SYSCALL32
151 151 struct exportdata32 {
152 152 int32_t ex_version; /* structure version */
153 153 caddr32_t ex_path; /* exported path */
154 154 int32_t ex_pathlen; /* path length */
155 155 int32_t ex_flags; /* flags */
156 156 uint32_t ex_anon; /* uid for unauthenticated requests */
157 157 int32_t ex_seccnt; /* count of security modes */
158 158 caddr32_t ex_secinfo; /* security mode info */
159 159 caddr32_t ex_index; /* index file for public filesystem */
160 160 caddr32_t ex_log_buffer; /* path to logging buffer file */
161 161 int32_t ex_log_bufferlen; /* buffer file path len */
162 162 caddr32_t ex_tag; /* tag used to identify log config */
163 163 int32_t ex_taglen; /* tag length */
164 164 };
165 165 #endif /* _SYSCALL32 */
166 166
167 167 /*
168 168 * exported vfs flags.
169 169 */
170 170
171 171 #define EX_NOSUID 0x01 /* exported with unsetable set[ug]ids */
172 172 #define EX_ACLOK 0x02 /* exported with maximal access if acl exists */
173 173 #define EX_PUBLIC 0x04 /* exported with public filehandle */
174 174 #define EX_NOSUB 0x08 /* no nfs_getfh or MCL below export point */
175 175 #define EX_INDEX 0x10 /* exported with index file specified */
176 176 #define EX_LOG 0x20 /* logging enabled */
177 177 #define EX_LOG_ALLOPS 0x40 /* logging of all RPC operations enabled */
178 178 /* by default only operations which affect */
179 179 /* transaction logging are enabled */
180 180 #define EX_PSEUDO 0x80 /* pseudo filesystem export */
181 181 #ifdef VOLATILE_FH_TEST
|
↓ open down ↓ |
85 lines elided |
↑ open up ↑ |
182 182 #define EX_VOLFH 0x100 /* XXX nfsv4 fh may expire anytime */
183 183 #define EX_VOLRNM 0x200 /* XXX nfsv4 fh expire at rename */
184 184 #define EX_VOLMIG 0x400 /* XXX nfsv4 fh expire at migration */
185 185 #define EX_NOEXPOPEN 0x800 /* XXX nfsv4 fh no expire with open */
186 186 #endif /* VOLATILE_FH_TEST */
187 187
188 188 #define EX_CHARMAP 0x1000 /* NFS may need a character set conversion */
189 189 #define EX_NOACLFAB 0x2000 /* If set, NFSv2 and v3 servers won't */
190 190 /* fabricate an aclent_t ACL on file systems */
191 191 /* that don't support aclent_t ACLs */
192 +#define EX_NOHIDE 0x4000 /* traversable from exported parent */
192 193
193 194 #ifdef _KERNEL
194 195
195 196 #define RPC_IDEMPOTENT 0x1 /* idempotent or not */
196 197 /*
197 198 * Be very careful about which NFS procedures get the RPC_ALLOWANON bit.
198 199 * Right now, if this bit is on, we ignore the results of per NFS request
199 200 * access control.
200 201 */
201 202 #define RPC_ALLOWANON 0x2 /* allow anonymous access */
202 203 #define RPC_MAPRESP 0x4 /* use mapped response buffer */
203 204 #define RPC_AVOIDWORK 0x8 /* do work avoidance for dups */
204 205 #define RPC_PUBLICFH_OK 0x10 /* allow use of public filehandle */
205 206
206 207 /*
207 208 * RPC_ALL is an or of all above bits to be used with "don't care"
208 209 * nfsv4 ops. The flags of an nfsv4 request is the bit-AND of the
209 210 * per-op flags.
210 211 */
211 212 #define RPC_ALL (RPC_IDEMPOTENT|RPC_ALLOWANON|RPC_AVOIDWORK|RPC_PUBLICFH_OK)
212 213
213 214
214 215 #ifdef VOLATILE_FH_TEST
215 216 struct ex_vol_rename {
216 217 nfs_fh4_fmt_t vrn_fh_fmt;
217 218 struct ex_vol_rename *vrn_next;
218 219 };
219 220 #endif /* VOLATILE_FH_TEST */
220 221
221 222 /*
222 223 * An auth cache client entry. This is the umbrella structure and contains all
223 224 * related auth_cache entries in the authc_tree AVL tree.
224 225 */
225 226 struct auth_cache_clnt {
226 227 avl_node_t authc_link;
227 228 struct netbuf authc_addr; /* address of the client */
228 229 krwlock_t authc_lock; /* protects authc_tree */
229 230 avl_tree_t authc_tree; /* auth_cache entries */
230 231 };
231 232
232 233 /*
233 234 * An auth cache entry can exist in 6 states.
234 235 *
235 236 * A NEW entry was recently allocated and added to the cache. It does not
236 237 * contain the valid auth state yet.
237 238 *
238 239 * A WAITING entry is one which is actively engaging the user land mountd code
239 240 * to authenticate or re-authenticate it. The auth state might not be valid
240 241 * yet. The other threads should wait on auth_cv until the retrieving thread
241 242 * finishes the retrieval and changes the auth cache entry to FRESH, or NEW (in
242 243 * a case this entry had no valid auth state yet).
243 244 *
244 245 * A REFRESHING entry is one which is actively engaging the user land mountd
245 246 * code to re-authenticate the cache entry. There is currently no other thread
246 247 * waiting for the results of the refresh.
247 248 *
248 249 * A FRESH entry is one which is valid (it is either newly retrieved or has
249 250 * been refreshed at least once).
250 251 *
251 252 * A STALE entry is one which has been detected to be too old. The transition
252 253 * from FRESH to STALE prevents multiple threads from submitting refresh
253 254 * requests.
254 255 *
255 256 * An INVALID entry is one which was either STALE or REFRESHING and was deleted
256 257 * out of the encapsulating exi. Since we can't delete it yet, we mark it as
257 258 * INVALID, which lets the refresh thread know not to work on it and free it
258 259 * instead.
259 260 *
260 261 * Note that the auth state of the entry is valid, even if the entry is STALE.
261 262 * Just as you can eat stale bread, you can consume a stale cache entry. The
262 263 * only time the contents change could be during the transition from REFRESHING
263 264 * or WAITING to FRESH.
264 265 *
265 266 * Valid state transitions:
266 267 *
267 268 * alloc
268 269 * |
269 270 * v
270 271 * +-----+
271 272 * +--->| NEW |------>free
272 273 * | +-----+
273 274 * | |
274 275 * | v
275 276 * | +---------+
276 277 * +<-| WAITING |
277 278 * ^ +---------+
278 279 * | |
279 280 * | v
280 281 * | +<--------------------------+<---------------+
281 282 * | | ^ |
282 283 * | v | |
283 284 * | +-------+ +-------+ +------------+ +---------+
284 285 * +---| FRESH |--->| STALE |--->| REFRESHING |--->| WAITING |
285 286 * +-------+ +-------+ +------------+ +---------+
286 287 * | | |
287 288 * | v |
288 289 * v +---------+ |
289 290 * free<-----| INVALID |<--------+
290 291 * +---------+
291 292 */
292 293 typedef enum auth_state {
293 294 NFS_AUTH_FRESH,
294 295 NFS_AUTH_STALE,
295 296 NFS_AUTH_REFRESHING,
296 297 NFS_AUTH_INVALID,
297 298 NFS_AUTH_NEW,
298 299 NFS_AUTH_WAITING
299 300 } auth_state_t;
300 301
301 302 /*
302 303 * An authorization cache entry
303 304 *
304 305 * Either the state in auth_state will protect the
305 306 * contents or auth_lock must be held.
306 307 */
307 308 struct auth_cache {
308 309 avl_node_t auth_link;
309 310 struct auth_cache_clnt *auth_clnt;
310 311 int auth_flavor;
311 312 cred_t *auth_clnt_cred;
312 313 uid_t auth_srv_uid;
313 314 gid_t auth_srv_gid;
314 315 uint_t auth_srv_ngids;
315 316 gid_t *auth_srv_gids;
316 317 int auth_access;
317 318 time_t auth_time;
318 319 time_t auth_freshness;
319 320 auth_state_t auth_state;
320 321 kmutex_t auth_lock;
321 322 kcondvar_t auth_cv;
322 323 };
323 324
324 325 #define AUTH_TABLESIZE 32
325 326
326 327 /*
327 328 * Structure containing log file meta-data.
328 329 */
329 330 struct log_file {
330 331 unsigned int lf_flags; /* flags (see below) */
331 332 int lf_writers; /* outstanding writers */
332 333 int lf_refcnt; /* references to this struct */
333 334 caddr_t lf_path; /* buffer file location */
334 335 vnode_t *lf_vp; /* vnode for the buffer file */
335 336 kmutex_t lf_lock;
336 337 kcondvar_t lf_cv_waiters;
337 338 };
338 339
339 340 /*
340 341 * log_file and log_buffer flags.
341 342 */
342 343 #define L_WAITING 0x01 /* flush of in-core data to stable */
343 344 /* storage in progress */
344 345 #define L_PRINTED 0x02 /* error message printed to console */
345 346 #define L_ERROR 0x04 /* error condition detected */
346 347
347 348 /*
348 349 * The logging buffer information.
349 350 * This structure may be shared by multiple exportinfo structures,
350 351 * if they share the same buffer file.
351 352 * This structure contains the basic information about the buffer, such
352 353 * as it's location in the filesystem.
353 354 *
354 355 * 'lb_lock' protects all the fields in this structure except for 'lb_path',
355 356 * and 'lb_next'.
356 357 * 'lb_path' is a write-once/read-many field which needs no locking, it is
357 358 * set before the structure is linked to any exportinfo structure.
358 359 * 'lb_next' is protected by the log_buffer_list_lock.
359 360 */
360 361 struct log_buffer {
361 362 unsigned int lb_flags; /* L_ONLIST set? */
362 363 int lb_refcnt; /* references to this struct */
363 364 unsigned int lb_rec_id; /* used to generate unique id */
364 365 caddr_t lb_path; /* buffer file pathname */
365 366 struct log_file *lb_logfile; /* points to log_file structure */
366 367 kmutex_t lb_lock;
367 368 struct log_buffer *lb_next;
368 369 kcondvar_t lb_cv_waiters;
369 370 caddr_t lb_records; /* linked list of records to write */
370 371 int lb_num_recs; /* # of records to write */
371 372 ssize_t lb_size_queued; /* number of bytes queued for write */
372 373 };
373 374
374 375 #define LOG_BUFFER_HOLD(lbp) { \
375 376 mutex_enter(&(lbp)->lb_lock); \
376 377 (lbp)->lb_refcnt++; \
377 378 mutex_exit(&(lbp)->lb_lock); \
378 379 }
379 380
380 381 #define LOG_BUFFER_RELE(lbp) { \
381 382 log_buffer_rele(lbp); \
382 383 }
383 384
384 385 /*
385 386 * Structure for character set conversion mapping based on client address.
386 387 */
387 388 struct charset_cache {
388 389 struct charset_cache *next;
389 390 kiconv_t inbound;
390 391 kiconv_t outbound;
391 392 struct sockaddr client_addr;
392 393 };
393 394
394 395 /* Forward declarations */
395 396 struct exportinfo;
396 397 struct exp_visible;
397 398 struct svc_req;
398 399
399 400 /*
400 401 * Treenodes are used to build tree representing every node which is part
401 402 * of nfs server pseudo namespace. They are connected with both exportinfo
402 403 * and exp_visible struct. They were introduced to avoid lookup of ".."
403 404 * in the underlying file system during unshare, which was failing if the
404 405 * file system was forcibly unmounted or if the directory was removed.
405 406 * One exp_visible_t can be shared via several treenode_t, i.e.
406 407 * different tree_vis can point to the same exp_visible_t.
407 408 * This will happen if some directory is on two different shared paths:
408 409 * E.g. after share /tmp/a/b1 and share /tmp/a/b2 there will be two treenodes
409 410 * corresponding to /tmp/a and both will have same value in tree_vis.
410 411 *
411 412 *
412 413 *
413 414 * NEW DATA STRUCT ORIGINAL DATA STRUCT
414 415 *
415 416 * ns_root +---+ +----------+
416 417 * | / | |PSEUDO EXP|-->+---+ +---+ +---+
417 418 * +---+--------- ----+----------+ | a |-->| k |-->| b |
418 419 * /\ +---+ +---+ +---+
419 420 * / \ . . .
420 421 * +---+...\......... ..................... . .
421 422 * *| a | \ +----------+ . .
422 423 * +---+-----\------- ----|REAL EXP a| . .
423 424 * / \ +----------+ . .
424 425 * / +===+... ............................. .
425 426 * / *| k | +----------+ .
426 427 * / +===+--- ----|REAL EXP k| .
427 428 * / +----------+ .
428 429 * +===+................ .....................................
429 430 * *| b | +----------+
430 431 * +===+---------------- ----|REAL EXP b|-->+---+
431 432 * \ +----------+ | d |
432 433 * +===+............. ...................+---+
433 434 * | d | +----------+
434 435 * +===+------------- ----|PSEUDO EXP|-->+---+ +---+
435 436 * / +----------+ | e |-->| g |
436 437 * +---+................. ...................+---+ +---+
437 438 * | e | .
438 439 * +---+ .
439 440 * \ .
440 441 * +---+.............. ............................
441 442 * *| g | +----------+
442 443 * +---+-------------- ----|REAL EXP g|
443 444 * +----------+
444 445 *
445 446 *
446 447 *
447 448 * +===+ +---+ +---+
448 449 * | b |..mountpoint | e |..directory/file *| a |..node is shared
449 450 * +===+ (VROOT) +---+ +---+
450 451 *
451 452 *
452 453 * Bi-directional interconnect:
453 454 * treenode_t::tree_exi --------- exportinfo_t::exi_tree
454 455 * One-way direction connection:
455 456 * treenode_t::tree_vis .........> exp_visible_t
456 457 */
457 458 /* Access to treenode_t is under protection of exported_lock RW_LOCK */
458 459 typedef struct treenode {
459 460 /* support for generic n-ary trees */
460 461 struct treenode *tree_parent;
461 462 struct treenode *tree_child_first;
462 463 struct treenode *tree_sibling; /* next sibling */
463 464 /* private, nfs specific part */
464 465 struct exportinfo *tree_exi;
465 466 struct exp_visible *tree_vis;
466 467 } treenode_t;
467 468
468 469 /*
469 470 * TREE_ROOT checks if the node corresponds to a filesystem root
470 471 * TREE_EXPORTED checks if the node is explicitly shared
471 472 */
472 473
473 474 #define TREE_ROOT(t) \
474 475 ((t)->tree_exi && (t)->tree_exi->exi_vp->v_flag & VROOT)
475 476
476 477 #define TREE_EXPORTED(t) \
477 478 ((t)->tree_exi && !PSEUDO((t)->tree_exi))
478 479
479 480 /* Root of nfs pseudo namespace */
480 481 extern treenode_t *ns_root;
481 482
482 483 #define EXPTABLESIZE 256
483 484
484 485 struct exp_hash {
485 486 struct exportinfo *prev; /* ptr to the previous exportinfo */
486 487 struct exportinfo *next; /* ptr to the next exportinfo */
487 488 struct exportinfo **bckt; /* backpointer to the hash bucket */
488 489 };
489 490
490 491 /*
491 492 * A node associated with an export entry on the
492 493 * list of exported filesystems.
493 494 *
494 495 * exi_count+exi_lock protects an individual exportinfo from being freed
495 496 * when in use.
496 497 *
497 498 * You must have the writer lock on exported_lock to add/delete an exportinfo
498 499 * structure to/from the list.
499 500 *
500 501 * exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the
501 502 * underlying fs devno can change on each mount. When set, the server
502 503 * should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must
503 504 * use exi_fsid because it is guaranteed to be persistent. This isn't
504 505 * in any way related to NFS4 volatile filehandles.
505 506 *
506 507 * The exi_cache_lock protects the exi_cache AVL trees.
507 508 */
508 509 struct exportinfo {
509 510 struct exportdata exi_export;
510 511 fsid_t exi_fsid;
511 512 struct fid exi_fid;
512 513 struct exp_hash fid_hash;
513 514 struct exp_hash path_hash;
514 515 struct treenode *exi_tree;
515 516 fhandle_t exi_fh;
516 517 krwlock_t exi_cache_lock;
517 518 kmutex_t exi_lock;
518 519 uint_t exi_count;
519 520 vnode_t *exi_vp;
520 521 vnode_t *exi_dvp;
521 522 avl_tree_t *exi_cache[AUTH_TABLESIZE];
522 523 struct log_buffer *exi_logbuffer;
523 524 struct exp_visible *exi_visible;
524 525 struct charset_cache *exi_charset;
525 526 unsigned exi_volatile_dev:1;
526 527 unsigned exi_moved:1;
527 528 #ifdef VOLATILE_FH_TEST
528 529 uint32_t exi_volatile_id;
529 530 struct ex_vol_rename *exi_vol_rename;
530 531 kmutex_t exi_vol_rename_lock;
531 532 #endif /* VOLATILE_FH_TEST */
532 533 };
533 534
534 535 typedef struct exportinfo exportinfo_t;
535 536 typedef struct exportdata exportdata_t;
536 537 typedef struct secinfo secinfo_t;
537 538
538 539 /*
539 540 * exp_visible is a visible list per filesystem. It is for filesystems
540 541 * that may need a limited view of its contents. A pseudo export and
541 542 * a real export at the mount point (VROOT) which has a subtree shared
542 543 * has a visible list.
543 544 *
544 545 * The exi_visible field is NULL for normal, non-pseudo filesystems
545 546 * which do not have any subtree exported. If the field is non-null,
546 547 * it points to a list of visible entries, identified by vis_fid and/or
547 548 * vis_ino. The presence of a "visible" list means that if this export
548 549 * can only have a limited view, it can only view the entries in the
549 550 * exp_visible list. The directories in the fid list comprise paths that
550 551 * lead to exported directories.
551 552 *
552 553 * The vis_count field records the number of paths in this filesystem
553 554 * that use this directory. The vis_exported field is non-zero if the
554 555 * entry is an exported directory (leaf node).
555 556 *
556 557 * exp_visible itself is not reference counted. Each exp_visible is
557 558 * referenced twice:
558 559 * 1) from treenode::tree_vis
559 560 * 2) linked from exportinfo::exi_visible
560 561 * The 'owner' of exp_visible is the exportinfo structure. exp_visible should
561 562 * be always freed only from exportinfo_t, never from treenode::tree_vis.
562 563 */
563 564
564 565 struct exp_visible {
565 566 vnode_t *vis_vp;
566 567 fid_t vis_fid;
567 568 u_longlong_t vis_ino;
568 569 int vis_count;
569 570 int vis_exported;
570 571 struct exp_visible *vis_next;
571 572 struct secinfo *vis_secinfo;
572 573 int vis_seccnt;
573 574 timespec_t vis_change;
574 575 };
575 576 typedef struct exp_visible exp_visible_t;
576 577
577 578 #define PSEUDO(exi) ((exi)->exi_export.ex_flags & EX_PSEUDO)
578 579 #define EXP_LINKED(exi) ((exi)->fid_hash.bckt != NULL)
579 580
580 581 #define EQFSID(fsidp1, fsidp2) \
581 582 (((fsidp1)->val[0] == (fsidp2)->val[0]) && \
582 583 ((fsidp1)->val[1] == (fsidp2)->val[1]))
583 584
584 585 #define EQFID(fidp1, fidp2) \
585 586 ((fidp1)->fid_len == (fidp2)->fid_len && \
586 587 bcmp((char *)(fidp1)->fid_data, (char *)(fidp2)->fid_data, \
587 588 (uint_t)(fidp1)->fid_len) == 0)
588 589
589 590 #define exportmatch(exi, fsid, fid) \
590 591 (EQFSID(&(exi)->exi_fsid, (fsid)) && EQFID(&(exi)->exi_fid, (fid)))
591 592
592 593 /*
593 594 * Returns true iff exported filesystem is read-only to the given host.
594 595 *
595 596 * Note: this macro should be as fast as possible since it's called
596 597 * on each NFS modification request.
597 598 */
598 599 #define rdonly(ro, vp) ((ro) || vn_is_readonly(vp))
599 600 #define rdonly4(req, cs) \
600 601 (vn_is_readonly((cs)->vp) || \
601 602 (nfsauth4_access((cs)->exi, (cs)->vp, (req), (cs)->basecr, NULL, \
602 603 NULL, NULL, NULL) & (NFSAUTH_RO | NFSAUTH_LIMITED)))
603 604
604 605 extern int nfsauth4_access(struct exportinfo *, vnode_t *,
605 606 struct svc_req *, cred_t *, uid_t *, gid_t *, uint_t *, gid_t **);
606 607 extern int nfsauth4_secinfo_access(struct exportinfo *,
607 608 struct svc_req *, int, int, cred_t *);
608 609 extern int nfsauth_cache_clnt_compar(const void *, const void *);
609 610 extern int nfs_fhbcmp(char *, char *, int);
610 611 extern int nfs_exportinit(void);
611 612 extern void nfs_exportfini(void);
612 613 extern int chk_clnt_sec(struct exportinfo *, struct svc_req *);
613 614 extern int makefh(fhandle_t *, struct vnode *, struct exportinfo *);
614 615 extern int makefh_ol(fhandle_t *, struct exportinfo *, uint_t);
615 616 extern int makefh3(nfs_fh3 *, struct vnode *, struct exportinfo *);
616 617 extern int makefh3_ol(nfs_fh3 *, struct exportinfo *, uint_t);
617 618 extern vnode_t *nfs_fhtovp(fhandle_t *, struct exportinfo *);
618 619 extern vnode_t *nfs3_fhtovp(nfs_fh3 *, struct exportinfo *);
619 620 extern struct exportinfo *checkexport(fsid_t *, struct fid *);
620 621 extern struct exportinfo *checkexport4(fsid_t *, struct fid *, vnode_t *);
621 622 extern void exi_hold(struct exportinfo *);
622 623 extern void exi_rele(struct exportinfo *);
623 624 extern struct exportinfo *nfs_vptoexi(vnode_t *, vnode_t *, cred_t *, int *,
624 625 int *, bool_t);
625 626 extern int nfs_check_vpexi(vnode_t *, vnode_t *, cred_t *,
626 627 struct exportinfo **);
627 628 extern void export_link(struct exportinfo *);
628 629 extern void export_unlink(struct exportinfo *);
629 630 extern vnode_t *untraverse(vnode_t *);
630 631 extern int vn_is_nfs_reparse(vnode_t *, cred_t *);
631 632 extern int client_is_downrev(struct svc_req *);
632 633 extern char *build_symlink(vnode_t *, cred_t *, size_t *);
633 634
634 635 /*
635 636 * Functions that handle the NFSv4 server namespace
636 637 */
637 638 extern exportinfo_t *vis2exi(treenode_t *);
638 639 extern int treeclimb_export(struct exportinfo *);
639 640 extern void treeclimb_unexport(struct exportinfo *);
640 641 extern int nfs_visible(struct exportinfo *, vnode_t *, int *);
641 642 extern int nfs_visible_inode(struct exportinfo *, ino64_t,
642 643 struct exp_visible **);
643 644 extern int has_visible(struct exportinfo *, vnode_t *);
644 645 extern void free_visible(struct exp_visible *);
645 646 extern int nfs_exported(struct exportinfo *, vnode_t *);
646 647 extern struct exportinfo *pseudo_exportfs(vnode_t *, fid_t *,
647 648 struct exp_visible *, struct exportdata *);
648 649 extern int vop_fid_pseudo(vnode_t *, fid_t *);
649 650 extern int nfs4_vget_pseudo(struct exportinfo *, vnode_t **, fid_t *);
650 651 extern bool_t nfs_visible_change(struct exportinfo *, vnode_t *,
651 652 timespec_t *);
652 653 extern void tree_update_change(treenode_t *, timespec_t *);
653 654 /*
654 655 * Functions that handle the NFSv4 server namespace security flavors
655 656 * information.
656 657 */
657 658 extern void srv_secinfo_exp2pseu(struct exportdata *, struct exportdata *);
658 659 extern void srv_secinfo_list_free(struct secinfo *, int);
659 660
660 661 /*
661 662 * "public" and default (root) location for public filehandle
662 663 */
663 664 extern struct exportinfo *exi_public, *exi_root;
664 665 extern fhandle_t nullfh2; /* for comparing V2 filehandles */
665 666 extern krwlock_t exported_lock;
666 667 extern struct exportinfo *exptable[];
667 668
668 669 /*
669 670 * Two macros for identifying public filehandles.
670 671 * A v2 public filehandle is 32 zero bytes.
671 672 * A v3 public filehandle is zero length.
672 673 */
673 674 #define PUBLIC_FH2(fh) \
674 675 ((fh)->fh_fsid.val[1] == 0 && \
675 676 bcmp((fh), &nullfh2, sizeof (fhandle_t)) == 0)
676 677
677 678 #define PUBLIC_FH3(fh) \
678 679 ((fh)->fh3_length == 0)
679 680
680 681 extern int makefh4(nfs_fh4 *, struct vnode *, struct exportinfo *);
681 682 extern vnode_t *nfs4_fhtovp(nfs_fh4 *, struct exportinfo *, nfsstat4 *);
682 683
683 684 #endif /* _KERNEL */
684 685
685 686 #ifdef __cplusplus
686 687 }
687 688 #endif
688 689
689 690 #endif /* _NFS_EXPORT_H */
|
↓ open down ↓ |
488 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX