summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/klm/nlm_impl.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/klm/nlm_impl.c')
-rw-r--r--usr/src/uts/common/klm/nlm_impl.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/usr/src/uts/common/klm/nlm_impl.c b/usr/src/uts/common/klm/nlm_impl.c
index bab08acdae..cbba11f6ed 100644
--- a/usr/src/uts/common/klm/nlm_impl.c
+++ b/usr/src/uts/common/klm/nlm_impl.c
@@ -28,6 +28,7 @@
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright 2017 Joyent, Inc. All rights reserved.
*/
/*
@@ -57,6 +58,7 @@
#include <sys/queue.h>
#include <sys/bitmap.h>
#include <sys/sdt.h>
+#include <sys/brand.h>
#include <netinet/in.h>
#include <rpc/rpc.h>
@@ -202,6 +204,12 @@ static struct nlm_knc nlm_netconfigs[] = { /* (g) */
};
/*
+ * NLM functions which can be called by a brand hook.
+ */
+void nlm_netbuf_to_netobj(struct netbuf *, int *, netobj *);
+void nlm_nsm_clnt_init(CLIENT *, struct nlm_nsm *);
+
+/*
* NLM misc. function
*/
static void nlm_copy_netbuf(struct netbuf *, struct netbuf *);
@@ -210,8 +218,6 @@ static void nlm_kmem_reclaim(void *);
static void nlm_pool_shutdown(void);
static void nlm_suspend_zone(struct nlm_globals *);
static void nlm_resume_zone(struct nlm_globals *);
-static void nlm_nsm_clnt_init(CLIENT *, struct nlm_nsm *);
-static void nlm_netbuf_to_netobj(struct netbuf *, int *, netobj *);
/*
* NLM thread functions
@@ -1847,6 +1853,12 @@ nlm_host_unmonitor(struct nlm_globals *g, struct nlm_host *host)
return;
host->nh_flags &= ~NLM_NH_MONITORED;
+
+ if (ZONE_IS_BRANDED(curzone) && ZBROP(curzone)->b_rpc_statd != NULL) {
+ ZBROP(curzone)->b_rpc_statd(SM_UNMON, g, host);
+ return;
+ }
+
stat = nlm_nsm_unmon(&g->nlm_nsm, host->nh_name);
if (stat != RPC_SUCCESS) {
NLM_WARN("NLM: Failed to contact statd, stat=%d\n", stat);
@@ -1885,6 +1897,11 @@ nlm_host_monitor(struct nlm_globals *g, struct nlm_host *host, int state)
host->nh_flags |= NLM_NH_MONITORED;
mutex_exit(&host->nh_lock);
+ if (ZONE_IS_BRANDED(curzone) && ZBROP(curzone)->b_rpc_statd != NULL) {
+ ZBROP(curzone)->b_rpc_statd(SM_MON, g, host);
+ return;
+ }
+
/*
* Before we begin monitoring the host register the network address
* associated with this hostname.
@@ -2361,6 +2378,13 @@ nlm_svc_starting(struct nlm_globals *g, struct file *fp,
VERIFY(g->run_status == NLM_ST_STARTING);
VERIFY(g->nlm_gc_thread == NULL);
+ if (g->nlm_v4_only) {
+ NLM_WARN("Zone %d has no rpcbind, NLM is v4 only", getzoneid());
+ bzero(&g->nlm_nsm, sizeof (struct nlm_nsm));
+ g->nlm_nsm.ns_addr_handle = (void *)-1;
+ goto v4_only;
+ }
+
error = nlm_nsm_init_local(&g->nlm_nsm);
if (error != 0) {
NLM_ERR("Failed to initialize NSM handler "
@@ -2397,6 +2421,7 @@ nlm_svc_starting(struct nlm_globals *g, struct file *fp,
"(rpcerr=%d)\n", stat);
goto shutdown_lm;
}
+v4_only:
g->grace_threshold = ddi_get_lbolt() +
SEC_TO_TICK(g->grace_period);
@@ -2520,7 +2545,9 @@ nlm_svc_stopping(struct nlm_globals *g)
ASSERT(TAILQ_EMPTY(&g->nlm_slocks));
- nlm_nsm_fini(&g->nlm_nsm);
+ /* If started with rpcbind (the normal case) */
+ if (g->nlm_nsm.ns_addr_handle != (void *)-1)
+ nlm_nsm_fini(&g->nlm_nsm);
g->lockd_pid = 0;
g->run_status = NLM_ST_DOWN;
}
@@ -2814,14 +2841,14 @@ nlm_cprresume(void)
rw_exit(&lm_lck);
}
-static void
+void
nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
{
(void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
NLM_RPC_RETRIES, zone_kcred());
}
-static void
+void
nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
{
/* LINTED pointer alignment */