Mercurial > illumos > illumos-gate
changeset 10873:4145146e1cfb
6263835 inetd could use option to set SO_KEEPALIVE
author | Gary Mills <mills@cc.umanitoba.ca> |
---|---|
date | Mon, 26 Oct 2009 09:11:24 -0700 |
parents | 2b1d93d31553 |
children | 3d30b905fb0b |
files | usr/src/cmd/cmd-inet/usr.lib/inetd/config.c usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.c usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.xml usr/src/lib/libinetsvc/common/inetsvc.c usr/src/lib/libinetsvc/common/inetsvc.h |
diffstat | 5 files changed, 40 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c Mon Oct 26 08:37:11 2009 -0700 +++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/config.c Mon Oct 26 09:11:24 2009 -0700 @@ -315,6 +315,8 @@ PR_DO_TCP_WRAPPERS_NAME); cfg->do_tcp_trace = get_prop_value_boolean(bprops, PR_DO_TCP_TRACE_NAME); + cfg->do_tcp_keepalive = get_prop_value_boolean(bprops, + PR_DO_TCP_KEEPALIVE_NAME); cfg->inherit_env = get_prop_value_boolean(bprops, PR_INHERIT_ENV_NAME); cfg->wait_fail_cnt = get_prop_value_int(bprops, PR_MAX_FAIL_RATE_CNT_NAME);
--- a/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.c Mon Oct 26 08:37:11 2009 -0700 +++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.c Mon Oct 26 09:11:24 2009 -0700 @@ -728,6 +728,18 @@ (void) close(fd); return (-1); } + if (inst->config->basic->do_tcp_keepalive && + !inst->config->basic->iswait && !inst->config->basic->istlx) { + /* set the keepalive option */ + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, + sizeof (on)) == -1) { + error_msg(gettext("setsockopt SO_KEEPALIVE failed for " + "service instance %s, proto %s: %s"), fmri, + proto, strerror(errno)); + (void) close(fd); + return (-1); + } + } if (sock_info->pr_info.v6only) { /* restrict socket to IPv6 communications only */ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on,
--- a/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.xml Mon Oct 26 08:37:11 2009 -0700 +++ b/usr/src/cmd/cmd-inet/usr.lib/inetd/inetd.xml Mon Oct 26 09:11:24 2009 -0700 @@ -138,6 +138,7 @@ <propval name='failrate_cnt' type='integer' value='40' /> <propval name='failrate_interval' type='integer' value='60' /> <propval name='inherit_env' type='boolean' value='true' /> + <propval name='tcp_keepalive' type='boolean' value='false' /> <propval name='tcp_trace' type='boolean' value='false' /> <propval name='tcp_wrappers' type='boolean' value='false' /> <propval name='bind_addr' type='astring' value='' /> @@ -402,6 +403,15 @@ </value> </values> </prop_pattern> + <prop_pattern name='tcp_keepalive' type='boolean' + required='true'> + <description> + <loctext xml:lang='C'> +If true, enables periodic transmission of messages for nowait stream services. + </loctext> + </description> + <cardinality min='1' max='1' /> + </prop_pattern> <prop_pattern name='tcp_trace' type='boolean' required='true'> <description> @@ -732,6 +742,15 @@ </description> <cardinality min='1' max='1' /> </prop_pattern> + <prop_pattern name='tcp_keepalive' type='boolean' + required='false'> + <description> + <loctext xml:lang='C'> +If true, enables periodic transmission of messages for nowait stream services. + </loctext> + </description> + <cardinality min='1' max='1' /> + </prop_pattern> <prop_pattern name='tcp_trace' type='boolean' required='false'> <description>
--- a/usr/src/lib/libinetsvc/common/inetsvc.c Mon Oct 26 08:37:11 2009 -0700 +++ b/usr/src/lib/libinetsvc/common/inetsvc.c Mon Oct 26 09:11:24 2009 -0700 @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This library contains a set of routines that are shared amongst inetd, * inetadm, inetconv and the formerly internal inetd services. Amongst the @@ -104,6 +102,8 @@ B_TRUE, IVE_UNSET, NULL, B_FALSE}, {PR_CONNECTION_BACKLOG_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_INTEGER, B_TRUE, IVE_UNSET, NULL, B_FALSE}, + {PR_DO_TCP_KEEPALIVE_NAME, PG_NAME_SERVICE_CONFIG, INET_TYPE_BOOLEAN, + B_TRUE, IVE_UNSET, NULL, B_FALSE}, {NULL}, };
--- a/usr/src/lib/libinetsvc/common/inetsvc.h Mon Oct 26 08:37:11 2009 -0700 +++ b/usr/src/lib/libinetsvc/common/inetsvc.h Mon Oct 26 09:11:24 2009 -0700 @@ -19,15 +19,13 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _INETSVC_H #define _INETSVC_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <libscf.h> #include <sys/socket.h> #include <libuutil.h> @@ -68,6 +66,7 @@ #define PR_INHERIT_ENV_NAME "inherit_env" #define PR_DO_TCP_WRAPPERS_NAME "tcp_wrappers" #define PR_DO_TCP_TRACE_NAME "tcp_trace" +#define PR_DO_TCP_KEEPALIVE_NAME "tcp_keepalive" #define PR_AUTO_CONVERTED_NAME "converted" #define PR_VERSION_NAME "version" #define PR_SOURCE_LINE_NAME "source_line" @@ -99,6 +98,7 @@ #define PT_DO_TCP_TRACE_INDEX 19 #define PT_DO_TCP_WRAPPERS_INDEX 20 #define PT_CONNECTION_BACKLOG_INDEX 21 +#define PT_DO_TCP_KEEPALIVE_INDEX 22 /* * Names of method properties. @@ -254,6 +254,7 @@ boolean_t do_tcp_wrappers; boolean_t do_tcp_trace; + boolean_t do_tcp_keepalive; /* inherit inetd's environment, or take an empty one */ boolean_t inherit_env;