Skip to content

Commit abfdbd5

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
SUNRPC: Faster detection if gssd is actually running
Recent changes to the NFS security flavour negotiation mean that we have a stronger dependency on rpc.gssd. If the latter is not running, because the user failed to start it, then we time out and mark the container as not having an instance. We then use that information to time out faster the next time. If, on the other hand, the rpc.gssd successfully binds to an rpc_pipe, then we mark the container as having an rpc.gssd instance. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent d36ccb9 commit abfdbd5

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎net/sunrpc/auth_gss/auth_gss.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#include <linux/sunrpc/gss_api.h>
5353
#include <asm/uaccess.h>
5454

55+
#include "../netns.h"
56+
5557
static const struct rpc_authops authgss_ops;
5658

5759
static const struct rpc_credops gss_credops;
@@ -559,21 +561,30 @@ gss_refresh_upcall(struct rpc_task *task)
559561
static inline int
560562
gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
561563
{
564+
struct net *net = rpc_net_ns(gss_auth->client);
565+
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
562566
struct rpc_pipe *pipe;
563567
struct rpc_cred *cred = &gss_cred->gc_base;
564568
struct gss_upcall_msg *gss_msg;
569+
unsigned long timeout;
565570
DEFINE_WAIT(wait);
566571
int err;
567572

568573
dprintk("RPC: %s for uid %u\n",
569574
__func__, from_kuid(&init_user_ns, cred->cr_uid));
570575
retry:
571576
err = 0;
577+
/* Default timeout is 15s unless we know that gssd is not running */
578+
timeout = 15 * HZ;
579+
if (!sn->gssd_running)
580+
timeout = HZ >> 2;
572581
gss_msg = gss_setup_upcall(gss_auth->client, gss_auth, cred);
573582
if (PTR_ERR(gss_msg) == -EAGAIN) {
574583
err = wait_event_interruptible_timeout(pipe_version_waitqueue,
575-
pipe_version >= 0, 15*HZ);
584+
pipe_version >= 0, timeout);
576585
if (pipe_version < 0) {
586+
if (err == 0)
587+
sn->gssd_running = 0;
577588
warn_gssd();
578589
err = -EACCES;
579590
}

‎net/sunrpc/netns.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct sunrpc_net {
2929
struct rpc_clnt *gssp_clnt;
3030
int use_gss_proxy;
3131
struct proc_dir_entry *use_gssp_proc;
32+
33+
unsigned int gssd_running;
3234
};
3335

3436
extern int sunrpc_net_id;

‎net/sunrpc/rpc_pipe.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,14 @@ rpc_destroy_inode(struct inode *inode)
216216
static int
217217
rpc_pipe_open(struct inode *inode, struct file *filp)
218218
{
219+
struct net *net = inode->i_sb->s_fs_info;
220+
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
219221
struct rpc_pipe *pipe;
220222
int first_open;
221223
int res = -ENXIO;
222224

223225
mutex_lock(&inode->i_mutex);
226+
sn->gssd_running = 1;
224227
pipe = RPC_I(inode)->pipe;
225228
if (pipe == NULL)
226229
goto out;
@@ -1069,6 +1072,7 @@ void rpc_pipefs_init_net(struct net *net)
10691072
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
10701073

10711074
mutex_init(&sn->pipefs_sb_lock);
1075+
sn->gssd_running = 1;
10721076
}
10731077

10741078
/*

0 commit comments

Comments
 (0)