@@ -92,45 +92,131 @@ int nfs4_fill_create_attrs(struct fuse_in_header *in_hdr, uint32_t mode, fattr4
92
92
return 0 ;
93
93
}
94
94
95
+ bool nfs4_check_session_trunking_allowed (EXCHANGE_ID4resok * l , EXCHANGE_ID4resok * r ) {
96
+ return l -> eir_clientid == r -> eir_clientid
97
+ && l -> eir_server_owner .so_major_id .so_major_id_len == r -> eir_server_owner .so_major_id .so_major_id_len
98
+ && memcmp (l -> eir_server_owner .so_major_id .so_major_id_val , r -> eir_server_owner
99
+ .so_major_id .so_major_id_val , l -> eir_server_owner .so_major_id .so_major_id_len ) == 0
100
+ && l -> eir_server_owner .so_minor_id == r -> eir_server_owner .so_minor_id
101
+ && l -> eir_server_scope .eir_server_scope_len == r -> eir_server_scope .eir_server_scope_len
102
+ && memcmp (l -> eir_server_scope .eir_server_scope_val , r -> eir_server_scope
103
+ .eir_server_scope_val , l -> eir_server_scope .eir_server_scope_len ) == 0 ;
104
+ }
105
+
106
+ int nfs4_op_createsession (nfs_argop4 * op , clientid4 clientid )
107
+ {
108
+ CREATE_SESSION4args * arg ;
109
+ op [0 ].argop = OP_BIND_CONN_TO_SESSION ;
110
+ arg = & op [0 ].nfs_argop4_u .opcreatesession ;
111
+
112
+ arg -> csa_clientid = clientid ;
113
+ arg -> csa_flags = 0 ;
114
+ arg -> csa_cb_program = 0 ;
115
+ arg -> csa_sec_parms .csa_sec_parms_val = NULL ;
116
+ arg -> csa_sec_parms .csa_sec_parms_len = 0 ;
117
+
118
+ // Currently no caching support
119
+ arg -> csa_fore_chan_attrs .ca_maxresponsesize_cached = 0 ;
120
+ arg -> csa_fore_chan_attrs .ca_maxrequests = NFS4_MAXREQUESTSIZE ;
121
+ arg -> csa_fore_chan_attrs .ca_maxresponsesize = NFS4_MAXRESPONSESIZE ;
122
+ arg -> csa_fore_chan_attrs .ca_maxrequestsize = NFS4_MAXREQUESTSIZE ;
123
+ // We have too little control over libnfs to properly use this
124
+ arg -> csa_fore_chan_attrs .ca_headerpadsize = 0 ;
125
+ // Magic from the Linux kernel, 8 seems about right
126
+ arg -> csa_fore_chan_attrs .ca_maxoperations = NFS4_MAX_OPS ;
127
+ // No RDMA here
128
+ arg -> csa_fore_chan_attrs .ca_rdma_ird .ca_rdma_ird_val = NULL ;
129
+ arg -> csa_fore_chan_attrs .ca_rdma_ird .ca_rdma_ird_len = 0 ;
130
+
131
+ // Currently no caching support
132
+ arg -> csa_back_chan_attrs .ca_maxresponsesize_cached = 0 ;
133
+ arg -> csa_back_chan_attrs .ca_maxrequests = NFS4_MAXREQUESTSIZE ;
134
+ arg -> csa_back_chan_attrs .ca_maxresponsesize = NFS4_MAXRESPONSESIZE ;
135
+ arg -> csa_back_chan_attrs .ca_maxrequestsize = NFS4_MAXREQUESTSIZE ;
136
+ // We have too little control over libnfs to properly use this
137
+ arg -> csa_back_chan_attrs .ca_headerpadsize = 0 ;
138
+ // Magic from the Linux kernel, 8 seems about right
139
+ arg -> csa_back_chan_attrs .ca_maxoperations = NFS4_MAX_OPS ;
140
+ // No RDMA here
141
+ arg -> csa_back_chan_attrs .ca_rdma_ird .ca_rdma_ird_val = NULL ;
142
+ arg -> csa_back_chan_attrs .ca_rdma_ird .ca_rdma_ird_len = 0 ;
143
+
144
+ return 1 ;
145
+ }
146
+
147
+
148
+ int nfs4_op_bindconntosession (nfs_argop4 * op , sessionid4 * sessionid , channel_dir_from_client4 channel , bool rdma )
149
+ {
150
+ BIND_CONN_TO_SESSION4args * bindargs ;
151
+ op [0 ].argop = OP_BIND_CONN_TO_SESSION ;
152
+ bindargs = & op [0 ].nfs_argop4_u .opbindconntosession ;
153
+
154
+ memcpy (& bindargs -> bctsa_sessid , sessionid , sizeof (sessionid4 ));
155
+ bindargs -> bctsa_dir = CDFC4_FORE_OR_BOTH ;
156
+ bindargs -> bctsa_use_conn_in_rdma_mode = rdma ;
157
+
158
+ return 1 ;
159
+ }
160
+
161
+ int nfs4_op_exchangeid (nfs_argop4 * op , verifier4 verifier , const char * client_name )
162
+ {
163
+ EXCHANGE_ID4args * exidargs ;
164
+ op [0 ].argop = OP_EXCHANGE_ID ;
165
+ exidargs = & op [0 ].nfs_argop4_u .opexchangeid ;
166
+
167
+ memcpy (exidargs -> eia_clientowner .co_verifier , verifier , sizeof (verifier4 ));
168
+ exidargs -> eia_clientowner .co_ownerid .co_ownerid_val = (char * ) client_name ;
169
+ exidargs -> eia_clientowner .co_ownerid .co_ownerid_len = strlen (client_name );
170
+
171
+ exidargs -> eia_state_protect .spa_how = SP4_NONE ;
172
+
173
+ exidargs -> eia_flags = 0 ;
174
+
175
+ exidargs -> eia_client_impl_id .eia_client_impl_id_val = NULL ;
176
+ exidargs -> eia_client_impl_id .eia_client_impl_id_len = 0 ;
177
+
178
+ return 1 ;
179
+ }
180
+
95
181
/* Functions taken and modified from libnfs/lib/nfs_v4.c
96
182
* commit: 2678dfecd9c797991b7768490929b1478f339809 */
97
183
98
184
int nfs4_op_setclientid (nfs_argop4 * op , verifier4 verifier , const char * client_name )
99
185
{
100
- SETCLIENTID4args * scidargs ;
101
-
102
- op [0 ].argop = OP_SETCLIENTID ;
103
- scidargs = & op [ 0 ]. nfs_argop4_u . opsetclientid ;
104
- memcpy (scidargs -> client .verifier , verifier , sizeof (verifier4 ));
105
- scidargs -> client .id .id_len = strlen (client_name );
106
- scidargs -> client .id .id_val = (char * ) client_name ;
107
- /* TODO: Decide what we should do here. As long as we only
108
- * expose a single FD to the application we will not be able to
109
- * do NFSv4 callbacks easily.
110
- * Just give it garbage for now until we figure out how we should
111
- * solve this. Until then we will just have to avoid doing things
112
- * that require a callback.
113
- * ( Clients (i.e. Linux) ignore this anyway and just call back to
114
- * the originating address and program anyway. )
115
- */
116
- scidargs -> callback .cb_program = 0 ; /* NFS4_CALLBACK */
117
- scidargs -> callback .cb_location .r_netid = "tcp" ;
118
- scidargs -> callback .cb_location .r_addr = "0.0.0.0.0.0" ;
119
- scidargs -> callback_ident = 0x00000001 ;
120
-
121
- return 1 ;
186
+ SETCLIENTID4args * scidargs ;
187
+ op [ 0 ]. argop = OP_SETCLIENTID ;
188
+ scidargs = & op [0 ].nfs_argop4_u . opsetclientid ;
189
+
190
+ memcpy (scidargs -> client .verifier , verifier , sizeof (verifier4 ));
191
+ scidargs -> client .id .id_len = strlen (client_name );
192
+ scidargs -> client .id .id_val = (char * ) client_name ;
193
+ /* TODO: Decide what we should do here. As long as we only
194
+ * expose a single FD to the application we will not be able to
195
+ * do NFSv4 callbacks easily.
196
+ * Just give it garbage for now until we figure out how we should
197
+ * solve this. Until then we will just have to avoid doing things
198
+ * that require a callback.
199
+ * ( Clients (i.e. Linux) ignore this anyway and just call back to
200
+ * the originating address and program anyway. )
201
+ */
202
+ scidargs -> callback .cb_program = 0 ; /* NFS4_CALLBACK */
203
+ scidargs -> callback .cb_location .r_netid = "tcp" ;
204
+ scidargs -> callback .cb_location .r_addr = "0.0.0.0.0.0" ;
205
+ scidargs -> callback_ident = 0x00000001 ;
206
+
207
+ return 1 ;
122
208
}
123
209
124
210
int nfs4_op_setclientid_confirm (struct nfs_argop4 * op , uint64_t clientid , verifier4 verifier )
125
211
{
126
- SETCLIENTID_CONFIRM4args * scidcargs ;
212
+ SETCLIENTID_CONFIRM4args * scidcargs ;
127
213
128
- op [0 ].argop = OP_SETCLIENTID_CONFIRM ;
129
- scidcargs = & op [0 ].nfs_argop4_u .opsetclientid_confirm ;
130
- scidcargs -> clientid = clientid ;
131
- memcpy (scidcargs -> setclientid_confirm , verifier , NFS4_VERIFIER_SIZE );
214
+ op [0 ].argop = OP_SETCLIENTID_CONFIRM ;
215
+ scidcargs = & op [0 ].nfs_argop4_u .opsetclientid_confirm ;
216
+ scidcargs -> clientid = clientid ;
217
+ memcpy (scidcargs -> setclientid_confirm , verifier , NFS4_VERIFIER_SIZE );
132
218
133
- return 1 ;
219
+ return 1 ;
134
220
}
135
221
136
222
int nfs4_find_op (COMPOUND4res * res , int op )
0 commit comments