summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-05-01 16:26:23 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-05-01 16:26:23 +0000
commit68cb90216586ebfa9b791300fb839044d28bcaf0 (patch)
tree1aea4915b836161240e4faede3022774530b071c
parent3a23bc3bf1ad922b3687f8aac18b0be92c9902b8 (diff)
parent5539384561c0efe744226d5e5d331f5546e500e4 (diff)
downloadillumos-joyent-68cb90216586ebfa9b791300fb839044d28bcaf0.tar.gz
[illumos-gate merge]20140501release-20140501
commit 5539384561c0efe744226d5e5d331f5546e500e4 4670 Resource leak in cots_listen_event() when set_addrmask() fails commit 9557befbc07a121f4baa233e966d24be5dca7345 4817 README.mapfiles: Missing version in an example commit 9a634533d15821efb93a491af59ea24d69227322 4812 libnsl: Some nisplus leftovers commit c5953fd0a23d8a0dc9475dfa76ad0dfd07663717 4808 libnsl: SI_SRPC_DOMAIN is always defined commit 0900f4f20e4cdeb8e5af4ba32aca32d28aeba2f9 4803 libnsl: recursive mutex lock in return_xprt_copy() commit dff8cdb7c81be0916631bfe5b4384516b430227f 4724 Possible memory leak in _clnt_vc_create_timed()
-rw-r--r--usr/src/cmd/avs/rdc/sndrd.c171
-rw-r--r--usr/src/cmd/fs.d/nfs/lib/nfs_tbind.c28
-rw-r--r--usr/src/lib/README.mapfiles2
-rw-r--r--usr/src/lib/libnsl/common/llib-lnsl5
-rw-r--r--usr/src/lib/libnsl/common/mapfile-vers7
-rw-r--r--usr/src/lib/libnsl/rpc/clnt_vc.c17
-rw-r--r--usr/src/lib/libnsl/rpc/getdname.c101
-rw-r--r--usr/src/lib/libnsl/rpc/svc_door.c39
-rw-r--r--usr/src/lib/libnsl/rpc/svc_vc.c189
9 files changed, 129 insertions, 430 deletions
diff --git a/usr/src/cmd/avs/rdc/sndrd.c b/usr/src/cmd/avs/rdc/sndrd.c
index 102478ffe0..f11129478e 100644
--- a/usr/src/cmd/avs/rdc/sndrd.c
+++ b/usr/src/cmd/avs/rdc/sndrd.c
@@ -23,6 +23,9 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
/*
* Network SNDR/ncall-ip server - based on nfsd
@@ -228,10 +231,9 @@ rdc_transport_open(struct netconfig *nconf)
fd = t_open(nconf->nc_device, O_RDWR, (struct t_info *)NULL);
if (fd == -1) {
if (t_errno == TSYSERR && errno == EMFILE &&
- (nofile_increase(0) == 0)) {
+ (nofile_increase(0) == 0)) {
/* Try again with a higher NOFILE limit. */
- fd = t_open(nconf->nc_device, O_RDWR,
- (struct t_info *)NULL);
+ fd = t_open(nconf->nc_device, O_RDWR, NULL);
}
if (fd == -1) {
if (t_errno == TSYSERR) {
@@ -276,11 +278,11 @@ rdc_transport_open(struct netconfig *nconf)
if (t_close(fd) == -1) {
if (t_errno == TSYSERR) {
syslog(LOG_ERR,
- "t_close failed on %d: %m", fd);
+ "t_close failed on %d: %m", fd);
} else {
syslog(LOG_ERR,
- "t_close failed on %d: %s",
- fd, t_errlist[t_errno]);
+ "t_close failed on %d: %s",
+ fd, t_errlist[t_errno]);
}
}
return (-1);
@@ -296,11 +298,11 @@ rdc_transport_open(struct netconfig *nconf)
if (t_close(fd) == -1) {
if (t_errno == TSYSERR) {
syslog(LOG_ERR,
- "t_close failed on %d: %m", fd);
+ "t_close failed on %d: %m", fd);
} else {
syslog(LOG_ERR,
- "t_close failed on %d: %s",
- fd, t_errlist[t_errno]);
+ "t_close failed on %d: %s",
+ fd, t_errlist[t_errno]);
}
}
return (-1);
@@ -374,12 +376,12 @@ do_one(char *provider, char *proto, struct protob *protobp0,
if (sock == -1) {
if ((Is_ipv6present() &&
- (strcmp(provider, "/dev/tcp6") == 0)) ||
- (!Is_ipv6present() && (strcmp(provider, "/dev/tcp") == 0)))
+ (strcmp(provider, "/dev/tcp6") == 0)) ||
+ (!Is_ipv6present() && (strcmp(provider, "/dev/tcp") == 0)))
(void) syslog(LOG_ERR,
"Cannot establish %s service over %s: transport "
- "setup problem.",
- protobp0->serv, provider ? provider : proto);
+ "setup problem.",
+ protobp0->serv, provider ? provider : proto);
return;
}
@@ -406,9 +408,9 @@ do_one(char *provider, char *proto, struct protob *protobp0,
* svc() doesn't block, it returns success or failure.
*/
if ((*svc)(sock, addrmask, retnconf) < 0) {
- (void) syslog(LOG_ERR,
-"Cannot establish %s service over <file desc. %d, protocol %s> : %m. Exiting",
- protobp0->serv, sock, retnconf->nc_proto);
+ (void) syslog(LOG_ERR, "Cannot establish %s service "
+ "over <file desc. %d, protocol %s> : %m. Exiting",
+ protobp0->serv, sock, retnconf->nc_proto);
exit(1);
}
}
@@ -438,8 +440,7 @@ do_all(struct protob *protobp,
if ((nconf->nc_flag & NC_VISIBLE) &&
strcmp(nconf->nc_protofmly, "loopback") != 0 &&
OK_TPI_TYPE(nconf))
- do_one(nconf->nc_device, nconf->nc_proto,
- protobp, svc);
+ do_one(nconf->nc_device, nconf->nc_proto, protobp, svc);
}
(void) endnetconfig(nc);
return (0);
@@ -742,7 +743,7 @@ poll_for_action(void)
*/
switch (errno) {
case EINTR:
- continue;
+ continue;
case EAGAIN:
case ENOMEM:
@@ -848,9 +849,9 @@ add_to_poll_list(int fd, struct netconfig *nconf)
*/
if (tpa) {
(void) memcpy((void *)poll_array, (void *)tpa,
- num_fds * sizeof (struct pollfd));
+ num_fds * sizeof (struct pollfd));
(void) memcpy((void *)conn_polled, (void *)tnp,
- num_fds * sizeof (struct conn_entry));
+ num_fds * sizeof (struct conn_entry));
free((void *)tpa);
free((void *)tnp);
}
@@ -1061,19 +1062,19 @@ cots_listen_event(int fd, int conn_index)
struct netbuf addrmask;
int ret = 0;
- conn_head = (struct conn_ind *)0;
+ conn_head = NULL;
(void) conn_get(fd, nconf, &conn_head);
while ((conn = conn_head) != NULL) {
conn_head = conn->conn_next;
if (conn_head == conn)
- conn_head = (struct conn_ind *)0;
+ conn_head = NULL;
else {
conn_head->conn_prev = conn->conn_prev;
conn->conn_prev->conn_next = conn_head;
}
call = conn->conn_call;
- free((char *)conn);
+ free(conn);
/*
* If we have already accepted the maximum number of
@@ -1100,8 +1101,7 @@ cots_listen_event(int fd, int conn_index)
}
/* Bind to a generic address/port for the accepting stream. */
- if (t_bind(new_fd, (struct t_bind *)NULL,
- (struct t_bind *)NULL) == -1) {
+ if (t_bind(new_fd, NULL, NULL) == -1) {
rdcd_log_tli_error("t_bind", new_fd, nconf);
call->udata.len = 0;
(void) t_snddis(fd, call);
@@ -1122,19 +1122,10 @@ cots_listen_event(int fd, int conn_index)
while (event = t_look(fd)) {
switch (event) {
case T_LISTEN:
-#ifdef DEBUG
- (void) printf(
-"cots_listen_event(%s): T_LISTEN during accept processing\n", nconf->nc_proto);
-#endif
(void) conn_get(fd, nconf, &conn_head);
continue;
case T_DISCONNECT:
-#ifdef DEBUG
- (void) printf(
- "cots_listen_event(%s): T_DISCONNECT during accept processing\n",
- nconf->nc_proto);
-#endif
(void) discon_get(fd, nconf,
&conn_head);
continue;
@@ -1156,16 +1147,19 @@ cots_listen_event(int fd, int conn_index)
if (set_addrmask(new_fd, nconf, &addrmask) < 0) {
(void) syslog(LOG_ERR, "Cannot set address mask for %s",
nconf->nc_netid);
- return;
+ (void) t_snddis(new_fd, NULL);
+ (void) t_free((char *)call, T_CALL);
+ (void) t_close(new_fd);
+ continue;
}
- /* Tell KRPC about the new stream. */
+ /* Tell kRPC about the new stream. */
ret = (*Mysvc)(new_fd, addrmask, nconf);
if (ret < 0) {
syslog(LOG_ERR,
"unable to register with kernel rpc: %m");
free(addrmask.buf);
- (void) t_snddis(new_fd, (struct t_call *)0);
+ (void) t_snddis(new_fd, NULL);
(void) t_free((char *)call, T_CALL);
(void) t_close(new_fd);
goto do_next_conn;
@@ -1201,18 +1195,10 @@ do_poll_cots_action(int fd, int conn_index)
while (event = t_look(fd)) {
switch (event) {
case T_LISTEN:
-#ifdef DEBUG
- (void) printf("do_poll_cots_action(%s, %d): T_LISTEN event\n",
- nconf->nc_proto, fd);
-#endif
cots_listen_event(fd, conn_index);
break;
case T_DATA:
-#ifdef DEBUG
- (void) printf("do_poll_cots_action(%d, %s): T_DATA event\n",
- fd, nconf->nc_proto);
-#endif
/*
* Receive a private notification from CONS rpcmod.
*/
@@ -1234,10 +1220,6 @@ do_poll_cots_action(int fd, int conn_index)
* hung connections from continuing to consume
* resources.
*/
-#ifdef DEBUG
-(void) printf("do_poll_cots_action(%s, %d): ", nconf->nc_proto, fd);
-(void) printf("initiating orderly release of idle connection\n");
-#endif
if (nconf->nc_semantics == NC_TPI_COTS ||
connent->closing != 0) {
(void) t_snddis(fd, (struct t_call *)0);
@@ -1261,10 +1243,6 @@ do_poll_cots_action(int fd, int conn_index)
break;
case T_ORDREL:
-#ifdef DEBUG
- (void) printf("do_poll_cots_action(%s, %d): T_ORDREL event\n",
- nconf->nc_proto, fd);
-#endif
/* Perform an orderly release. */
if (t_rcvrel(fd) == 0) {
/* T_ORDREL on listen fd's should be ignored */
@@ -1289,10 +1267,6 @@ do_poll_cots_action(int fd, int conn_index)
}
case T_DISCONNECT:
-#ifdef DEBUG
-(void) printf("do_poll_cots_action(%s, %d): T_DISCONNECT event\n",
-nconf->nc_proto, fd);
-#endif
if (t_rcvdis(fd, (struct t_discon *)NULL) == -1)
rdcd_log_tli_error("t_rcvdis", fd, nconf);
@@ -1307,11 +1281,11 @@ nconf->nc_proto, fd);
case T_ERROR:
default:
if (event == T_ERROR || t_errno == TSYSERR) {
- if ((errorstr = strerror(errno)) == NULL) {
- (void) snprintf(buf, sizeof (buf),
- "Unknown error num %d", errno);
- errorstr = (const char *)buf;
- }
+ if ((errorstr = strerror(errno)) == NULL) {
+ (void) snprintf(buf, sizeof (buf),
+ "Unknown error num %d", errno);
+ errorstr = (const char *)buf;
+ }
} else if (event == -1)
errorstr = t_strerror(t_errno);
else
@@ -1403,13 +1377,14 @@ do_poll_clts_action(int fd, int conn_index)
*/
error = errno;
(void) syslog(LOG_ERR,
- "t_alloc(file descriptor %d/transport %s, T_UNITDATA) failed: %m",
- fd, nconf->nc_proto);
+ "t_alloc(file descriptor %d/transport %s, "
+ "T_UNITDATA) failed: %m",
+ fd, nconf->nc_proto);
return (error);
}
- (void) syslog(LOG_ERR,
-"t_alloc(file descriptor %d/transport %s, T_UNITDATA) failed TLI error %d",
- fd, nconf->nc_proto, t_errno);
+ (void) syslog(LOG_ERR, "t_alloc(file descriptor %d/"
+ "transport %s, T_UNITDATA) failed TLI error %d",
+ fd, nconf->nc_proto, t_errno);
goto flush_it;
}
}
@@ -1433,9 +1408,9 @@ try_again:
ret = t_rcvudata(fd, unitdata, &flags);
if (ret == 0 || t_errno == TBUFOVFLW) {
- (void) syslog(LOG_WARNING,
-"t_rcvudata(file descriptor %d/transport %s) got unexpected data, %d bytes",
- fd, nconf->nc_proto, unitdata->udata.len);
+ (void) syslog(LOG_WARNING, "t_rcvudata(file descriptor %d/"
+ "transport %s) got unexpected data, %d bytes",
+ fd, nconf->nc_proto, unitdata->udata.len);
/*
* Even though we don't expect any data, in case we do,
@@ -1460,15 +1435,15 @@ try_again:
*/
error = errno;
(void) syslog(LOG_ERR,
- "t_rcvudata(file descriptor %d/transport %s) %m",
- fd, nconf->nc_proto);
+ "t_rcvudata(file descriptor %d/transport %s) %m",
+ fd, nconf->nc_proto);
return (error);
case TLOOK:
break;
default:
(void) syslog(LOG_ERR,
- "t_rcvudata(file descriptor %d/transport %s) TLI error %d",
- fd, nconf->nc_proto, t_errno);
+ "t_rcvudata(file descriptor %d/transport %s) TLI error %d",
+ fd, nconf->nc_proto, t_errno);
goto flush_it;
}
@@ -1489,20 +1464,20 @@ try_again:
*/
error = errno;
(void) syslog(LOG_ERR,
- "t_look(file descriptor %d/transport %s) %m",
- fd, nconf->nc_proto);
+ "t_look(file descriptor %d/transport %s) %m",
+ fd, nconf->nc_proto);
return (error);
}
(void) syslog(LOG_ERR,
- "t_look(file descriptor %d/transport %s) TLI error %d",
- fd, nconf->nc_proto, t_errno);
+ "t_look(file descriptor %d/transport %s) TLI error %d",
+ fd, nconf->nc_proto, t_errno);
goto flush_it;
case T_UDERR:
break;
default:
- (void) syslog(LOG_WARNING,
- "t_look(file descriptor %d/transport %s) returned %d not T_UDERR (%d)",
- fd, nconf->nc_proto, ret, T_UDERR);
+ (void) syslog(LOG_WARNING, "t_look(file descriptor %d/"
+ "transport %s) returned %d not T_UDERR (%d)",
+ fd, nconf->nc_proto, ret, T_UDERR);
}
if (uderr == NULL) {
@@ -1518,13 +1493,14 @@ try_again:
*/
error = errno;
(void) syslog(LOG_ERR,
- "t_alloc(file descriptor %d/transport %s, T_UDERROR) failed: %m",
- fd, nconf->nc_proto);
+ "t_alloc(file descriptor %d/transport %s, "
+ "T_UDERROR) failed: %m",
+ fd, nconf->nc_proto);
return (error);
}
- (void) syslog(LOG_ERR,
-"t_alloc(file descriptor %d/transport %s, T_UDERROR) failed TLI error: %d",
- fd, nconf->nc_proto, t_errno);
+ (void) syslog(LOG_ERR, "t_alloc(file descriptor %d/"
+ "transport %s, T_UDERROR) failed TLI error: %d",
+ fd, nconf->nc_proto, t_errno);
goto flush_it;
}
}
@@ -1602,13 +1578,13 @@ try_again:
*/
error = errno;
(void) syslog(LOG_ERR,
- "t_rcvuderr(file descriptor %d/transport %s) %m",
- fd, nconf->nc_proto);
+ "t_rcvuderr(file descriptor %d/transport %s) %m",
+ fd, nconf->nc_proto);
return (error);
default:
(void) syslog(LOG_ERR,
- "t_rcvuderr(file descriptor %d/transport %s) TLI error %d",
- fd, nconf->nc_proto, t_errno);
+ "t_rcvuderr(file descriptor %d/transport %s) TLI error %d",
+ fd, nconf->nc_proto, t_errno);
goto flush_it;
}
@@ -1620,8 +1596,8 @@ flush_it:
* nonblocking mode.
*/
(void) syslog(LOG_ERR,
- "Flushing one input message from <file descriptor %d/transport %s>",
- fd, nconf->nc_proto);
+ "Flushing one input message from <file descriptor %d/transport %s>",
+ fd, nconf->nc_proto);
/*
* Read and discard the message. Do this this until there is
@@ -1807,9 +1783,9 @@ rdcd_bindit(struct netconfig *nconf, struct netbuf **addr,
if (t_optmgmt(fd, &req, &resp) < 0 ||
resp.flags != T_SUCCESS) {
- syslog(LOG_ERR,
- "couldn't set NODELAY option for proto %s: t_errno = %d, %m",
- nconf->nc_proto, t_errno);
+ syslog(LOG_ERR, "couldn't set NODELAY option for "
+ "proto %s: t_errno = %d, %m", nconf->nc_proto,
+ t_errno);
}
}
@@ -1883,8 +1859,7 @@ set_addrmask(int fd, struct netconfig *nconf, struct netbuf *mask)
}
mask->len = mask->maxlen = info.addr;
if (info.addr <= 0) {
- syslog(LOG_ERR, "set_addrmask: address size: %ld",
- info.addr);
+ syslog(LOG_ERR, "set_addrmask: address size: %ld", info.addr);
return (-1);
}
diff --git a/usr/src/cmd/fs.d/nfs/lib/nfs_tbind.c b/usr/src/cmd/fs.d/nfs/lib/nfs_tbind.c
index d14bb0329c..8a7d4d6cd3 100644
--- a/usr/src/cmd/fs.d/nfs/lib/nfs_tbind.c
+++ b/usr/src/cmd/fs.d/nfs/lib/nfs_tbind.c
@@ -21,8 +21,8 @@
/*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
@@ -1313,19 +1313,19 @@ cots_listen_event(int fd, int conn_index)
char *clnt_uaddr = NULL;
struct nd_hostservlist *clnt_serv = NULL;
- conn_head = (struct conn_ind *)0;
+ conn_head = NULL;
(void) conn_get(fd, nconf, &conn_head);
while ((conn = conn_head) != NULL) {
conn_head = conn->conn_next;
if (conn_head == conn)
- conn_head = (struct conn_ind *)0;
+ conn_head = NULL;
else {
conn_head->conn_prev = conn->conn_prev;
conn->conn_prev->conn_next = conn_head;
}
call = conn->conn_call;
- free((char *)conn);
+ free(conn);
/*
* If we have already accepted the maximum number of
@@ -1352,8 +1352,7 @@ cots_listen_event(int fd, int conn_index)
}
/* Bind to a generic address/port for the accepting stream. */
- if (t_bind(new_fd, (struct t_bind *)NULL,
- (struct t_bind *)NULL) == -1) {
+ if (t_bind(new_fd, NULL, NULL) == -1) {
nfslib_log_tli_error("t_bind", new_fd, nconf);
call->udata.len = 0;
(void) t_snddis(fd, call);
@@ -1408,10 +1407,13 @@ cots_listen_event(int fd, int conn_index)
(void) syslog(LOG_ERR,
"Cannot set address mask for %s",
nconf->nc_netid);
- return;
+ (void) t_snddis(new_fd, NULL);
+ (void) t_free((char *)call, T_CALL);
+ (void) t_close(new_fd);
+ continue;
}
- /* Tell KRPC about the new stream. */
+ /* Tell kRPC about the new stream. */
if (Mysvc4 != NULL)
ret = (*Mysvc4)(new_fd, &addrmask, nconf,
NFS4_KRPC_START, &call->addr);
@@ -1441,13 +1443,17 @@ cots_listen_event(int fd, int conn_index)
if (clnt)
syslog(LOG_ERR,
"unable to register new connection: client %s has dropped connection", clnt);
- if (clnt_serv)
+ if (clnt_serv) {
netdir_free(clnt_serv, ND_HOSTSERVLIST);
- if (clnt_uaddr)
+ clnt_serv = NULL;
+ }
+ if (clnt_uaddr) {
free(clnt_uaddr);
+ clnt_uaddr = NULL;
+ }
}
free(addrmask.buf);
- (void) t_snddis(new_fd, (struct t_call *)0);
+ (void) t_snddis(new_fd, NULL);
(void) t_free((char *)call, T_CALL);
(void) t_close(new_fd);
goto do_next_conn;
diff --git a/usr/src/lib/README.mapfiles b/usr/src/lib/README.mapfiles
index 560226938e..69285b296e 100644
--- a/usr/src/lib/README.mapfiles
+++ b/usr/src/lib/README.mapfiles
@@ -194,7 +194,7 @@ feature of the C preprocessor. For instance, the following mapfile declares
a version SUNW_1.1 that always exports a symbol foo, and also exports
the symbol bar on 32-bit sparc platforms:
-$mapfile_version
+$mapfile_version 2
SYMBOL_VERSION SUNW_1.1 {
foo;
$if _sparc && _ELF32
diff --git a/usr/src/lib/libnsl/common/llib-lnsl b/usr/src/lib/libnsl/common/llib-lnsl
index 106dab70d6..582eecef95 100644
--- a/usr/src/lib/libnsl/common/llib-lnsl
+++ b/usr/src/lib/libnsl/common/llib-lnsl
@@ -23,7 +23,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -836,9 +836,6 @@ int rpc_reg(rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum,
/* svc_vc.c */
SVCXPRT *svc_vc_create(int fd, uint_t sendsize, uint_t recvsize);
SVCXPRT *svc_fd_create(int fd, uint_t sendsize, uint_t recvsize);
-void __svc_nisplus_fdcleanup_hack(void);
-void __svc_nisplus_enable_timestamps(void);
-void __svc_nisplus_purge_since(long since);
bool_t __svc_vc_dupcache_init(SVCXPRT *xprt, void *condition, int basis);
int __svc_vc_dup(struct svc_req *req, caddr_t *resp_buf, uint_t *resp_bufsz);
int __svc_vc_dupdone(struct svc_req *req, caddr_t resp_buf, uint_t resp_bufsz,
diff --git a/usr/src/lib/libnsl/common/mapfile-vers b/usr/src/lib/libnsl/common/mapfile-vers
index f875cd99fc..c8fa67b625 100644
--- a/usr/src/lib/libnsl/common/mapfile-vers
+++ b/usr/src/lib/libnsl/common/mapfile-vers
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2014 Nexenta Systems, Inc. All rights reserved.
#
#
@@ -467,8 +467,8 @@ $endif
SYMBOL_VERSION SUNWprivate_1.5 {
global:
- inet_matchaddr;
clnt_create_service_timed;
+ inet_matchaddr;
} SUNWprivate_1.4;
SYMBOL_VERSION SUNWprivate_1.4 {
@@ -663,9 +663,6 @@ SYMBOL_VERSION SUNWprivate_1.1 {
svc_get_local_cred;
_svc_getreqset_proc;
__svc_get_svcauth;
- __svc_nisplus_enable_timestamps;
- __svc_nisplus_fdcleanup_hack;
- __svc_nisplus_purge_since;
__svc_set_proc_cleanup_cb;
__svc_vc_dup;
__svc_vc_dupcache_init;
diff --git a/usr/src/lib/libnsl/rpc/clnt_vc.c b/usr/src/lib/libnsl/rpc/clnt_vc.c
index 671adaada6..0c0fb01037 100644
--- a/usr/src/lib/libnsl/rpc/clnt_vc.c
+++ b/usr/src/lib/libnsl/rpc/clnt_vc.c
@@ -240,7 +240,9 @@ _clnt_vc_create_timed(int fd, struct netbuf *svcaddr, rpcprog_t prog,
int flag;
cl = malloc(sizeof (*cl));
- ct = malloc(sizeof (*ct));
+ if ((ct = malloc(sizeof (*ct))) != NULL)
+ ct->ct_addr.buf = NULL;
+
if ((cl == NULL) || (ct == NULL)) {
(void) syslog(LOG_ERR, clnt_vc_errstr,
clnt_vc_str, __no_mem_str);
@@ -249,7 +251,6 @@ _clnt_vc_create_timed(int fd, struct netbuf *svcaddr, rpcprog_t prog,
rpc_createerr.cf_error.re_terrno = 0;
goto err;
}
- ct->ct_addr.buf = NULL;
/*
* The only use of vctbl_lock is for serializing the creation of
@@ -366,14 +367,12 @@ _clnt_vc_create_timed(int fd, struct netbuf *svcaddr, rpcprog_t prog,
return (cl);
err:
- if (cl) {
- if (ct) {
- if (ct->ct_addr.len)
- free(ct->ct_addr.buf);
- free(ct);
- }
- free(cl);
+ if (ct) {
+ free(ct->ct_addr.buf);
+ free(ct);
}
+ free(cl);
+
return (NULL);
}
diff --git a/usr/src/lib/libnsl/rpc/getdname.c b/usr/src/lib/libnsl/rpc/getdname.c
index 34d2ea22b4..a471117bea 100644
--- a/usr/src/lib/libnsl/rpc/getdname.c
+++ b/usr/src/lib/libnsl/rpc/getdname.c
@@ -24,6 +24,9 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -33,120 +36,28 @@
* California.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Gets and sets the domain name of the system
*/
-#include "mt.h"
-#include "rpc_mt.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
#include <sys/systeminfo.h>
-#include <sys/time.h>
-#include <syslog.h>
-
-#ifndef SI_SRPC_DOMAIN
-#define use_file
-#endif
-
-#ifdef use_file
-char DOMAIN[] = "/etc/domain";
-#endif
-
-int setdomainname();
-
-#ifdef use_file
-static char *domainname;
-#endif
-
-extern mutex_t dname_lock;
int
-getdomainname(name, namelen)
- char *name;
- int namelen;
+getdomainname(char *name, int namelen)
{
-#ifdef use_file
- FILE *domain_fd;
- char *line;
-
- (void) mutex_lock(&dname_lock);
- if (domainname) {
- (void) strncpy(name, domainname, namelen);
- (void) mutex_unlock(&dname_lock);
- return (0);
- }
-
- domainname = calloc(1, 256);
- if (domainname == NULL) {
- syslog(LOG_ERR, "getdomainname : out of memory.");
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
-
- if ((domain_fd = fopen(DOMAIN, "r")) == NULL) {
-
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
- if (fscanf(domain_fd, "%s", domainname) == NULL) {
- (void) fclose(domain_fd);
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
- (void) fclose(domain_fd);
- (void) strncpy(name, domainname, namelen);
- (void) mutex_unlock(&dname_lock);
- return (0);
-#else
int sysinfostatus;
sysinfostatus = sysinfo(SI_SRPC_DOMAIN, name, namelen);
return ((sysinfostatus < 0) ? -1 : 0);
-#endif
}
int
-setdomainname(domain, len)
- char *domain;
- int len;
+setdomainname(char *domain, int len)
{
-#ifdef use_file
-
- FILE *domain_fd;
-
- (void) mutex_lock(&dname_lock);
- if (domainname)
- free(domainname);
-
- if ((domain_fd = fopen(DOMAIN, "w")) == NULL) {
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
- if (fputs(domain, domain_fd) == NULL) {
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
- (void) fclose(domain_fd);
- domainname = calloc(1, 256);
- if (domainname == NULL) {
- syslog(LOG_ERR, "setdomainname : out of memory.");
- (void) mutex_unlock(&dname_lock);
- return (-1);
- }
- (void) strncpy(domainname, domain, len);
- (void) mutex_unlock(&dname_lock);
- return (0);
-#else
int sysinfostatus;
sysinfostatus = sysinfo(SI_SET_SRPC_DOMAIN,
- domain, len + 1); /* add null */
+ domain, len + 1); /* add null */
return ((sysinfostatus < 0) ? -1 : 0);
-#endif
}
diff --git a/usr/src/lib/libnsl/rpc/svc_door.c b/usr/src/lib/libnsl/rpc/svc_door.c
index 480e28b4c3..e0c7bf96f2 100644
--- a/usr/src/lib/libnsl/rpc/svc_door.c
+++ b/usr/src/lib/libnsl/rpc/svc_door.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
/*
* svc_door.c, Server side for doors IPC based RPC.
@@ -171,7 +174,7 @@ make_tmp_dir(void)
return (FALSE);
}
return ((statbuf.st_mode & S_IFMT) == S_IFDIR &&
- (statbuf.st_mode & 01777) == 01777);
+ (statbuf.st_mode & 01777) == 01777);
}
static void
@@ -198,7 +201,7 @@ svc_door_dispatch(SVCXPRT *xprt, struct rpc_msg *msg, struct svc_req *r)
}
if (su->call_info.prognum == r->rq_prog && su->call_info.versnum ==
- r->rq_vers) {
+ r->rq_vers) {
(*su->call_info.dispatch)(r, xprt);
return;
}
@@ -209,7 +212,7 @@ svc_door_dispatch(SVCXPRT *xprt, struct rpc_msg *msg, struct svc_req *r)
*/
if (su->call_info.prognum == r->rq_prog)
svcerr_progvers(xprt, su->call_info.versnum,
- su->call_info.versnum);
+ su->call_info.versnum);
else
svcerr_noprog(xprt);
}
@@ -245,7 +248,7 @@ door_server(void *cookie, char *argp, size_t arg_size,
(void) mutex_lock(&svc_door_mutex);
if ((xprt = get_xprt_copy(parent, result_buf)) == NULL) {
(void) syslog(LOG_ERR,
- "door_server: memory allocation failure");
+ "door_server: memory allocation failure");
(void) mutex_unlock(&svc_door_mutex);
(void) door_return(NULL, 0, NULL, 0);
/*NOTREACHED*/
@@ -322,7 +325,7 @@ svc_door_create(void (*dispatch)(), const rpcprog_t prognum,
if (!make_tmp_dir()) {
(void) syslog(LOG_ERR, "svc_door_create: cannot open %s",
- RPC_DOOR_DIR);
+ RPC_DOOR_DIR);
(void) mutex_unlock(&svc_door_mutex);
return (NULL);
}
@@ -335,7 +338,7 @@ svc_door_create(void (*dispatch)(), const rpcprog_t prognum,
svc_flags(xprt) |= SVC_DOOR;
(void) sprintf(rendezvous, RPC_DOOR_RENDEZVOUS, (int)prognum,
- (int)versnum);
+ (int)versnum);
mask = umask(0);
fd = open(rendezvous, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0644);
(void) umask(mask);
@@ -343,24 +346,24 @@ svc_door_create(void (*dispatch)(), const rpcprog_t prognum,
if (errno == EEXIST) {
if (unlink(rendezvous) < 0) {
(void) syslog(LOG_ERR,
- "svc_door_create: %s %s:%m", rendezvous,
- "exists and could not be removed");
+ "svc_door_create: %s %s:%m", rendezvous,
+ "exists and could not be removed");
goto freedata;
}
mask = umask(0);
- fd = open(rendezvous, O_WRONLY|O_CREAT|O_EXCL|
- O_TRUNC, 0644);
+ fd = open(rendezvous, O_WRONLY | O_CREAT | O_EXCL |
+ O_TRUNC, 0644);
(void) umask(mask);
if (fd < 0) {
(void) syslog(LOG_ERR,
- "svc_door_create: %s %s:%m",
- "could not create", rendezvous);
+ "svc_door_create: %s %s:%m",
+ "could not create", rendezvous);
goto freedata;
}
} else {
(void) syslog(LOG_ERR,
- "svc_door_create: could not create %s:%m",
- rendezvous);
+ "svc_door_create: could not create %s:%m",
+ rendezvous);
goto freedata;
}
}
@@ -368,15 +371,15 @@ svc_door_create(void (*dispatch)(), const rpcprog_t prognum,
did = door_create(door_server, (void *)xprt, DOOR_REFUSE_DESC);
if (did < 0) {
(void) syslog(LOG_ERR,
- "svc_door_create: door_create failed: %m");
+ "svc_door_create: door_create failed: %m");
goto freedata;
}
if (fattach(did, rendezvous) < 0) {
if (errno != EBUSY || fdetach(rendezvous) < 0 ||
- fattach(did, rendezvous) < 0) {
+ fattach(did, rendezvous) < 0) {
(void) syslog(LOG_ERR,
- "svc_door_create: fattach failed: %m");
+ "svc_door_create: fattach failed: %m");
goto freedata;
}
}
@@ -554,7 +557,7 @@ return_xprt_copy(SVCXPRT *xprt)
svc_flags(parent) |= SVC_DEFUNCT;
/* LINTED pointer cast */
if (SVCEXT(parent)->refcnt == 0)
- svc_door_destroy(xprt);
+ svc_door_destroy_pvt(xprt);
}
(void) mutex_unlock(&svc_door_mutex);
return (len);
diff --git a/usr/src/lib/libnsl/rpc/svc_vc.c b/usr/src/lib/libnsl/rpc/svc_vc.c
index e98c2b2028..bd001a43b8 100644
--- a/usr/src/lib/libnsl/rpc/svc_vc.c
+++ b/usr/src/lib/libnsl/rpc/svc_vc.c
@@ -77,7 +77,6 @@ extern SVCXPRT **svc_xports;
extern int __td_setnodelay(int);
extern bool_t __xdrrec_getbytes_nonblock(XDR *, enum xprt_stat *);
extern bool_t __xdrrec_set_conn_nonblock(XDR *, uint32_t);
-extern int _t_do_ioctl(int, char *, int, int, int *);
extern int __rpc_legal_connmaxrec(int);
/* Structure used to initialize SVC_XP_AUTH(xprt).svc_ah_ops. */
extern struct svc_auth_ops svc_auth_any_ops;
@@ -90,7 +89,6 @@ static bool_t svc_vc_nonblock(SVCXPRT *, SVCXPRT *);
static int read_vc(SVCXPRT *, caddr_t, int);
static int write_vc(SVCXPRT *, caddr_t, int);
static SVCXPRT *makefd_xprt(int, uint_t, uint_t, t_scalar_t, char *);
-static bool_t fd_is_dead(int);
static void update_nonblock_timestamps(SVCXPRT *);
struct cf_rendezvous { /* kept in xprt->xp_p1 for rendezvouser */
@@ -126,9 +124,6 @@ extern int __xdrrec_setfirst(XDR *);
extern int __xdrrec_resetfirst(XDR *);
extern int __is_xdrrec_first(XDR *);
-void __svc_nisplus_enable_timestamps(void);
-void __svc_timeout_nonblock_xprt(void);
-
/*
* This is intended as a performance improvement on the old string handling
* stuff by read only moving data into the text segment.
@@ -155,14 +150,6 @@ static const char no_fcntl_getfl_str[] = "could not get status flags and modes";
static const char no_nonblock_str[] = "could not set transport non-blocking";
/*
- * Records a timestamp when data comes in on a descriptor. This is
- * only used if timestamps are enabled with __svc_nisplus_enable_timestamps().
- */
-static long *timestamps;
-static int ntimestamps; /* keep track how many timestamps */
-static mutex_t timestamp_lock = DEFAULTMUTEX;
-
-/*
* Used to determine whether the time-out logic should be executed.
*/
static bool_t check_nonblock_timestamps = FALSE;
@@ -1192,12 +1179,6 @@ _svc_vc_destroy_private(SVCXPRT *xprt, bool_t lock_not_held)
__xprt_unregister_private(xprt, lock_not_held);
(void) t_close(xprt->xp_fd);
- (void) mutex_lock(&timestamp_lock);
- if (timestamps && xprt->xp_fd < ntimestamps) {
- timestamps[xprt->xp_fd] = 0;
- }
- (void) mutex_unlock(&timestamp_lock);
-
if (svc_mt_mode != RPC_SVC_MT_NONE) {
svc_xprt_destroy(xprt);
} else {
@@ -1285,43 +1266,11 @@ rendezvous_control(SVCXPRT *xprt, const uint_t rq, void *in)
/*
* All read operations timeout after 35 seconds.
* A timeout is fatal for the connection.
- * update_timestamps() is used by nisplus operations,
* update_nonblock_timestamps() is used for nonblocked
* connection fds.
*/
#define WAIT_PER_TRY 35000 /* milliseconds */
-static void
-update_timestamps(int fd)
-{
- (void) mutex_lock(&timestamp_lock);
- if (timestamps) {
- struct timeval tv;
-
- (void) gettimeofday(&tv, NULL);
- while (fd >= ntimestamps) {
- long *tmp_timestamps = timestamps;
-
- /* allocate more timestamps */
- tmp_timestamps = realloc(timestamps, sizeof (long) *
- (ntimestamps + FD_INCREMENT));
- if (tmp_timestamps == NULL) {
- (void) mutex_unlock(&timestamp_lock);
- syslog(LOG_ERR,
- "update_timestamps: out of memory");
- return;
- }
-
- timestamps = tmp_timestamps;
- (void) memset(&timestamps[ntimestamps], 0,
- sizeof (long) * FD_INCREMENT);
- ntimestamps += FD_INCREMENT;
- }
- timestamps[fd] = tv.tv_sec;
- }
- (void) mutex_unlock(&timestamp_lock);
-}
-
static void
update_nonblock_timestamps(SVCXPRT *xprt_conn)
{
@@ -1371,7 +1320,6 @@ read_vc(SVCXPRT *xprt, caddr_t buf, int len)
*/
if ((len = t_rcvnonblock(xprt, buf, len)) >= 0) {
if (len > 0) {
- update_timestamps(fd);
update_nonblock_timestamps(xprt);
}
return (len);
@@ -1401,7 +1349,6 @@ read_vc(SVCXPRT *xprt, caddr_t buf, int len)
}
(void) __xdrrec_resetfirst(xdrs);
if ((len = t_rcvall(fd, buf, len)) > 0) {
- update_timestamps(fd);
return (len);
}
@@ -1865,142 +1812,6 @@ svc_vc_rendezvous_ops(void)
}
/*
- * PRIVATE RPC INTERFACE
- *
- * This is a hack to let NIS+ clean up connections that have already been
- * closed. This problem arises because rpc.nisd forks a child to handle
- * existing connections when it does checkpointing. The child may close
- * some of these connections. But the descriptors still stay open in the
- * parent, and because TLI descriptors don't support persistent EOF
- * condition (like sockets do), the parent will never detect that these
- * descriptors are dead.
- *
- * The following internal procedure __svc_nisplus_fdcleanup_hack() - should
- * be removed as soon as rpc.nisd is rearchitected to do the right thing.
- * This procedure should not find its way into any header files.
- *
- * This procedure should be called only when rpc.nisd knows that there
- * are no children servicing clients.
- */
-
-static bool_t
-fd_is_dead(int fd)
-{
- struct T_info_ack inforeq;
- int retval;
-
- inforeq.PRIM_type = T_INFO_REQ;
- if (!_t_do_ioctl(fd, (caddr_t)&inforeq, sizeof (struct T_info_req),
- TI_GETINFO, &retval))
- return (TRUE);
- if (retval != (int)sizeof (struct T_info_ack))
- return (TRUE);
-
- switch (inforeq.CURRENT_state) {
- case TS_UNBND:
- case TS_IDLE:
- return (TRUE);
- default:
- break;
- }
- return (FALSE);
-}
-
-void
-__svc_nisplus_fdcleanup_hack(void)
-{
- SVCXPRT *xprt;
- SVCXPRT *dead_xprt[CLEANUP_SIZE];
- int i, fd_idx = 0, dead_idx = 0;
-
- if (svc_xports == NULL)
- return;
- for (;;) {
- (void) rw_wrlock(&svc_fd_lock);
- for (dead_idx = 0; fd_idx < svc_max_pollfd; fd_idx++) {
- if ((xprt = svc_xports[fd_idx]) == NULL)
- continue;
-/* LINTED pointer alignment */
- if (svc_type(xprt) != SVC_CONNECTION)
- continue;
- if (fd_is_dead(fd_idx)) {
- dead_xprt[dead_idx++] = xprt;
- if (dead_idx >= CLEANUP_SIZE)
- break;
- }
- }
-
- for (i = 0; i < dead_idx; i++) {
- /* Still holding svc_fd_lock */
- _svc_vc_destroy_private(dead_xprt[i], FALSE);
- }
- (void) rw_unlock(&svc_fd_lock);
- if (fd_idx++ >= svc_max_pollfd)
- return;
- }
-}
-
-void
-__svc_nisplus_enable_timestamps(void)
-{
- (void) mutex_lock(&timestamp_lock);
- if (!timestamps) {
- timestamps = calloc(FD_INCREMENT, sizeof (long));
- if (timestamps != NULL)
- ntimestamps = FD_INCREMENT;
- else {
- (void) mutex_unlock(&timestamp_lock);
- syslog(LOG_ERR, "__svc_nisplus_enable_timestamps: "
- "out of memory");
- return;
- }
- }
- (void) mutex_unlock(&timestamp_lock);
-}
-
-void
-__svc_nisplus_purge_since(long since)
-{
- SVCXPRT *xprt;
- SVCXPRT *dead_xprt[CLEANUP_SIZE];
- int i, fd_idx = 0, dead_idx = 0;
-
- if (svc_xports == NULL)
- return;
- for (;;) {
- (void) rw_wrlock(&svc_fd_lock);
- (void) mutex_lock(&timestamp_lock);
- for (dead_idx = 0; fd_idx < svc_max_pollfd; fd_idx++) {
- if ((xprt = svc_xports[fd_idx]) == NULL) {
- continue;
- }
- /* LINTED pointer cast */
- if (svc_type(xprt) != SVC_CONNECTION) {
- continue;
- }
- if (fd_idx >= ntimestamps) {
- break;
- }
- if (timestamps[fd_idx] &&
- timestamps[fd_idx] < since) {
- dead_xprt[dead_idx++] = xprt;
- if (dead_idx >= CLEANUP_SIZE)
- break;
- }
- }
- (void) mutex_unlock(&timestamp_lock);
-
- for (i = 0; i < dead_idx; i++) {
- /* Still holding svc_fd_lock */
- _svc_vc_destroy_private(dead_xprt[i], FALSE);
- }
- (void) rw_unlock(&svc_fd_lock);
- if (fd_idx++ >= svc_max_pollfd)
- return;
- }
-}
-
-/*
* dup cache wrapper functions for vc requests. The set of dup
* functions were written with the view that they may be expanded
* during creation of a generic svc_vc_enablecache routine