summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/inet/tcp/tcp_tunables.c
diff options
context:
space:
mode:
authorDan McDonald <danmcd@nexenta.com>2013-07-18 22:44:14 -0400
committerDan McDonald <danmcd@nexenta.com>2013-07-19 16:56:58 -0400
commit7256a34efe9df75b638b9e812912ef7c5c68e208 (patch)
treee1cfd58e2326ee1c9041ec61cee53b2438744afb /usr/src/uts/common/inet/tcp/tcp_tunables.c
parent452bd827089206a0c637b3944aa91806f17304d7 (diff)
downloadillumos-joyent-7256a34efe9df75b638b9e812912ef7c5c68e208.tar.gz
3895 {tcp,udp}_{largest,smallest}_anon_port should reality-check
Reviewed by: Marcel Telka <marcel@telka.sk> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/uts/common/inet/tcp/tcp_tunables.c')
-rw-r--r--usr/src/uts/common/inet/tcp/tcp_tunables.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/usr/src/uts/common/inet/tcp/tcp_tunables.c b/usr/src/uts/common/inet/tcp/tcp_tunables.c
index 36bab57964..346903c577 100644
--- a/usr/src/uts/common/inet/tcp/tcp_tunables.c
+++ b/usr/src/uts/common/inet/tcp/tcp_tunables.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent Inc. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
/* Copyright (c) 1990 Mentat Inc. */
@@ -188,6 +189,46 @@ tcp_listener_conf_del(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
}
/*
+ * Special checkers for smallest/largest anonymous port so they don't
+ * ever happen to be (largest < smallest).
+ */
+/* ARGSUSED */
+static int
+tcp_smallest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
+ const char *ifname, const void *pval, uint_t flags)
+{
+ unsigned long new_value;
+ tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
+ int err;
+
+ if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
+ return (err);
+ /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
+ if ((uint32_t)new_value > tcps->tcps_largest_anon_port)
+ return (ERANGE);
+ pinfo->prop_cur_uval = (uint32_t)new_value;
+ return (0);
+}
+
+/* ARGSUSED */
+static int
+tcp_largest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
+ const char *ifname, const void *pval, uint_t flags)
+{
+ unsigned long new_value;
+ tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
+ int err;
+
+ if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
+ return (err);
+ /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
+ if ((uint32_t)new_value < tcps->tcps_smallest_anon_port)
+ return (ERANGE);
+ pinfo->prop_cur_uval = (uint32_t)new_value;
+ return (0);
+}
+
+/*
* All of these are alterable, within the min/max values given, at run time.
*
* Note: All those tunables which do not start with "_" are Committed and
@@ -308,11 +349,11 @@ mod_prop_info_t tcp_propinfo_tbl[] = {
{B_FALSE}, {B_FALSE} },
{ "smallest_anon_port", MOD_PROTO_TCP,
- mod_set_uint32, mod_get_uint32,
+ tcp_smallest_anon_set, mod_get_uint32,
{1024, ULP_MAX_PORT, 32*1024}, {32*1024} },
{ "largest_anon_port", MOD_PROTO_TCP,
- mod_set_uint32, mod_get_uint32,
+ tcp_largest_anon_set, mod_get_uint32,
{1024, ULP_MAX_PORT, ULP_MAX_PORT},
{ULP_MAX_PORT} },