summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-02-12 19:53:35 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-02-12 19:53:35 +0000
commit7e6f010d4395486de8255938900c8fcafd6e30e8 (patch)
treedb0db5060236edb51c6e19ba03dbc0b5d20d4ca0
parent2de98f4292c55e65683fd4a5cfcfdac5bc98403a (diff)
parent3ed73a35f260311604b6a106c2de1e8488499ff8 (diff)
downloadillumos-joyent-7e6f010d4395486de8255938900c8fcafd6e30e8.tar.gz
[illumos-gate merge]
commit 3ed73a35f260311604b6a106c2de1e8488499ff8 4554 memory leak in ndmpd_config_get_fs_info_v3 commit 42cdb25977ffa6ebef76064b66ad665992fadee5 4484 lockd: SMF property reading and cli options are incorrect
-rw-r--r--usr/src/cmd/fs.d/nfs/lockd/lockd.c63
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_config.c50
2 files changed, 42 insertions, 71 deletions
diff --git a/usr/src/cmd/fs.d/nfs/lockd/lockd.c b/usr/src/cmd/fs.d/nfs/lockd/lockd.c
index 2fa73e73e3..2aca35fa0f 100644
--- a/usr/src/cmd/fs.d/nfs/lockd/lockd.c
+++ b/usr/src/cmd/fs.d/nfs/lockd/lockd.c
@@ -21,8 +21,8 @@
/*
* Copyright (c) 1989, 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.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -90,8 +90,8 @@ struct lm_svc_args lmargs = {
/* fd, n_fmly, n_proto, n_rdev (below) */
.debug = 0,
.timout = 5 * 60,
- .grace = 60,
- .retransmittimeout = 15
+ .grace = 90,
+ .retransmittimeout = 5
};
int max_servers = 20;
@@ -172,20 +172,6 @@ main(int ac, char *av[])
* command line options so the options override SMF values.
*/
- /* How long to keep idle connections. */
- propname = "conn_idle_timeout"; /* also -t */
- ret = nfs_smf_get_iprop(propname, &val,
- DEFAULT_INSTANCE, SCF_TYPE_INTEGER, LOCKD);
- if (ret == SA_OK) {
- if (val <= 0)
- fprintf(stderr, gettext(
- "Invalid %s from SMF"), propname);
- else
- lmargs.timout = val;
- }
-
- /* Note: debug_level can only be set by args. */
-
/* How long to wait for clients to re-establish locks. */
propname = "grace_period"; /* also -g */
ret = nfs_smf_get_iprop(propname, &val,
@@ -196,9 +182,12 @@ main(int ac, char *av[])
"Invalid %s from SMF"), propname);
else
lmargs.grace = val;
+ } else {
+ syslog(LOG_ERR, "Reading of %s from SMF failed, using default "
+ "value", propname);
}
- propname = "listen_backlog"; /* also -l */
+ propname = "lockd_listen_backlog"; /* also -l */
ret = nfs_smf_get_iprop(propname, &val,
DEFAULT_INSTANCE, SCF_TYPE_INTEGER, LOCKD);
if (ret == SA_OK) {
@@ -207,20 +196,12 @@ main(int ac, char *av[])
"Invalid %s from SMF"), propname);
else
listen_backlog = val;
+ } else {
+ syslog(LOG_ERR, "Reading of %s from SMF failed, using default "
+ "value", propname);
}
- propname = "max_connections"; /* also -c */
- ret = nfs_smf_get_iprop(propname, &val,
- DEFAULT_INSTANCE, SCF_TYPE_INTEGER, LOCKD);
- if (ret == SA_OK) {
- if (val <= 0)
- fprintf(stderr, gettext(
- "Invalid %s from SMF"), propname);
- else
- max_conns_allowed = val;
- }
-
- propname = "max_servers"; /* also argv[1] */
+ propname = "lockd_servers"; /* also argv[1] */
ret = nfs_smf_get_iprop(propname, &val,
DEFAULT_INSTANCE, SCF_TYPE_INTEGER, LOCKD);
if (ret == SA_OK) {
@@ -229,9 +210,12 @@ main(int ac, char *av[])
"Invalid %s from SMF"), propname);
else
max_servers = val;
+ } else {
+ syslog(LOG_ERR, "Reading of %s from SMF failed, using default "
+ "value", propname);
}
- propname = "retrans_timeout"; /* also -r */
+ propname = "lockd_retransmit_timeout"; /* also -t */
ret = nfs_smf_get_iprop(propname, &val,
DEFAULT_INSTANCE, SCF_TYPE_INTEGER, LOCKD);
if (ret == SA_OK) {
@@ -240,10 +224,12 @@ main(int ac, char *av[])
"Invalid %s from SMF"), propname);
else
lmargs.retransmittimeout = val;
+ } else {
+ syslog(LOG_ERR, "Reading of %s from SMF failed, using default "
+ "value", propname);
}
-
- while ((c = getopt(ac, av, "c:d:g:l:r:t:")) != EOF)
+ while ((c = getopt(ac, av, "c:d:g:l:t:")) != EOF)
switch (c) {
case 'c': /* max_connections */
if ((val = atoi(optarg)) <= 0)
@@ -267,18 +253,12 @@ main(int ac, char *av[])
listen_backlog = val;
break;
- case 'r': /* retrans_timeout */
+ case 't': /* retrans_timeout */
if ((val = atoi(optarg)) <= 0)
goto badval;
lmargs.retransmittimeout = val;
break;
- case 't': /* conn_idle_timeout */
- if ((val = atoi(optarg)) <= 0)
- goto badval;
- lmargs.timout = val;
- break;
-
badval:
fprintf(stderr, gettext(
"Invalid -%c option value"), c);
@@ -543,8 +523,7 @@ usage(void)
(void) fprintf(stderr, "\t-d debug_level\n");
(void) fprintf(stderr, "\t-g grace_period\n");
(void) fprintf(stderr, "\t-l listen_backlog\n");
- (void) fprintf(stderr, "\t-r retrans_timeout\n");
- (void) fprintf(stderr, "\t-t conn_idle_timeout\n");
+ (void) fprintf(stderr, "\t-t retransmit_timeout\n");
exit(1);
}
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
index e108f2243a..a411a5d7c5 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
@@ -37,6 +37,7 @@
*/
/* Copyright (c) 2007, The Storage Networking Industry Association. */
/* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
+/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */
#include <dirent.h>
#include <errno.h>
@@ -530,8 +531,8 @@ void
ndmpd_config_get_fs_info_v3(ndmp_connection_t *connection, void *body)
{
ndmp_config_get_fs_info_reply_v3 reply;
- ndmp_fs_info_v3 *fsip, *fsip_save; /* FS info pointer */
- int i, nmnt, fd;
+ ndmp_fs_info_v3 *fsip = NULL, *fsip_save = NULL; /* FS info pointer */
+ int len = 0, nmnt, fd;
int log_dev_len;
FILE *fp = NULL;
struct mnttab mt, *fs;
@@ -544,45 +545,36 @@ ndmpd_config_get_fs_info_v3(ndmp_connection_t *connection, void *body)
if ((fd = open(MNTTAB, O_RDONLY)) == -1) {
NDMP_LOG(LOG_ERR, "File mnttab open error: %m.");
reply.error = NDMP_UNDEFINED_ERR;
- ndmp_send_reply(connection, (void *)&reply,
- "sending ndmp_config_get_fs_info reply");
- return;
+ goto send_reply;
}
/* nothing was found, send an empty reply */
if (ioctl(fd, MNTIOC_NMNTS, &nmnt) != 0 || nmnt <= 0) {
- NDMP_LOG(LOG_ERR, "No file system found.");
- ndmp_send_reply(connection, (void *)&reply,
- "sending ndmp_config_get_fs_info reply");
(void) close(fd);
- return;
+ NDMP_LOG(LOG_ERR, "No file system found.");
+ goto send_reply;
}
- (void) close(fd);
- fp = fopen(MNTTAB, "r");
+ fp = fdopen(fd, "r");
if (!fp) {
+ (void) close(fd);
NDMP_LOG(LOG_ERR, "File mnttab open error: %m.");
reply.error = NDMP_UNDEFINED_ERR;
- ndmp_send_reply(connection, (void *)&reply,
- "sending ndmp_config_get_fs_info reply");
- return;
+ goto send_reply;
}
fsip_save = fsip = ndmp_malloc(sizeof (ndmp_fs_info_v3) * nmnt);
if (!fsip) {
(void) fclose(fp);
reply.error = NDMP_NO_MEM_ERR;
- ndmp_send_reply(connection, (void *)&reply,
- "error sending ndmp_config_get_fs_info reply");
- return;
+ goto send_reply;
}
/*
* Re-read the directory and set up file system information.
*/
- i = 0;
rewind(fp);
- while (i < nmnt && (getmntent(fp, &mt) == 0))
+ while (len < nmnt && (getmntent(fp, &mt) == 0))
{
fs = &mt;
@@ -593,9 +585,9 @@ ndmpd_config_get_fs_info_v3(ndmp_connection_t *connection, void *body)
fsip->fs_logical_device = ndmp_malloc(log_dev_len);
fsip->fs_type = ndmp_malloc(MNTTYPE_LEN);
if (!fsip->fs_logical_device || !fsip->fs_type) {
- reply.error = NDMP_NO_MEM_ERR;
free(fsip->fs_logical_device);
free(fsip->fs_type);
+ reply.error = NDMP_NO_MEM_ERR;
break;
}
(void) snprintf(fsip->fs_type, MNTTYPE_LEN, "%s",
@@ -631,6 +623,8 @@ ndmpd_config_get_fs_info_v3(ndmp_connection_t *connection, void *body)
}
save = envp = ndmp_malloc(sizeof (ndmp_pval) * V3_N_FS_ENVS);
if (!envp) {
+ free(fsip->fs_logical_device);
+ free(fsip->fs_type);
reply.error = NDMP_NO_MEM_ERR;
break;
}
@@ -647,29 +641,27 @@ ndmpd_config_get_fs_info_v3(ndmp_connection_t *connection, void *body)
}
fsip->fs_env.fs_env_len = envp - save;
- i++;
+ len++;
fsip++;
}
(void) fclose(fp);
+
+send_reply:
if (reply.error == NDMP_NO_ERR) {
- reply.fs_info.fs_info_len = i;
+ reply.fs_info.fs_info_len = len;
reply.fs_info.fs_info_val = fsip_save;
- } else {
- reply.fs_info.fs_info_len = 0;
- reply.fs_info.fs_info_val = NULL;
}
ndmp_send_reply(connection, (void *)&reply,
"error sending ndmp_config_get_fs_info reply");
- fsip = fsip_save;
- while (--i >= 0) {
+ while (fsip > fsip_save) {
+ fsip--;
free(fsip->fs_logical_device);
free(fsip->fs_env.fs_env_val);
free(fsip->fs_type);
- fsip++;
}
- free(fsip_save);
+ free(fsip);
}