- struct auth_cred acred;
- struct rpc_clnt *clnt = clp->cl_callback.cb_client;
- struct rpc_cred *ret;
-
- get_group_info(clp->cl_cred.cr_group_info);
- acred.uid = clp->cl_cred.cr_uid;
- acred.gid = clp->cl_cred.cr_gid;
- acred.group_info = clp->cl_cred.cr_group_info;
-
- dprintk("NFSD: looking up %s cred\n",
- clnt->cl_auth->au_ops->au_name);
- ret = rpcauth_lookup_credcache(clnt->cl_auth, &acred, taskflags);
- put_group_info(clp->cl_cred.cr_group_info);
- return ret;
+ return max(NFSD_LEASE_TIME/10, (time_t)1) * HZ;
+}
+
+/* Reference counting, callback cleanup, etc., all look racy as heck.
+ * And why is cb_set an atomic? */
+
+int setup_callback_client(struct nfs4_client *clp)
+{
+ struct nfs4_cb_conn *cb = &clp->cl_cb_conn;
+ struct rpc_timeout timeparms = {
+ .to_initval = max_cb_time(),
+ .to_retries = 0,
+ };
+ struct rpc_create_args args = {
+ .protocol = XPRT_TRANSPORT_TCP,
+ .address = (struct sockaddr *) &cb->cb_addr,
+ .addrsize = cb->cb_addrlen,
+ .timeout = &timeparms,
+ .program = &cb_program,
+ .prognumber = cb->cb_prog,
+ .version = nfs_cb_version[1]->number,
+ .authflavor = clp->cl_flavor,
+ .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET),
+ .client_name = clp->cl_principal,
+ };
+ struct rpc_clnt *client;
+
+ if (!clp->cl_principal && (clp->cl_flavor >= RPC_AUTH_GSS_KRB5))
+ return -EINVAL;
+ if (cb->cb_minorversion) {
+ args.bc_xprt = clp->cl_cb_xprt;
+ args.protocol = XPRT_TRANSPORT_BC_TCP;
+ }
+ /* Create RPC client */
+ client = rpc_create(&args);
+ if (IS_ERR(client)) {
+ dprintk("NFSD: couldn't create callback client: %ld\n",
+ PTR_ERR(client));
+ return PTR_ERR(client);
+ }
+ cb->cb_client = client;
+ return 0;
+
+}
+
+static void warn_no_callback_path(struct nfs4_client *clp, int reason)
+{
+ dprintk("NFSD: warning: no callback path to client %.*s: error %d\n",
+ (int)clp->cl_name.len, clp->cl_name.data, reason);
+}
+
+static void nfsd4_cb_probe_done(struct rpc_task *task, void *calldata)
+{
+ struct nfs4_client *clp = calldata;
+
+ if (task->tk_status)
+ warn_no_callback_path(clp, task->tk_status);
+ else
+ atomic_set(&clp->cl_cb_conn.cb_set, 1);
+ put_nfs4_client(clp);
+}
+
+static const struct rpc_call_ops nfsd4_cb_probe_ops = {
+ .rpc_call_done = nfsd4_cb_probe_done,
+};
+
+static struct rpc_cred *callback_cred;
+
+int set_callback_cred(void)
+{
+ if (callback_cred)
+ return 0;
+ callback_cred = rpc_lookup_machine_cred();
+ if (!callback_cred)
+ return -ENOMEM;
+ return 0;
+}
+
+
+void do_probe_callback(struct nfs4_client *clp)
+{
+ struct nfs4_cb_conn *cb = &clp->cl_cb_conn;
+ struct rpc_message msg = {
+ .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
+ .rpc_argp = clp,
+ .rpc_cred = callback_cred
+ };
+ int status;
+
+ status = rpc_call_async(cb->cb_client, &msg,
+ RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
+ &nfsd4_cb_probe_ops, (void *)clp);
+ if (status) {
+ warn_no_callback_path(clp, status);
+ put_nfs4_client(clp);
+ }