ReactOS 0.4.15-dev-7842-g558ab78
nfs41_compound.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "nfs41_compound.h"
#include "nfs41_xdr.h"
#include "nfs41_ops.h"
#include "recovery.h"
#include "name_cache.h"
#include "daemon_debug.h"
#include "rpc/rpc.h"
#include "rpc/auth_sspi.h"
Include dependency graph for nfs41_compound.c:

Go to the source code of this file.

Macros

#define RETRY_INDEFINITELY
 

Functions

int compound_error (int status)
 
void compound_init (nfs41_compound *compound, nfs_argop4 *argops, nfs_resop4 *resops, const char *tag)
 
void compound_add_op (nfs41_compound *compound, uint32_t opnum, void *arg, void *res)
 
static void set_expected_res (nfs41_compound *compound)
 
static int create_new_rpc_auth (nfs41_session *session, uint32_t op, nfs41_secinfo_info *secinfo)
 
int compound_encode_send_decode (nfs41_session *session, nfs41_compound *compound, bool_t try_recovery)
 

Macro Definition Documentation

◆ RETRY_INDEFINITELY

#define RETRY_INDEFINITELY

Function Documentation

◆ compound_add_op()

void compound_add_op ( nfs41_compound compound,
uint32_t  opnum,
void arg,
void res 
)

Definition at line 61 of file nfs41_compound.c.

66{
67 const uint32_t i = compound->args.argarray_count++;
68 const uint32_t j = compound->res.resarray_count++;
69 compound->args.argarray[i].op = opnum;
70 compound->args.argarray[i].arg = arg;
71 compound->res.resarray[j].op = opnum;
72 compound->res.resarray[j].res = res;
73}
UINT32 uint32_t
Definition: types.h:75
GLuint res
Definition: glext.h:9613
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
nfs_resop4 * resarray
nfs41_compound_res res
nfs41_compound_args args
void * arg
Definition: msvc.h:10

Referenced by lookup_rpc(), nfs41_access(), nfs41_bind_conn_to_session(), nfs41_close(), nfs41_commit(), nfs41_create(), nfs41_create_session(), nfs41_delegpurge(), nfs41_delegreturn(), nfs41_destroy_clientid(), nfs41_destroy_session(), nfs41_exchange_id(), nfs41_free_stateid(), nfs41_fs_locations(), nfs41_getattr(), nfs41_link(), nfs41_lock(), nfs41_open(), nfs41_read(), nfs41_readdir(), nfs41_readlink(), nfs41_reclaim_complete(), nfs41_remove(), nfs41_rename(), nfs41_rpc_openattr(), nfs41_secinfo(), nfs41_secinfo_noname(), nfs41_send_sequence(), nfs41_setattr(), nfs41_superblock_getattr(), nfs41_test_stateid(), nfs41_unlock(), nfs41_want_delegation(), nfs41_write(), pnfs_rpc_getdeviceinfo(), pnfs_rpc_layoutcommit(), pnfs_rpc_layoutget(), pnfs_rpc_layoutreturn(), and rpc_array_putfh().

◆ compound_encode_send_decode()

int compound_encode_send_decode ( nfs41_session session,
nfs41_compound compound,
bool_t  try_recovery 
)

Definition at line 137 of file nfs41_compound.c.

141{
142 int status, retry_count = 0, delayby = 0, secinfo_status;
144 compound->args.argarray[0].arg;
145 uint32_t saved_sec_flavor;
146 AUTH *saved_auth;
147 int op1 = compound->args.argarray[0].op;
148
149retry:
150 /* send compound */
151 retry_count++;
152 set_expected_res(compound);
153 status = nfs41_send_compound(session->client->rpc,
154 (char *)&compound->args, (char *)&compound->res);
155 // bump sequence number if sequence op succeeded.
156 if (compound->res.resarray_count > 0 &&
157 compound->res.resarray[0].op == OP_SEQUENCE) {
158 nfs41_sequence_res *seq =
159 (nfs41_sequence_res *)compound->res.resarray[0].res;
160 if (seq->sr_status == NFS4_OK) {
161 // returned slotid must be the same we sent
162 if (seq->sr_resok4.sr_slotid != args->sa_slotid) {
163 eprintf("[session] sr_slotid=%d != sa_slotid=%d\n",
164 seq->sr_resok4.sr_slotid, args->sa_slotid);
166 goto out_free_slot;
167 }
168 // returned sessionid must be the same we sent
169 if (memcmp(seq->sr_resok4.sr_sessionid, args->sa_sessionid,
171 eprintf("[session] sr_sessionid != sa_sessionid\n");
172 print_hexbuf(1, (unsigned char *)"sr_sessionid",
174 print_hexbuf(1, (unsigned char *)"sa_sessionid",
175 args->sa_sessionid, NFS4_SESSIONID_SIZE);
177 goto out_free_slot;
178 }
179 if (seq->sr_resok4.sr_status_flags)
181
184
185 /* check sequence status flags for state revocation */
186 if (try_recovery && seq->sr_resok4.sr_status_flags)
189 }
190 }
191
192 if (status) {
193 eprintf("nfs41_send_compound failed %d for seqid=%d, slotid=%d\n",
194 status, args->sa_sequenceid, args->sa_slotid);
196 goto out_free_slot;
197 }
198
199 if (compound->res.status != NFS4_OK)
200 dprintf(1, "\n################ %s ################\n\n",
201 nfs_error_string(compound->res.status));
202
203 switch (compound->res.status) {
204 case NFS4_OK:
205 break;
206
208 if (!try_recovery)
209 goto out;
211 goto do_retry;
212 // try to create a new client
214
216 if (status) {
217 eprintf("nfs41_client_renew() failed with %d\n", status);
219 goto out;
220 }
221 if (op1 == OP_CREATE_SESSION) {
223 compound->args.argarray[0].arg;
224 AcquireSRWLockShared(&session->client->exid_lock);
225 csa->csa_clientid = session->client->clnt_id;
226 csa->csa_sequence = session->client->seq_id;
227 AcquireSRWLockShared(&session->client->exid_lock);
228 }
229 goto do_retry;
230
232 if (!try_recovery)
233 goto out;
235 goto do_retry;
236 // try to create a new session
238
240 if (status) {
241 eprintf("nfs41_recover_session() failed with %d\n", status);
243 goto out;
244 }
245 goto do_retry;
246
247 case NFS4ERR_EXPIRED: /* revoked by lease expiration */
249 case NFS4ERR_STALE_STATEID: /* server reboot */
250 if (op1 == OP_SEQUENCE)
252 if (try_recovery && nfs41_recover_stateid(session,
253 &compound->args.argarray[compound->res.resarray_count-1]))
254 goto do_retry;
255 goto out;
256
257 case NFS4ERR_BADSLOT:
258 /* free the slot and retry with a new one */
260 goto out;
261 goto retry;
262
263 case NFS4ERR_GRACE:
264 case NFS4ERR_DELAY:
265#define RETRY_INDEFINITELY
266#ifndef RETRY_INDEFINITELY
267#define NUMBER_2_RETRY 19
268#endif
269
270#ifndef RETRY_INDEFINITELY
271 if (retry_count < NUMBER_2_RETRY) {
272#endif
273 if (op1 == OP_SEQUENCE)
275 if (compound->res.status == NFS4ERR_GRACE)
276 delayby = 5000;
277 else
278 delayby = 500*retry_count;
279 dprintf(1, "Compound returned %s: sleeping for %ums..\n",
280 (compound->res.status==NFS4ERR_GRACE)?"NFS4ERR_GRACE":"NFS4ERR_DELAY",
281 delayby);
282 Sleep(delayby);
283 dprintf(1, "Attempting to resend compound.\n");
284 goto do_retry;
285#ifndef RETRY_INDEFINITELY
286 }
287#endif
288 break;
289
290 case NFS4ERR_FHEXPIRED: /* TODO: recover expired volatile filehandles */
291 status = NFS4ERR_STALE; /* for now, treat them as ERR_STALE */
292 /* no break */
293 case NFS4ERR_STALE:
294 {
295 nfs_argop4 *argarray = compound->args.argarray;
296 struct nfs41_name_cache *name_cache =
298 nfs41_putfh_args *putfh;
299 uint32_t i, start = 0;
300
301 /* NFS4ERR_STALE generally comes from a PUTFH operation. in
302 * this case, remove its filehandle from the name cache. but
303 * because COMPOUNDs are not atomic, a file can be removed
304 * between PUTFH and the operation that uses it. in this
305 * case, we can't tell which PUTFH operation is to blame, so
306 * we must invalidate filehandles of all PUTFH operations in
307 * the COMPOUND */
308
309 if (argarray[compound->res.resarray_count-1].op == OP_PUTFH)
310 start = compound->res.resarray_count-1;
311
312 for (i = start; i < compound->res.resarray_count; i++) {
313 if (argarray[i].op == OP_PUTFH) {
314 putfh = (nfs41_putfh_args*)argarray[i].arg;
315
316 if (!putfh->in_recovery && putfh->file->path)
318 session, putfh->file->path);
319 }
320 }
321 }
322 break;
323 case NFS4ERR_WRONGSEC:
324 {
325 nfs41_secinfo_info secinfo[MAX_SECINFOS] = { 0 };
326 uint32_t rcount = compound->res.resarray_count;
327 nfs_argop4 *argarray = compound->args.argarray;
328 uint32_t op = argarray[rcount-1].op;
329 nfs41_putfh_args *putfh;
331 switch(op) {
332 case OP_PUTFH:
333 case OP_RESTOREFH:
334 case OP_LINK:
335 case OP_RENAME:
336 case OP_PUTROOTFH:
337 case OP_LOOKUP:
338 case OP_OPEN:
340 case OP_SECINFO:
341 if (op1 == OP_SEQUENCE)
343 /* from: 2.6.3.1.1.5. Put Filehandle Operation + SECINFO/SECINFO_NO_NAME
344 * The NFSv4.1 server MUST NOT return NFS4ERR_WRONGSEC to a put
345 * filehandle operation that is immediately followed by SECINFO or
346 * SECINFO_NO_NAME. The NFSv4.1 server MUST NOT return NFS4ERR_WRONGSEC
347 * from SECINFO or SECINFO_NO_NAME.
348 */
349 if (op1 == OP_SEQUENCE &&
350 (argarray[1].op == OP_PUTFH ||
351 argarray[1].op == OP_PUTROOTFH) &&
352 (argarray[2].op == OP_SECINFO_NO_NAME ||
353 argarray[2].op == OP_SECINFO)) {
354 dprintf(1, "SECINFO: BROKEN SERVER\n");
355 goto out;
356 }
357 if (!try_recovery)
358 goto out;
360 goto do_retry;
361
362 saved_sec_flavor = session->client->rpc->sec_flavor;
363 saved_auth = session->client->rpc->rpc->cl_auth;
364 if (op == OP_LOOKUP || op == OP_OPEN) {
365 const nfs41_component *name;
366 nfs41_path_fh tmp = { 0 };
367 nfs41_getfh_res *getfh;
368 nfs41_lookup_args *largs;
370 if (argarray[rcount-2].op == OP_PUTFH) {
371 putfh = (nfs41_putfh_args *)argarray[rcount-2].arg;
372 file = putfh->file;
373 } else if (argarray[rcount-2].op == OP_GETATTR &&
374 argarray[rcount-3].op == OP_GETFH) {
375 getfh = (nfs41_getfh_res *)compound->res.resarray[rcount-3].res;
376 memcpy(&tmp.fh, getfh->fh, sizeof(nfs41_fh));
377 file = &tmp;
378 }
379 else {
381 goto out;
382 }
383
384 if (op == OP_LOOKUP) {
385 largs = (nfs41_lookup_args *)argarray[rcount-1].arg;
386 name = largs->name;
387 } else if (op == OP_OPEN) {
388 oargs = (nfs41_op_open_args *)argarray[rcount-1].arg;
389 name = oargs->claim->u.null.filename;
390 }
391 secinfo_status = nfs41_secinfo(session, file, name, secinfo);
392 if (secinfo_status) {
393 eprintf("nfs41_secinfo failed with %d\n", secinfo_status);
395 if (secinfo_status == NFS4ERR_BADSESSION) {
396 if (op1 == OP_SEQUENCE)
398 goto do_retry;
399 }
400 goto out_free_slot;
401 }
402 }
403 else {
404 if (op == OP_PUTFH) {
405 putfh = (nfs41_putfh_args *)argarray[rcount-1].arg;
406 file = putfh->file;
407 }
408 secinfo_status = nfs41_secinfo_noname(session, file, secinfo);
409 if (secinfo_status) {
410 eprintf("nfs41_secinfo_noname failed with %d\n",
411 secinfo_status);
413 if (op1 == OP_SEQUENCE)
415 goto out_free_slot;
416 }
417 }
418 secinfo_status = create_new_rpc_auth(session, op, secinfo);
419 if (!secinfo_status) {
420 auth_destroy(saved_auth);
422 // Need to retry only
423 goto do_retry;
424 } else {
425 AcquireSRWLockExclusive(&session->client->rpc->lock);
426 session->client->rpc->sec_flavor = saved_sec_flavor;
427 session->client->rpc->rpc->cl_auth = saved_auth;
428 ReleaseSRWLockExclusive(&session->client->rpc->lock);
430 }
431 break;
432 }
433 }
434 }
435 if (compound->res.resarray[0].op == OP_SEQUENCE) {
436 nfs41_sequence_res *seq =
437 (nfs41_sequence_res *)compound->res.resarray[0].res;
438 if (seq->sr_status == NFS4_OK && session->client->rpc->needcb &&
442 session->session_id, CDFC4_BACK_OR_BOTH);
443 goto out;
444 }
445 }
446out_free_slot:
447 if (op1 == OP_SEQUENCE)
449out:
450 return status;
451
452do_retry:
453 if (compound->res.resarray[0].op == OP_SEQUENCE)
455 &args->sa_sequenceid, &args->sa_highest_slotid);
456 goto retry;
457}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
bool_t nfs41_recover_stateid(IN nfs41_session *session, IN nfs_argop4 *argop)
Definition: recovery.c:788
void nfs41_recovery_finish(IN nfs41_client *client)
Definition: recovery.c:57
int nfs41_recover_session(IN nfs41_session *session, IN bool_t client_state_lost)
Definition: recovery.c:69
bool_t nfs41_recovery_start_or_wait(IN nfs41_client *client)
Definition: recovery.c:34
void nfs41_recover_sequence_flags(IN nfs41_session *session, IN uint32_t flags)
Definition: recovery.c:98
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
const char * nfs_error_string(int status)
Definition: daemon_debug.c:370
void print_hexbuf(int level, unsigned char *title, unsigned char *buf, int len)
Definition: daemon_debug.c:98
void print_sr_status_flags(int level, int flags)
Definition: daemon_debug.c:525
#define auth_destroy(auth)
Definition: auth.h:259
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
UINT op
Definition: effect.c:236
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
GLuint start
Definition: gl.h:1545
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int nfs41_name_cache_remove_stale(IN struct nfs41_name_cache *cache, IN nfs41_session *session, IN nfs41_abs_path *path)
Definition: name_cache.c:1359
static __inline struct nfs41_name_cache * session_name_cache(IN nfs41_session *session)
Definition: name_cache.h:34
int nfs41_send_compound(IN nfs41_rpc_clnt *rpc, IN char *inbuf, OUT char *outbuf)
Definition: nfs41_rpc.c:337
void nfs41_session_free_slot(IN nfs41_session *session, IN uint32_t slotid)
void nfs41_session_get_slot(IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seq, OUT uint32_t *highest)
void nfs41_session_bump_seq(IN nfs41_session *session, IN uint32_t slotid, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:80
int nfs41_client_renew(IN nfs41_client *client)
Definition: nfs41_client.c:168
int nfs41_session_bad_slot(IN nfs41_session *session, IN OUT struct __nfs41_sequence_args *args)
static void set_expected_res(nfs41_compound *compound)
static int create_new_rpc_auth(nfs41_session *session, uint32_t op, nfs41_secinfo_info *secinfo)
#define NFS4_SESSIONID_SIZE
Definition: nfs41_const.h:32
@ NFS4ERR_BAD_STATEID
Definition: nfs41_const.h:132
@ NFS4ERR_EXPIRED
Definition: nfs41_const.h:116
@ NFS4ERR_DELAY
Definition: nfs41_const.h:113
@ NFS4ERR_BADSLOT
Definition: nfs41_const.h:162
@ NFS4ERR_WRONGSEC
Definition: nfs41_const.h:121
@ NFS4ERR_FHEXPIRED
Definition: nfs41_const.h:119
@ NFS4ERR_BADSESSION
Definition: nfs41_const.h:161
@ NFS4ERR_STALE_CLIENTID
Definition: nfs41_const.h:129
@ NFS4_OK
Definition: nfs41_const.h:87
@ NFS4ERR_IO
Definition: nfs41_const.h:90
@ NFS4ERR_STALE_STATEID
Definition: nfs41_const.h:130
@ NFS4ERR_GRACE
Definition: nfs41_const.h:118
@ NFS4ERR_STALE
Definition: nfs41_const.h:106
int nfs41_secinfo_noname(IN nfs41_session *session, IN nfs41_path_fh *file, OUT nfs41_secinfo_info *secinfo)
Definition: nfs41_ops.c:1828
enum nfsstat4 nfs41_bind_conn_to_session(IN nfs41_rpc_clnt *rpc, IN const unsigned char *sessionid, IN enum channel_dir_from_client4 dir)
Definition: nfs41_ops.c:185
int nfs41_secinfo(IN nfs41_session *session, IN nfs41_path_fh *file, IN const nfs41_component *name, OUT nfs41_secinfo_info *secinfo)
Definition: nfs41_ops.c:1785
#define MAX_SECINFOS
Definition: nfs41_ops.h:881
@ OP_RESTOREFH
Definition: nfs41_ops.h:59
@ OP_OPEN
Definition: nfs41_ops.h:46
@ OP_SECINFO_NO_NAME
Definition: nfs41_ops.h:82
@ OP_GETFH
Definition: nfs41_ops.h:38
@ OP_CREATE_SESSION
Definition: nfs41_ops.h:73
@ OP_SECINFO
Definition: nfs41_ops.h:61
@ OP_PUTROOTFH
Definition: nfs41_ops.h:52
@ OP_RENAME
Definition: nfs41_ops.h:57
@ OP_GETATTR
Definition: nfs41_ops.h:37
@ OP_SEQUENCE
Definition: nfs41_ops.h:83
@ OP_PUTFH
Definition: nfs41_ops.h:50
@ OP_LOOKUP
Definition: nfs41_ops.h:43
@ OP_LINK
Definition: nfs41_ops.h:39
@ CDFC4_BACK_OR_BOTH
Definition: nfs41_ops.h:186
@ SEQ4_STATUS_CB_PATH_DOWN
Definition: nfs41_ops.h:237
#define dprintf
Definition: regdump.c:33
static FILE * out
Definition: regtests2xml.c:44
va_list oargs
Definition: format.c:255
Definition: auth.h:205
nfs41_fh * fh
Definition: nfs41_ops.h:504
const nfs41_component * name
Definition: nfs41_ops.h:492
nfs41_abs_path * path
Definition: nfs41_types.h:60
nfs41_path_fh * file
Definition: nfs41_ops.h:510
unsigned char sr_sessionid[NFS4_SESSIONID_SIZE]
Definition: nfs41_ops.h:253
uint32_t sr_target_highest_slotid
Definition: nfs41_ops.h:257
nfs41_sequence_res_ok sr_resok4
Definition: nfs41_ops.h:264
Definition: match.c:390
Definition: fci.c:127
Definition: name.c:39
Definition: ps.c:97
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150

Referenced by lookup_rpc(), nfs41_access(), nfs41_close(), nfs41_commit(), nfs41_create(), nfs41_create_session(), nfs41_delegpurge(), nfs41_delegreturn(), nfs41_destroy_session(), nfs41_free_stateid(), nfs41_fs_locations(), nfs41_getattr(), nfs41_link(), nfs41_lock(), nfs41_open(), nfs41_read(), nfs41_readdir(), nfs41_readlink(), nfs41_reclaim_complete(), nfs41_remove(), nfs41_rename(), nfs41_rpc_openattr(), nfs41_secinfo(), nfs41_secinfo_noname(), nfs41_send_sequence(), nfs41_setattr(), nfs41_superblock_getattr(), nfs41_test_stateid(), nfs41_unlock(), nfs41_want_delegation(), nfs41_write(), pnfs_rpc_getdeviceinfo(), pnfs_rpc_layoutcommit(), pnfs_rpc_layoutget(), pnfs_rpc_layoutreturn(), and rpc_array_putfh().

◆ compound_error()

◆ compound_init()

void compound_init ( nfs41_compound compound,
nfs_argop4 argops,
nfs_resop4 resops,
const char tag 
)

Definition at line 41 of file nfs41_compound.c.

46{
47 /* initialize args */
48 compound->args.tag_len = (uint32_t)strlen(tag);
49 memcpy(compound->args.tag, tag, compound->args.tag_len);
50 compound->args.minorversion = 1;
51 compound->args.argarray_count = 0;
52 compound->args.argarray = argops;
53
54 /* initialize results */
55 ZeroMemory(&compound->res, sizeof(nfs41_compound_res));
56 compound->res.tag_len = NFS4_OPAQUE_LIMIT;
57 compound->res.resarray_count = 0;
58 compound->res.resarray = resops;
59}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NFS4_OPAQUE_LIMIT
Definition: nfs41_const.h:31
#define uint32_t
Definition: nsiface.idl:61
unsigned char tag[NFS4_OPAQUE_LIMIT]
Definition: ecma_167.h:138
#define ZeroMemory
Definition: winbase.h:1712

Referenced by lookup_rpc(), nfs41_access(), nfs41_bind_conn_to_session(), nfs41_close(), nfs41_commit(), nfs41_create(), nfs41_create_session(), nfs41_delegpurge(), nfs41_delegreturn(), nfs41_destroy_clientid(), nfs41_destroy_session(), nfs41_exchange_id(), nfs41_free_stateid(), nfs41_fs_locations(), nfs41_getattr(), nfs41_link(), nfs41_lock(), nfs41_open(), nfs41_read(), nfs41_readdir(), nfs41_readlink(), nfs41_reclaim_complete(), nfs41_remove(), nfs41_rename(), nfs41_rpc_openattr(), nfs41_secinfo(), nfs41_secinfo_noname(), nfs41_send_sequence(), nfs41_setattr(), nfs41_superblock_getattr(), nfs41_test_stateid(), nfs41_unlock(), nfs41_want_delegation(), nfs41_write(), pnfs_rpc_getdeviceinfo(), pnfs_rpc_layoutcommit(), pnfs_rpc_layoutget(), pnfs_rpc_layoutreturn(), and rpc_array_putfh().

◆ create_new_rpc_auth()

static int create_new_rpc_auth ( nfs41_session session,
uint32_t  op,
nfs41_secinfo_info secinfo 
)
static

Definition at line 91 of file nfs41_compound.c.

93{
94 AUTH *auth = NULL;
97
98 for (i = 0; i < MAX_SECINFOS; i++) {
99 if (!secinfo[i].sec_flavor && !secinfo[i].type)
100 goto out;
101 if (secinfo[i].sec_flavor == RPCSEC_GSS) {
102 auth = authsspi_create_default(session->client->rpc->rpc,
103 session->client->rpc->server_name, secinfo[i].type);
104 if (auth == NULL) {
105 eprintf("handle_wrongsecinfo_noname: authsspi_create_default for "
106 "gsstype %s failed\n", gssauth_string(secinfo[i].type));
107 continue;
108 }
109 sec_flavor = secinfo[i].type;
110 } else {
111 char machname[MAXHOSTNAMELEN + 1];
112 gid_t gids[1];
113 if (gethostname(machname, sizeof(machname)) == -1) {
114 eprintf("nfs41_rpc_clnt_create: gethostname failed\n");
115 continue;
116 }
117 machname[sizeof(machname) - 1] = '\0';
118 auth = authsys_create(machname, session->client->rpc->uid,
119 session->client->rpc->gid, 0, gids);
120 if (auth == NULL) {
121 eprintf("handle_wrongsecinfo_noname: authsys_create failed\n");
122 continue;
123 }
125 }
126 AcquireSRWLockExclusive(&session->client->rpc->lock);
127 session->client->rpc->sec_flavor = sec_flavor;
128 session->client->rpc->rpc->cl_auth = auth;
129 ReleaseSRWLockExclusive(&session->client->rpc->lock);
130 status = 0;
131 break;
132 }
133out:
134 return status;
135}
AUTH * authsspi_create_default(CLIENT *clnt, char *service, int svc)
Definition: auth_sspi.c:133
#define MAXHOSTNAMELEN
Definition: ftp.c:31
const char * gssauth_string(int type)
Definition: daemon_debug.c:504
#define AUTH_SYS
Definition: auth.h:403
#define authsys_create(c, i1, i2, i3, ip)
Definition: auth.h:323
UINT gid_t
Definition: types.h:89
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
Definition: getxbyxx.c:397
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
sec_flavor
Definition: nfs41_ops.h:861
#define RPCSEC_GSS
Definition: nfs41_ops.h:867
enum sec_flavor type
Definition: nfs41_ops.h:874
#define ERROR_NETWORK_UNREACHABLE
Definition: winerror.h:734

Referenced by compound_encode_send_decode().

◆ set_expected_res()

static void set_expected_res ( nfs41_compound compound)
static

Definition at line 81 of file nfs41_compound.c.

83{
84 uint32_t i;
85 compound->res.resarray_count = compound->args.argarray_count;
86 for (i = 0; i < compound->res.resarray_count; i++)
87 compound->res.resarray[i].op = compound->args.argarray[i].op;
88}

Referenced by compound_encode_send_decode().