4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
28 #include <sys/modctl.h>
29 #include <sys/stream.h>
30 #include <sys/strsubr.h>
31 #include <sys/stropts.h>
32 #define _SUN_TPI_VERSION 2
34 #include <sys/sunddi.h>
35 #include <sys/cmn_err.h>
36 #include <sys/debug.h>
37 #include <sys/vtrace.h>
38 #include <sys/errno.h>
39 #include <inet/common.h>
43 #include <sys/strsun.h>
45 #include <fs/sockfs/nl7c.h>
46 #include <fs/sockfs/nl7curi.h>
48 #include <inet/nca/nca.h>
49 #include <inet/nca/ncalogd.h>
52 * This file is for NCA compatability, specifically it provides ndd
53 * support for existing NCA ndd ...
56 extern boolean_t nl7c_logd_enabled
;
57 extern nca_fio_t
*nl7c_logd_fio
;
58 extern clock_t nl7c_uri_ttl
;
59 extern boolean_t nl7c_use_kmem
;
60 extern uint64_t nl7c_file_prefetch
;
61 extern uint64_t nl7c_uri_max
;
62 extern uint64_t nl7c_uri_bytes
;
64 extern void nl7c_mi_report_addr(mblk_t
*);
67 #define SECONDS (1000 * MS)
68 #define MINUTES (60 * SECONDS)
69 #define HOURS (60 * MINUTES)
70 #define DAYS (24 * HOURS)
72 #define PARAM_MAX UINT_MAX
73 #define PARAML_MAX ULONG_MAX
75 #include <inet/nca/ncandd.h>
77 uint32_t nca_major_version
= 1;
78 uint32_t nca_minor_version
= 3;
79 uint32_t nca_httpd_version
= NCA_HTTP_VERSION1
;
80 uint32_t nca_logd_version
= NCA_LOG_VERSION1
;
82 caddr_t nca_g_nd
; /* Head of 'named dispatch' variable list */
85 * min, max, and value are int64_t's, addr is the optional address of an
86 * external int64_t to be updated at init/set, name is the ndd name used
87 * to access. Note, if min == max then only get is allowed, i.e. RO.
91 ncaparam_t nca_param_arr
[] = {
92 /*min max value name */
93 { 0, 1, 1, "nca_log_cycle"},
94 { 0, 1, 0, "no_caching"},
95 { 0, PARAML_MAX
, 0, "nca_log_size"},
96 { 0, PARAM_MAX
, 10000000, "nca_max_cache_size"},
97 { 0, PARAM_MAX
, 300*SECONDS
, "nca_http_timeout"},
98 { 0, PARAM_MAX
, 15*SECONDS
, "nca_http_keep_alive_timeout"},
99 { 0, PARAM_MAX
, 100, "nca_http_keep_alive_max"},
100 { 0, 1, 1, "nca_inq_nointr"},
101 { 0, 1, 1, "nca_use_hwcksum"},
102 { 0, PARAM_MAX
, 0, "nca_segmap_min_size"},
106 * Obsolete ip variables, use "/dev/ip" instead.
109 ncaparam_t nca_ip_obsolete_arr
[] = {
110 { 0, 0, 0, "ip_forwarding"},
111 { 0, 0, 0, "ip_respond_to_address_mask_broadcast"},
112 { 0, 0, 0, "ip_respond_to_echo_broadcast"},
113 { 0, 0, 0, "ip_respond_to_timestamp"},
114 { 0, 0, 0, "ip_respond_to_timestamp_broadcast"},
115 { 0, 0, 0, "ip_send_redirects"},
116 { 0, 0, 0, "ip_forward_directed_broadcasts"},
117 { 0, 0, 0, "ip_debug"},
118 { 0, 0, 0, "ip_mrtdebug"},
119 { 0, 0, 0, "ip_ire_cleanup_interval" },
120 { 0, 0, 0, "ip_ire_flush_interval" },
121 { 0, 0, 0, "ip_ire_redirect_interval" },
122 { 0, 0, 0, "ip_def_ttl" },
123 { 0, 0, 0, "ip_forward_src_routed"},
124 { 0, 0, 0, "ip_wroff_extra" },
125 { 0, 0, 0, "ip_ire_pathmtu_interval" },
126 { 0, 0, 0, "ip_icmp_return_data_bytes" },
127 { 0, 0, 0, "ip_send_source_quench" },
128 { 0, 0, 0, "ip_path_mtu_discovery" },
129 { 0, 0, 0, "ip_ignore_delete_time" },
130 { 0, 0, 0, "ip_ignore_redirect" },
131 { 0, 0, 0, "ip_output_queue" },
132 { 0, 0, 0, "ip_broadcast_ttl" },
133 { 0, 0, 0, "ip_icmp_err_interval" },
134 { 0, 0, 0, "ip_reass_queue_bytes" },
135 { 0, 0, 0, "ip_strict_dst_multihoming" },
136 { 0, 0, 0, "ip_addrs_per_if"},
140 * Obsolete tcp variables, use "/dev/tcp" instead.
143 ncaparam_t nca_tcp_obsolete_arr
[] = {
144 { 0, 0, 0, "tcp_time_wait_interval"},
145 { 0, 0, 0, "tcp_conn_req_max_q" },
146 { 0, 0, 0, "tcp_conn_req_max_q0" },
147 { 0, 0, 0, "tcp_conn_req_min" },
148 { 0, 0, 0, "tcp_conn_grace_period" },
149 { 0, 0, 0, "tcp_cwnd_max" },
150 { 0, 0, 0, "tcp_debug" },
151 { 0, 0, 0, "tcp_smallest_nonpriv_port"},
152 { 0, 0, 0, "tcp_ip_abort_cinterval"},
153 { 0, 0, 0, "tcp_ip_abort_linterval"},
154 { 0, 0, 0, "tcp_ip_abort_interval"},
155 { 0, 0, 0, "tcp_ip_notify_cinterval"},
156 { 0, 0, 0, "tcp_ip_notify_interval"},
157 { 0, 0, 0, "tcp_ip_ttl"},
158 { 0, 0, 0, "tcp_keepalive_interval"},
159 { 0, 0, 0, "tcp_maxpsz_multiplier" },
160 { 0, 0, 0, "tcp_mss_def"},
161 { 0, 0, 0, "tcp_mss_max"},
162 { 0, 0, 0, "tcp_mss_min"},
163 { 0, 0, 0, "tcp_naglim_def"},
164 { 0, 0, 0, "tcp_rexmit_interval_initial"},
165 { 0, 0, 0, "tcp_rexmit_interval_max"},
166 { 0, 0, 0, "tcp_rexmit_interval_min"},
167 { 0, 0, 0, "tcp_wroff_xtra" },
168 { 0, 0, 0, "tcp_deferred_ack_interval" },
169 { 0, 0, 0, "tcp_snd_lowat_fraction" },
170 { 0, 0, 0, "tcp_sth_rcv_hiwat" },
171 { 0, 0, 0, "tcp_sth_rcv_lowat" },
172 { 0, 0, 0, "tcp_dupack_fast_retransmit" },
173 { 0, 0, 0, "tcp_ignore_path_mtu" },
174 { 0, 0, 0, "tcp_rcv_push_wait" },
175 { 0, 0, 0, "tcp_smallest_anon_port"},
176 { 0, 0, 0, "tcp_largest_anon_port"},
177 { 0, 0, 0, "tcp_xmit_hiwat"},
178 { 0, 0, 0, "tcp_xmit_lowat"},
179 { 0, 0, 0, "tcp_recv_hiwat"},
180 { 0, 0, 0, "tcp_recv_hiwat_minmss"},
181 { 0, 0, 0, "tcp_fin_wait_2_flush_interval"},
182 { 0, 0, 0, "tcp_max_buf"},
183 { 0, 0, 0, "tcp_strong_iss"},
184 { 0, 0, 0, "tcp_rtt_updates"},
185 { 0, 0, 0, "tcp_wscale_always"},
186 { 0, 0, 0, "tcp_tstamp_always"},
187 { 0, 0, 0, "tcp_tstamp_if_wscale"},
188 { 0, 0, 0, "tcp_rexmit_interval_extra"},
189 { 0, 0, 0, "tcp_deferred_acks_max"},
190 { 0, 0, 0, "tcp_slow_start_after_idle"},
191 { 0, 0, 0, "tcp_slow_start_initial"},
192 { 0, 0, 0, "tcp_sack_permitted"},
194 { 0, 0, 0, "tcp_drop_oob"},
199 * Obsolete nca variables, just warn.
202 ncaparam_t nca_nca_obsolete_arr
[] = {
203 { 0, 0, 0, "nca_ipport_table_bucket"},
204 { 0, 0, 0, "nca_ipport_table_size"},
205 { 0, 0, 0, "nca_ipport_table_expand"},
206 { 0, 0, 0, "nca_ipport_table_shrink"},
207 { 0, 0, 0, "nca_ip_virtual_hosting"},
208 { 0, 0, 0, "httpd_door_address"},
209 { 0, 0, 0, "httpd_door_path"},
210 { 0, 0, 0, "httpd_downdoor_path"},
211 { 0, 0, 0, "nca_ppmax"},
212 { 0, 0, 0, "nca_vpmax"},
213 { 0, 0, 0, "nca_use_segmap"},
214 { 0, 0, 0, "nca_availrmem"},
215 { 0, 0, 0, "nca_maxkmem"},
216 { 0, 0, 0, "nca_log_file"},
217 { 0, 0, 0, "conn_status"},
218 { 0, 0, 0, "conn_status_all"},
219 { 0, 0, 0, "nca_conn_req_max_q"},
220 { 0, 0, 0, "nca_conn_req_max_q0"},
221 { 0, 0, 0, "cache_clear"},
222 { 0, 0, 0, "nca_node_hash"},
223 { 0, 0, 0, "node_status"},
225 { 0, 0, 0, "nca_debug_counter"},
232 nl7c_uri_ttl_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
234 (void) mi_mpprintf(mp
, "%ld", nl7c_uri_ttl
);
240 nl7c_uri_ttl_set(queue_t
*q
, mblk_t
*mp
, char *value
, caddr_t nu
, cred_t
*cr
)
242 if (ddi_strtol(value
, NULL
, 10, &nl7c_uri_ttl
) != 0)
249 nca_logging_on_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
251 (void) mi_mpprintf(mp
, "%d", nl7c_logd_enabled
);
257 nca_logging_on_set(queue_t
*q
, mblk_t
*mp
, char *value
, caddr_t nu
, cred_t
*cr
)
261 if (ddi_strtol(value
, NULL
, 10, &new_value
) != 0 || new_value
< 0 ||
265 if (nca_fio_cnt(nl7c_logd_fio
) == 0)
267 nl7c_logd_enabled
= new_value
;
274 nca_version_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
276 (void) mi_mpprintf(mp
, "%d.%d", nca_major_version
, nca_minor_version
);
282 nca_httpd_version_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
284 (void) mi_mpprintf(mp
, "%d", nca_httpd_version
);
290 nca_logd_version_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
292 (void) mi_mpprintf(mp
, "%d", nca_logd_version
);
298 nca_httpd_door_inst_get(queue_t
*q
, mblk_t
*mp
, caddr_t nu
, cred_t
*cr
)
300 nl7c_mi_report_addr(mp
);
306 nca_param_get(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
308 ncaparam_t
*ncapa
= (ncaparam_t
*)cp
;
310 (void) mi_mpprintf(mp
, "%ld", ncapa
->param_val
);
316 nca_param_set(queue_t
*q
, mblk_t
*mp
, char *value
, caddr_t cp
, cred_t
*cr
)
319 ncaparam_t
*ncapa
= (ncaparam_t
*)cp
;
321 if (ddi_strtoul(value
, NULL
, 10, &new_value
) != 0 ||
322 new_value
< ncapa
->param_min
|| new_value
> ncapa
->param_max
) {
325 ncapa
->param_val
= new_value
;
331 nca_obsolete(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
333 (void) mi_mpprintf(mp
, "obsolete");
339 nca_ip_obsolete(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
341 (void) mi_mpprintf(mp
, "obsolete for /dev/nca, use /dev/ip");
347 nca_tcp_obsolete(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
349 (void) mi_mpprintf(mp
, "obsolete for /dev/nca, use /dev/tcp");
355 nca_nca_obsolete(queue_t
*q
, mblk_t
*mp
, caddr_t cp
, cred_t
*cr
)
357 (void) mi_mpprintf(mp
, "obsolete for /dev/nca");
362 nca_param_register(ncaparam_t
*ncapa
, int cnt
)
364 for (; cnt
-- > 0; ncapa
++) {
365 if (ncapa
->param_name
&& ncapa
->param_name
[0]) {
366 if (!nd_load(&nca_g_nd
, ncapa
->param_name
,
367 nca_param_get
, nca_param_set
,
374 if (!nd_load(&nca_g_nd
, "nca_version", nca_version_get
, nil(pfi_t
),
378 if (!nd_load(&nca_g_nd
, "nca_logd_version", nca_logd_version_get
,
379 nil(pfi_t
), nil(caddr_t
))) {
382 if (!nd_load(&nca_g_nd
, "nca_logging_on", nca_logging_on_get
,
383 nca_logging_on_set
, nil(caddr_t
))) {
387 if (!nd_load(&nca_g_nd
, "uri_time_to_live", nl7c_uri_ttl_get
,
388 nl7c_uri_ttl_set
, nil(caddr_t
))) {
391 if (!nd_load(&nca_g_nd
, "nca_httpd_version", nca_httpd_version_get
,
392 nil(pfi_t
), nil(caddr_t
))) {
395 if (!nd_load(&nca_g_nd
, "httpd_door_instance", nca_httpd_door_inst_get
,
396 nil(pfi_t
), nil(caddr_t
))) {
401 ncapa
= nca_ip_obsolete_arr
;
402 cnt
= A_CNT(nca_ip_obsolete_arr
);
403 for (; cnt
-- > 0; ncapa
++) {
404 if (ncapa
->param_name
&& ncapa
->param_name
[0]) {
405 if (!nd_load(&nca_g_nd
, ncapa
->param_name
,
406 nca_ip_obsolete
, NULL
, (caddr_t
)ncapa
)) {
413 ncapa
= nca_tcp_obsolete_arr
;
414 cnt
= A_CNT(nca_tcp_obsolete_arr
);
415 for (; cnt
-- > 0; ncapa
++) {
416 if (ncapa
->param_name
&& ncapa
->param_name
[0]) {
417 if (!nd_load(&nca_g_nd
, ncapa
->param_name
,
418 nca_tcp_obsolete
, NULL
, (caddr_t
)ncapa
)) {
425 ncapa
= nca_nca_obsolete_arr
;
426 cnt
= A_CNT(nca_nca_obsolete_arr
);
427 for (; cnt
-- > 0; ncapa
++) {
428 if (ncapa
->param_name
&& ncapa
->param_name
[0]) {
429 if (!nd_load(&nca_g_nd
, ncapa
->param_name
,
430 nca_nca_obsolete
, NULL
, (caddr_t
)ncapa
)) {
448 if (! nca_param_register(nca_param_arr
, A_CNT(nca_param_arr
)))
450 "nl7c: /dev/nca ndd initialization failed.");