Skip to content

Commit 5075ab7

Browse files
committed
nfs4.1: implement BACKCHANNEL_CTL operation
Motivation: BACKCHANNEL_CTL allows clients to replace security flavor of callback channel. Up to now, nfs4j doesn't support it. Modification: Add OperationBACKCHANNEL_CTL that will replace security flavor of backchannel for nfsv4.1 clients. Result: better spec support. Acked-by: Marina Sahakyan Target: master
1 parent 79123cf commit 5075ab7

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

core/src/main/java/org/dcache/nfs/v4/MDSOperationExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ protected AbstractNFSv4Operation getOperation(nfs_argop4 op) {
107107
return new OperationWRITE(op);
108108
case nfs_opnum4.OP_RELEASE_LOCKOWNER:
109109
return new OperationRELEASE_LOCKOWNER(op);
110+
case nfs_opnum4.OP_BACKCHANNEL_CTL:
111+
return new OperationBACKCHANNEL_CTL(op);
110112
/**
111113
* NFSv4.1 (pNFS)
112114
*/
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2025 Deutsches Elektronen-Synchroton,
3+
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
4+
*
5+
* This library is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU Library General Public License as
7+
* published by the Free Software Foundation; either version 2 of the
8+
* License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Library General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Library General Public
16+
* License along with this program (see the file COPYING.LIB for more
17+
* details); if not, write to the Free Software Foundation, Inc.,
18+
* 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*/
20+
package org.dcache.nfs.v4;
21+
22+
import org.dcache.nfs.ChimeraNFSException;
23+
import org.dcache.nfs.nfsstat;
24+
import org.dcache.nfs.status.InvalException;
25+
import org.dcache.nfs.status.NfsIoException;
26+
import org.dcache.nfs.status.NotSuppException;
27+
import org.dcache.nfs.v4.xdr.nfs4_prot;
28+
import org.dcache.nfs.v4.xdr.nfs_argop4;
29+
import org.dcache.nfs.v4.xdr.nfs_opnum4;
30+
import org.dcache.nfs.v4.xdr.nfs_resop4;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
33+
34+
import java.io.IOException;
35+
import java.util.concurrent.TimeoutException;
36+
37+
public class OperationBACKCHANNEL_CTL extends AbstractNFSv4Operation {
38+
39+
public static final Logger LOG = LoggerFactory.getLogger(OperationBACKCHANNEL_CTL.class);
40+
41+
42+
public OperationBACKCHANNEL_CTL(nfs_argop4 op) {
43+
super(op, nfs_opnum4.OP_BACKCHANNEL_CTL);
44+
}
45+
46+
@Override
47+
public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNFSException {
48+
49+
if( context.getMinorversion() == 0) {
50+
throw new NotSuppException("Backchannel update for minor version " + context.getMinorversion() + " not supported");
51+
}
52+
53+
var session = context.getSession();
54+
var cb = new ClientCB(
55+
context.getRpcCall().getTransport().getPeerTransport(),
56+
_args.opbackchannel_ctl.bca_cb_program.value,
57+
context.getMinorversion(),
58+
session.id(),
59+
session.getMaxCbOps(),
60+
_args.opbackchannel_ctl.bca_sec_parms);
61+
62+
try {
63+
cb.cbPing();
64+
session.getClient().setCB(cb);
65+
} catch (IOException | TimeoutException e) {
66+
LOG.warn("Failed to to replace backchannel for {} : {}", session.getClient(), e.getMessage());
67+
throw new NfsIoException(e.getMessage());
68+
}
69+
70+
result.opbackchannel_ctl.bcr_status = nfsstat.NFS_OK;
71+
}
72+
}

0 commit comments

Comments
 (0)