diff options
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/README.mapfiles | 2 | ||||
-rw-r--r-- | usr/src/lib/libnsl/common/llib-lnsl | 5 | ||||
-rw-r--r-- | usr/src/lib/libnsl/common/mapfile-vers | 7 | ||||
-rw-r--r-- | usr/src/lib/libnsl/rpc/clnt_vc.c | 17 | ||||
-rw-r--r-- | usr/src/lib/libnsl/rpc/getdname.c | 101 | ||||
-rw-r--r-- | usr/src/lib/libnsl/rpc/svc_door.c | 39 | ||||
-rw-r--r-- | usr/src/lib/libnsl/rpc/svc_vc.c | 189 |
7 files changed, 39 insertions, 321 deletions
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(×tamp_lock); - if (timestamps && xprt->xp_fd < ntimestamps) { - timestamps[xprt->xp_fd] = 0; - } - (void) mutex_unlock(×tamp_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(×tamp_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(×tamp_lock); - syslog(LOG_ERR, - "update_timestamps: out of memory"); - return; - } - - timestamps = tmp_timestamps; - (void) memset(×tamps[ntimestamps], 0, - sizeof (long) * FD_INCREMENT); - ntimestamps += FD_INCREMENT; - } - timestamps[fd] = tv.tv_sec; - } - (void) mutex_unlock(×tamp_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(×tamp_lock); - if (!timestamps) { - timestamps = calloc(FD_INCREMENT, sizeof (long)); - if (timestamps != NULL) - ntimestamps = FD_INCREMENT; - else { - (void) mutex_unlock(×tamp_lock); - syslog(LOG_ERR, "__svc_nisplus_enable_timestamps: " - "out of memory"); - return; - } - } - (void) mutex_unlock(×tamp_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(×tamp_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(×tamp_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 |