Print this page
4770 soconfig(1M) needs an option to print the in-kernel socket configuration table
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/socketvar.h
+++ new/usr/src/uts/common/sys/socketvar.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
28 28
29 29 /*
30 30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 31 * The Regents of the University of California
32 32 * All Rights Reserved
33 33 *
34 34 * University Acknowledgment- Portions of this document are derived from
35 35 * software developed by the University of California, Berkeley, and its
36 36 * contributors.
37 37 */
38 +/*
39 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
40 + */
38 41
39 42 #ifndef _SYS_SOCKETVAR_H
40 43 #define _SYS_SOCKETVAR_H
41 44
42 45 #include <sys/types.h>
43 46 #include <sys/stream.h>
44 47 #include <sys/t_lock.h>
45 48 #include <sys/cred.h>
46 49 #include <sys/vnode.h>
47 50 #include <sys/file.h>
48 51 #include <sys/param.h>
49 52 #include <sys/zone.h>
50 53 #include <sys/sdt.h>
51 54 #include <sys/modctl.h>
52 55 #include <sys/atomic.h>
53 56 #include <sys/socket.h>
54 57 #include <sys/ksocket.h>
55 58 #include <sys/kstat.h>
56 59
57 60 #ifdef _KERNEL
58 61 #include <sys/vfs_opreg.h>
59 62 #endif
60 63
61 64 #ifdef __cplusplus
62 65 extern "C" {
63 66 #endif
64 67
65 68 /*
66 69 * Internal representation of the address used to represent addresses
67 70 * in the loopback transport for AF_UNIX. While the sockaddr_un is used
68 71 * as the sockfs layer address for AF_UNIX the pathnames contained in
69 72 * these addresses are not unique (due to relative pathnames) thus can not
70 73 * be used in the transport.
71 74 *
72 75 * The transport level address consists of a magic number (used to separate the
73 76 * name space for specific and implicit binds). For a specific bind
74 77 * this is followed by a "vnode *" which ensures that all specific binds
75 78 * have a unique transport level address. For implicit binds the latter
76 79 * part of the address is a byte string (of the same length as a pointer)
77 80 * that is assigned by the loopback transport.
78 81 *
79 82 * The uniqueness assumes that the loopback transport has a separate namespace
80 83 * for sockets in order to avoid name conflicts with e.g. TLI use of the
81 84 * same transport.
82 85 */
83 86 struct so_ux_addr {
84 87 void *soua_vp; /* vnode pointer or assigned by tl */
85 88 uint_t soua_magic; /* See below */
86 89 };
87 90
88 91 #define SOU_MAGIC_EXPLICIT 0x75787670 /* "uxvp" */
89 92 #define SOU_MAGIC_IMPLICIT 0x616e6f6e /* "anon" */
90 93
91 94 struct sockaddr_ux {
92 95 sa_family_t sou_family; /* AF_UNIX */
93 96 struct so_ux_addr sou_addr;
94 97 };
95 98
96 99 #if defined(_KERNEL) || defined(_KMEMUSER)
97 100
98 101 #include <sys/socket_proto.h>
99 102
100 103 typedef struct sonodeops sonodeops_t;
101 104 typedef struct sonode sonode_t;
102 105
103 106 struct sodirect_s;
104 107
105 108 /*
106 109 * The sonode represents a socket. A sonode never exist in the file system
107 110 * name space and can not be opened using open() - only the socket, socketpair
108 111 * and accept calls create sonodes.
109 112 *
110 113 * The locking of sockfs uses the so_lock mutex plus the SOLOCKED and
111 114 * SOREADLOCKED flags in so_flag. The mutex protects all the state in the
112 115 * sonode. It is expected that the underlying transport protocol serializes
113 116 * socket operations, so sockfs will not normally not single-thread
114 117 * operations. However, certain sockets, including TPI based ones, can only
115 118 * handle one control operation at a time. The SOLOCKED flag is used to
116 119 * single-thread operations from sockfs users to prevent e.g. multiple bind()
117 120 * calls to operate on the same sonode concurrently. The SOREADLOCKED flag is
118 121 * used to ensure that only one thread sleeps in kstrgetmsg for a given
119 122 * sonode. This is needed to ensure atomic operation for things like
120 123 * MSG_WAITALL.
121 124 *
122 125 * The so_fallback_rwlock is used to ensure that for sockets that can
123 126 * fall back to TPI, the fallback is not initiated until all pending
124 127 * operations have completed.
125 128 *
126 129 * Note that so_lock is sometimes held across calls that might go to sleep
127 130 * (kmem_alloc and soallocproto*). This implies that no other lock in
128 131 * the system should be held when calling into sockfs; from the system call
129 132 * side or from strrput (in case of TPI based sockets). If locks are held
130 133 * while calling into sockfs the system might hang when running low on memory.
131 134 */
132 135 struct sonode {
133 136 struct vnode *so_vnode; /* vnode associated with this sonode */
134 137
135 138 sonodeops_t *so_ops; /* operations vector for this sonode */
136 139 void *so_priv; /* sonode private data */
137 140
138 141 krwlock_t so_fallback_rwlock;
139 142 kmutex_t so_lock; /* protects sonode fields */
140 143
141 144 kcondvar_t so_state_cv; /* synchronize state changes */
142 145 kcondvar_t so_single_cv; /* wait due to SOLOCKED */
143 146 kcondvar_t so_read_cv; /* wait due to SOREADLOCKED */
144 147
145 148 /* These fields are protected by so_lock */
146 149
147 150 uint_t so_state; /* internal state flags SS_*, below */
148 151 uint_t so_mode; /* characteristics on socket. SM_* */
149 152 ushort_t so_flag; /* flags, see below */
150 153 int so_count; /* count of opened references */
151 154
152 155 sock_connid_t so_proto_connid; /* protocol generation number */
153 156
154 157 ushort_t so_error; /* error affecting connection */
155 158
156 159 struct sockparams *so_sockparams; /* vnode or socket module */
157 160 /* Needed to recreate the same socket for accept */
158 161 short so_family;
159 162 short so_type;
160 163 short so_protocol;
161 164 short so_version; /* From so_socket call */
162 165
163 166 /* Accept queue */
164 167 kmutex_t so_acceptq_lock; /* protects accept queue */
165 168 list_t so_acceptq_list; /* pending conns */
166 169 list_t so_acceptq_defer; /* deferred conns */
167 170 list_node_t so_acceptq_node; /* acceptq list node */
168 171 unsigned int so_acceptq_len; /* # of conns (both lists) */
169 172 unsigned int so_backlog; /* Listen backlog */
170 173 kcondvar_t so_acceptq_cv; /* wait for new conn. */
171 174 struct sonode *so_listener; /* parent socket */
172 175
173 176 /* Options */
174 177 short so_options; /* From socket call, see socket.h */
175 178 struct linger so_linger; /* SO_LINGER value */
176 179 #define so_sndbuf so_proto_props.sopp_txhiwat /* SO_SNDBUF value */
177 180 #define so_sndlowat so_proto_props.sopp_txlowat /* tx low water mark */
178 181 #define so_rcvbuf so_proto_props.sopp_rxhiwat /* SO_RCVBUF value */
179 182 #define so_rcvlowat so_proto_props.sopp_rxlowat /* rx low water mark */
180 183 #define so_max_addr_len so_proto_props.sopp_maxaddrlen
181 184 #define so_minpsz so_proto_props.sopp_minpsz
182 185 #define so_maxpsz so_proto_props.sopp_maxpsz
183 186
184 187 int so_xpg_rcvbuf; /* SO_RCVBUF value for XPG4 socket */
185 188 clock_t so_sndtimeo; /* send timeout */
186 189 clock_t so_rcvtimeo; /* recv timeout */
187 190
188 191 mblk_t *so_oobmsg; /* outofline oob data */
189 192 ssize_t so_oobmark; /* offset of the oob data */
190 193
191 194 pid_t so_pgrp; /* pgrp for signals */
192 195
193 196 cred_t *so_peercred; /* connected socket peer cred */
194 197 pid_t so_cpid; /* connected socket peer cached pid */
195 198 zoneid_t so_zoneid; /* opener's zoneid */
196 199
197 200 struct pollhead so_poll_list; /* common pollhead */
198 201 short so_pollev; /* events that should be generated */
199 202
200 203 /* Receive */
201 204 unsigned int so_rcv_queued; /* # bytes on both rcv lists */
202 205 mblk_t *so_rcv_q_head; /* processing/copyout rcv queue */
203 206 mblk_t *so_rcv_q_last_head;
204 207 mblk_t *so_rcv_head; /* protocol prequeue */
205 208 mblk_t *so_rcv_last_head; /* last mblk in b_next chain */
206 209 kcondvar_t so_rcv_cv; /* wait for data */
207 210 uint_t so_rcv_wanted; /* # of bytes wanted by app */
208 211 timeout_id_t so_rcv_timer_tid;
209 212
210 213 #define so_rcv_thresh so_proto_props.sopp_rcvthresh
211 214 #define so_rcv_timer_interval so_proto_props.sopp_rcvtimer
212 215
213 216 kcondvar_t so_snd_cv; /* wait for snd buffers */
214 217 uint32_t
215 218 so_snd_qfull: 1, /* Transmit full */
216 219 so_rcv_wakeup: 1,
217 220 so_snd_wakeup: 1,
218 221 so_not_str: 1, /* B_TRUE if not streams based socket */
219 222 so_pad_to_bit_31: 28;
220 223
221 224 /* Communication channel with protocol */
222 225 sock_lower_handle_t so_proto_handle;
223 226 sock_downcalls_t *so_downcalls;
224 227
225 228 struct sock_proto_props so_proto_props; /* protocol settings */
226 229 boolean_t so_flowctrld; /* Flow controlled */
227 230 uint_t so_copyflag; /* Copy related flag */
228 231 kcondvar_t so_copy_cv; /* Copy cond variable */
229 232
230 233 /* kernel sockets */
231 234 ksocket_callbacks_t so_ksock_callbacks;
232 235 void *so_ksock_cb_arg; /* callback argument */
233 236 kcondvar_t so_closing_cv;
234 237
235 238 /* != NULL for sodirect enabled socket */
236 239 struct sodirect_s *so_direct;
237 240
238 241 /* socket filters */
239 242 uint_t so_filter_active; /* # of active fil */
240 243 uint_t so_filter_tx; /* pending tx ops */
241 244 struct sof_instance *so_filter_top; /* top of stack */
242 245 struct sof_instance *so_filter_bottom; /* bottom of stack */
243 246 clock_t so_filter_defertime; /* time when deferred */
244 247 };
245 248
246 249 #define SO_HAVE_DATA(so) \
247 250 /* \
248 251 * For the (tid == 0) case we must check so_rcv_{q_,}head \
249 252 * rather than (so_rcv_queued > 0), since the latter does not \
250 253 * take into account mblks with only control/name information. \
251 254 */ \
252 255 ((so)->so_rcv_timer_tid == 0 && ((so)->so_rcv_head != NULL || \
253 256 (so)->so_rcv_q_head != NULL)) || \
254 257 ((so)->so_state & SS_CANTRCVMORE)
255 258
256 259 /*
257 260 * Events handled by the protocol (in case sd_poll is set)
258 261 */
259 262 #define SO_PROTO_POLLEV (POLLIN|POLLRDNORM|POLLRDBAND)
260 263
261 264
262 265 #endif /* _KERNEL || _KMEMUSER */
263 266
264 267 /* flags */
265 268 #define SOMOD 0x0001 /* update socket modification time */
266 269 #define SOACC 0x0002 /* update socket access time */
267 270
268 271 #define SOLOCKED 0x0010 /* use to serialize open/closes */
269 272 #define SOREADLOCKED 0x0020 /* serialize kstrgetmsg calls */
270 273 #define SOCLONE 0x0040 /* child of clone driver */
271 274 #define SOASYNC_UNBIND 0x0080 /* wait for ACK of async unbind */
272 275
273 276 #define SOCK_IS_NONSTR(so) ((so)->so_not_str)
274 277
275 278 /*
276 279 * Socket state bits.
277 280 */
278 281 #define SS_ISCONNECTED 0x00000001 /* socket connected to a peer */
279 282 #define SS_ISCONNECTING 0x00000002 /* in process, connecting to peer */
280 283 #define SS_ISDISCONNECTING 0x00000004 /* in process of disconnecting */
281 284 #define SS_CANTSENDMORE 0x00000008 /* can't send more data to peer */
282 285
283 286 #define SS_CANTRCVMORE 0x00000010 /* can't receive more data */
284 287 #define SS_ISBOUND 0x00000020 /* socket is bound */
285 288 #define SS_NDELAY 0x00000040 /* FNDELAY non-blocking */
286 289 #define SS_NONBLOCK 0x00000080 /* O_NONBLOCK non-blocking */
287 290
288 291 #define SS_ASYNC 0x00000100 /* async i/o notify */
289 292 #define SS_ACCEPTCONN 0x00000200 /* listen done */
290 293 /* unused 0x00000400 */ /* was SS_HASCONNIND */
291 294 #define SS_SAVEDEOR 0x00000800 /* Saved MSG_EOR rcv side state */
292 295
293 296 #define SS_RCVATMARK 0x00001000 /* at mark on input */
294 297 #define SS_OOBPEND 0x00002000 /* OOB pending or present - poll */
295 298 #define SS_HAVEOOBDATA 0x00004000 /* OOB data present */
296 299 #define SS_HADOOBDATA 0x00008000 /* OOB data consumed */
297 300 #define SS_CLOSING 0x00010000 /* in process of closing */
298 301
299 302 #define SS_FIL_DEFER 0x00020000 /* filter deferred notification */
300 303 #define SS_FILOP_OK 0x00040000 /* socket can attach filters */
301 304 #define SS_FIL_RCV_FLOWCTRL 0x00080000 /* filter asserted rcv flow ctrl */
302 305 #define SS_FIL_SND_FLOWCTRL 0x00100000 /* filter asserted snd flow ctrl */
303 306 #define SS_FIL_STOP 0x00200000 /* no more filter actions */
304 307
305 308 #define SS_SODIRECT 0x00400000 /* transport supports sodirect */
306 309
307 310 #define SS_SENTLASTREADSIG 0x01000000 /* last rx signal has been sent */
308 311 #define SS_SENTLASTWRITESIG 0x02000000 /* last tx signal has been sent */
309 312
310 313 #define SS_FALLBACK_DRAIN 0x20000000 /* data was/is being drained */
311 314 #define SS_FALLBACK_PENDING 0x40000000 /* fallback is pending */
312 315 #define SS_FALLBACK_COMP 0x80000000 /* fallback has completed */
313 316
314 317
315 318 /* Set of states when the socket can't be rebound */
316 319 #define SS_CANTREBIND (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING|\
317 320 SS_CANTSENDMORE|SS_CANTRCVMORE|SS_ACCEPTCONN)
318 321
319 322 /*
320 323 * Sockets that can fall back to TPI must ensure that fall back is not
321 324 * initiated while a thread is using a socket.
322 325 */
323 326 #define SO_BLOCK_FALLBACK(so, fn) \
324 327 ASSERT(MUTEX_NOT_HELD(&(so)->so_lock)); \
325 328 rw_enter(&(so)->so_fallback_rwlock, RW_READER); \
326 329 if ((so)->so_state & (SS_FALLBACK_COMP|SS_FILOP_OK)) { \
327 330 if ((so)->so_state & SS_FALLBACK_COMP) { \
328 331 rw_exit(&(so)->so_fallback_rwlock); \
329 332 return (fn); \
330 333 } else { \
331 334 mutex_enter(&(so)->so_lock); \
332 335 (so)->so_state &= ~SS_FILOP_OK; \
333 336 mutex_exit(&(so)->so_lock); \
334 337 } \
335 338 }
336 339
337 340 #define SO_UNBLOCK_FALLBACK(so) { \
338 341 rw_exit(&(so)->so_fallback_rwlock); \
339 342 }
340 343
341 344 #define SO_SND_FLOWCTRLD(so) \
342 345 ((so)->so_snd_qfull || (so)->so_state & SS_FIL_SND_FLOWCTRL)
343 346
344 347 /* Poll events */
345 348 #define SO_POLLEV_IN 0x1 /* POLLIN wakeup needed */
346 349 #define SO_POLLEV_ALWAYS 0x2 /* wakeups */
347 350
348 351 /*
349 352 * Characteristics of sockets. Not changed after the socket is created.
350 353 */
351 354 #define SM_PRIV 0x001 /* privileged for broadcast, raw... */
352 355 #define SM_ATOMIC 0x002 /* atomic data transmission */
353 356 #define SM_ADDR 0x004 /* addresses given with messages */
354 357 #define SM_CONNREQUIRED 0x008 /* connection required by protocol */
355 358
356 359 #define SM_FDPASSING 0x010 /* passes file descriptors */
357 360 #define SM_EXDATA 0x020 /* Can handle T_EXDATA_REQ */
358 361 #define SM_OPTDATA 0x040 /* Can handle T_OPTDATA_REQ */
359 362 #define SM_BYTESTREAM 0x080 /* Byte stream - can use M_DATA */
360 363
361 364 #define SM_ACCEPTOR_ID 0x100 /* so_acceptor_id is valid */
362 365
363 366 #define SM_KERNEL 0x200 /* kernel socket */
364 367
365 368 /* The modes below are only for non-streams sockets */
366 369 #define SM_ACCEPTSUPP 0x400 /* can handle accept() */
367 370 #define SM_SENDFILESUPP 0x800 /* Private: proto supp sendfile */
368 371
369 372 /*
370 373 * Socket versions. Used by the socket library when calling _so_socket().
371 374 */
372 375 #define SOV_STREAM 0 /* Not a socket - just a stream */
373 376 #define SOV_DEFAULT 1 /* Select based on so_default_version */
374 377 #define SOV_SOCKSTREAM 2 /* Socket plus streams operations */
375 378 #define SOV_SOCKBSD 3 /* Socket with no streams operations */
376 379 #define SOV_XPG4_2 4 /* Xnet socket */
377 380
378 381 #if defined(_KERNEL) || defined(_KMEMUSER)
379 382
380 383 /*
381 384 * sonode create and destroy functions.
382 385 */
383 386 typedef struct sonode *(*so_create_func_t)(struct sockparams *,
384 387 int, int, int, int, int, int *, cred_t *);
385 388 typedef void (*so_destroy_func_t)(struct sonode *);
386 389
387 390 /* STREAM device information */
388 391 typedef struct sdev_info {
389 392 char *sd_devpath;
390 393 int sd_devpathlen; /* Is 0 if sp_devpath is a static string */
391 394 vnode_t *sd_vnode;
392 395 } sdev_info_t;
393 396
394 397 #define SOCKMOD_VERSION_1 1
395 398 #define SOCKMOD_VERSION 2
396 399
397 400 /* name of the TPI pseudo socket module */
398 401 #define SOTPI_SMOD_NAME "socktpi"
399 402
400 403 typedef struct __smod_priv_s {
401 404 so_create_func_t smodp_sock_create_func;
402 405 so_destroy_func_t smodp_sock_destroy_func;
403 406 so_proto_fallback_func_t smodp_proto_fallback_func;
404 407 const char *smodp_fallback_devpath_v4;
405 408 const char *smodp_fallback_devpath_v6;
406 409 } __smod_priv_t;
407 410
408 411 /*
409 412 * Socket module register information
410 413 */
411 414 typedef struct smod_reg_s {
412 415 int smod_version;
413 416 char *smod_name;
414 417 size_t smod_uc_version;
415 418 size_t smod_dc_version;
416 419 so_proto_create_func_t smod_proto_create_func;
417 420
418 421 /* __smod_priv_data must be NULL */
419 422 __smod_priv_t *__smod_priv;
420 423 } smod_reg_t;
421 424
422 425 /*
423 426 * Socket module information
424 427 */
425 428 typedef struct smod_info {
426 429 int smod_version;
427 430 char *smod_name;
428 431 uint_t smod_refcnt; /* # of entries */
429 432 size_t smod_uc_version; /* upcall version */
430 433 size_t smod_dc_version; /* down call version */
431 434 so_proto_create_func_t smod_proto_create_func;
432 435 so_proto_fallback_func_t smod_proto_fallback_func;
433 436 const char *smod_fallback_devpath_v4;
434 437 const char *smod_fallback_devpath_v6;
435 438 so_create_func_t smod_sock_create_func;
436 439 so_destroy_func_t smod_sock_destroy_func;
437 440 list_node_t smod_node;
438 441 } smod_info_t;
439 442
440 443 typedef struct sockparams_stats {
441 444 kstat_named_t sps_nfallback; /* # of fallbacks to TPI */
442 445 kstat_named_t sps_nactive; /* # of active sockets */
443 446 kstat_named_t sps_ncreate; /* total # of created sockets */
444 447 } sockparams_stats_t;
445 448
446 449 /*
447 450 * sockparams
448 451 *
449 452 * Used for mapping family/type/protocol to a socket module or STREAMS device
450 453 */
451 454 struct sockparams {
452 455 /*
453 456 * The family, type, protocol, sdev_info and smod_name are
454 457 * set when the entry is created, and they will never change
455 458 * thereafter.
456 459 */
457 460 int sp_family;
458 461 int sp_type;
459 462 int sp_protocol;
460 463
461 464 sdev_info_t sp_sdev_info; /* STREAM device */
462 465 char *sp_smod_name; /* socket module name */
463 466
464 467 kmutex_t sp_lock; /* lock for refcnt and smod_info */
465 468 uint64_t sp_refcnt; /* entry reference count */
466 469 smod_info_t *sp_smod_info; /* socket module */
467 470
468 471 sockparams_stats_t sp_stats;
469 472 kstat_t *sp_kstat;
470 473
471 474 /*
472 475 * The entries below are only modified while holding
473 476 * sockconf_lock as a writer.
474 477 */
475 478 int sp_flags; /* see below */
476 479 list_node_t sp_node;
477 480
478 481 list_t sp_auto_filters; /* list of automatic filters */
479 482 list_t sp_prog_filters; /* list of programmatic filters */
480 483 };
481 484
482 485 struct sof_entry;
483 486
484 487 typedef struct sp_filter {
485 488 struct sof_entry *spf_filter;
486 489 list_node_t spf_node;
487 490 } sp_filter_t;
488 491
489 492
490 493 /*
491 494 * sockparams flags
492 495 */
493 496 #define SOCKPARAMS_EPHEMERAL 0x1 /* temp. entry, not on global list */
494 497
495 498 extern void sockparams_init(void);
496 499 extern struct sockparams *sockparams_hold_ephemeral_bydev(int, int, int,
497 500 const char *, int, int *);
498 501 extern struct sockparams *sockparams_hold_ephemeral_bymod(int, int, int,
↓ open down ↓ |
451 lines elided |
↑ open up ↑ |
499 502 const char *, int, int *);
500 503 extern void sockparams_ephemeral_drop_last_ref(struct sockparams *);
501 504
502 505 extern struct sockparams *sockparams_create(int, int, int, char *, char *, int,
503 506 int, int, int *);
504 507 extern void sockparams_destroy(struct sockparams *);
505 508 extern int sockparams_add(struct sockparams *);
506 509 extern int sockparams_delete(int, int, int);
507 510 extern int sockparams_new_filter(struct sof_entry *);
508 511 extern void sockparams_filter_cleanup(struct sof_entry *);
512 +extern int sockparams_copyout_socktable(uintptr_t);
509 513
510 514 extern void smod_init(void);
511 515 extern void smod_add(smod_info_t *);
512 516 extern int smod_register(const smod_reg_t *);
513 517 extern int smod_unregister(const char *);
514 518 extern smod_info_t *smod_lookup_byname(const char *);
515 519
516 520 #define SOCKPARAMS_HAS_DEVICE(sp) \
517 521 ((sp)->sp_sdev_info.sd_devpath != NULL)
518 522
519 523 /* Increase the smod_info_t reference count */
520 524 #define SMOD_INC_REF(smodp) { \
521 525 ASSERT((smodp) != NULL); \
522 526 DTRACE_PROBE1(smodinfo__inc__ref, struct smod_info *, (smodp)); \
523 527 atomic_inc_uint(&(smodp)->smod_refcnt); \
524 528 }
525 529
526 530 /*
527 531 * Decreace the socket module entry reference count.
528 532 * When no one mapping to the entry, we try to unload the module from the
529 533 * kernel. If the module can't unload, just leave the module entry with
530 534 * a zero refcnt.
531 535 */
532 536 #define SMOD_DEC_REF(smodp, modname) { \
533 537 ASSERT((smodp) != NULL); \
534 538 ASSERT((smodp)->smod_refcnt != 0); \
535 539 atomic_dec_uint(&(smodp)->smod_refcnt); \
536 540 /* \
537 541 * No need to atomically check the return value because the \
538 542 * socket module framework will verify that no one is using \
539 543 * the module before unloading. Worst thing that can happen \
540 544 * here is multiple calls to mod_remove_by_name(), which is OK. \
541 545 */ \
542 546 if ((smodp)->smod_refcnt == 0) \
543 547 (void) mod_remove_by_name(modname); \
544 548 }
545 549
546 550 /* Increase the reference count */
547 551 #define SOCKPARAMS_INC_REF(sp) { \
548 552 ASSERT((sp) != NULL); \
549 553 DTRACE_PROBE1(sockparams__inc__ref, struct sockparams *, (sp)); \
550 554 mutex_enter(&(sp)->sp_lock); \
551 555 (sp)->sp_refcnt++; \
552 556 ASSERT((sp)->sp_refcnt != 0); \
553 557 mutex_exit(&(sp)->sp_lock); \
554 558 }
555 559
556 560 /*
557 561 * Decrease the reference count.
558 562 *
559 563 * If the sockparams is ephemeral, then the thread dropping the last ref
560 564 * count will destroy the entry.
561 565 */
562 566 #define SOCKPARAMS_DEC_REF(sp) { \
563 567 ASSERT((sp) != NULL); \
564 568 DTRACE_PROBE1(sockparams__dec__ref, struct sockparams *, (sp)); \
565 569 mutex_enter(&(sp)->sp_lock); \
566 570 ASSERT((sp)->sp_refcnt > 0); \
567 571 if ((sp)->sp_refcnt == 1) { \
568 572 if ((sp)->sp_flags & SOCKPARAMS_EPHEMERAL) { \
569 573 mutex_exit(&(sp)->sp_lock); \
570 574 sockparams_ephemeral_drop_last_ref((sp)); \
571 575 } else { \
572 576 (sp)->sp_refcnt--; \
573 577 if ((sp)->sp_smod_info != NULL) { \
574 578 SMOD_DEC_REF((sp)->sp_smod_info, \
575 579 (sp)->sp_smod_name); \
576 580 } \
577 581 (sp)->sp_smod_info = NULL; \
578 582 mutex_exit(&(sp)->sp_lock); \
579 583 } \
580 584 } else { \
581 585 (sp)->sp_refcnt--; \
582 586 mutex_exit(&(sp)->sp_lock); \
583 587 } \
584 588 }
585 589
586 590 /*
587 591 * Used to traverse the list of AF_UNIX sockets to construct the kstat
588 592 * for netstat(1m).
589 593 */
590 594 struct socklist {
591 595 kmutex_t sl_lock;
592 596 struct sonode *sl_list;
593 597 };
594 598
595 599 extern struct socklist socklist;
596 600 /*
597 601 * ss_full_waits is the number of times the reader thread
598 602 * waits when the queue is full and ss_empty_waits is the number
599 603 * of times the consumer thread waits when the queue is empty.
600 604 * No locks for these as they are just indicators of whether
601 605 * disk or network or both is slow or fast.
602 606 */
603 607 struct sendfile_stats {
604 608 uint32_t ss_file_cached;
605 609 uint32_t ss_file_not_cached;
606 610 uint32_t ss_full_waits;
607 611 uint32_t ss_empty_waits;
608 612 uint32_t ss_file_segmap;
609 613 };
610 614
611 615 /*
612 616 * A single sendfile request is represented by snf_req.
613 617 */
614 618 typedef struct snf_req {
615 619 struct snf_req *sr_next;
616 620 mblk_t *sr_mp_head;
617 621 mblk_t *sr_mp_tail;
618 622 kmutex_t sr_lock;
619 623 kcondvar_t sr_cv;
620 624 uint_t sr_qlen;
621 625 int sr_hiwat;
622 626 int sr_lowat;
623 627 int sr_operation;
624 628 struct vnode *sr_vp;
625 629 file_t *sr_fp;
626 630 ssize_t sr_maxpsz;
627 631 u_offset_t sr_file_off;
628 632 u_offset_t sr_file_size;
629 633 #define SR_READ_DONE 0x80000000
630 634 int sr_read_error;
631 635 int sr_write_error;
632 636 } snf_req_t;
633 637
634 638 /* A queue of sendfile requests */
635 639 struct sendfile_queue {
636 640 snf_req_t *snfq_req_head;
637 641 snf_req_t *snfq_req_tail;
638 642 kmutex_t snfq_lock;
639 643 kcondvar_t snfq_cv;
640 644 int snfq_svc_threads; /* # of service threads */
641 645 int snfq_idle_cnt; /* # of idling threads */
642 646 int snfq_max_threads;
643 647 int snfq_req_cnt; /* Number of requests */
644 648 };
645 649
646 650 #define READ_OP 1
647 651 #define SNFQ_TIMEOUT (60 * 5 * hz) /* 5 minutes */
648 652
649 653 /* Socket network operations switch */
650 654 struct sonodeops {
651 655 int (*sop_init)(struct sonode *, struct sonode *, cred_t *,
652 656 int);
653 657 int (*sop_accept)(struct sonode *, int, cred_t *, struct sonode **);
654 658 int (*sop_bind)(struct sonode *, struct sockaddr *, socklen_t,
655 659 int, cred_t *);
656 660 int (*sop_listen)(struct sonode *, int, cred_t *);
657 661 int (*sop_connect)(struct sonode *, struct sockaddr *,
658 662 socklen_t, int, int, cred_t *);
659 663 int (*sop_recvmsg)(struct sonode *, struct msghdr *,
660 664 struct uio *, cred_t *);
661 665 int (*sop_sendmsg)(struct sonode *, struct msghdr *,
662 666 struct uio *, cred_t *);
663 667 int (*sop_sendmblk)(struct sonode *, struct msghdr *, int,
664 668 cred_t *, mblk_t **);
665 669 int (*sop_getpeername)(struct sonode *, struct sockaddr *,
666 670 socklen_t *, boolean_t, cred_t *);
667 671 int (*sop_getsockname)(struct sonode *, struct sockaddr *,
668 672 socklen_t *, cred_t *);
669 673 int (*sop_shutdown)(struct sonode *, int, cred_t *);
670 674 int (*sop_getsockopt)(struct sonode *, int, int, void *,
671 675 socklen_t *, int, cred_t *);
672 676 int (*sop_setsockopt)(struct sonode *, int, int, const void *,
673 677 socklen_t, cred_t *);
674 678 int (*sop_ioctl)(struct sonode *, int, intptr_t, int,
675 679 cred_t *, int32_t *);
676 680 int (*sop_poll)(struct sonode *, short, int, short *,
677 681 struct pollhead **);
678 682 int (*sop_close)(struct sonode *, int, cred_t *);
679 683 };
680 684
681 685 #define SOP_INIT(so, flag, cr, flags) \
682 686 ((so)->so_ops->sop_init((so), (flag), (cr), (flags)))
683 687 #define SOP_ACCEPT(so, fflag, cr, nsop) \
684 688 ((so)->so_ops->sop_accept((so), (fflag), (cr), (nsop)))
685 689 #define SOP_BIND(so, name, namelen, flags, cr) \
686 690 ((so)->so_ops->sop_bind((so), (name), (namelen), (flags), (cr)))
687 691 #define SOP_LISTEN(so, backlog, cr) \
688 692 ((so)->so_ops->sop_listen((so), (backlog), (cr)))
689 693 #define SOP_CONNECT(so, name, namelen, fflag, flags, cr) \
690 694 ((so)->so_ops->sop_connect((so), (name), (namelen), (fflag), (flags), \
691 695 (cr)))
692 696 #define SOP_RECVMSG(so, msg, uiop, cr) \
693 697 ((so)->so_ops->sop_recvmsg((so), (msg), (uiop), (cr)))
694 698 #define SOP_SENDMSG(so, msg, uiop, cr) \
695 699 ((so)->so_ops->sop_sendmsg((so), (msg), (uiop), (cr)))
696 700 #define SOP_SENDMBLK(so, msg, size, cr, mpp) \
697 701 ((so)->so_ops->sop_sendmblk((so), (msg), (size), (cr), (mpp)))
698 702 #define SOP_GETPEERNAME(so, addr, addrlen, accept, cr) \
699 703 ((so)->so_ops->sop_getpeername((so), (addr), (addrlen), (accept), (cr)))
700 704 #define SOP_GETSOCKNAME(so, addr, addrlen, cr) \
701 705 ((so)->so_ops->sop_getsockname((so), (addr), (addrlen), (cr)))
702 706 #define SOP_SHUTDOWN(so, how, cr) \
703 707 ((so)->so_ops->sop_shutdown((so), (how), (cr)))
704 708 #define SOP_GETSOCKOPT(so, level, optionname, optval, optlenp, flags, cr) \
705 709 ((so)->so_ops->sop_getsockopt((so), (level), (optionname), \
706 710 (optval), (optlenp), (flags), (cr)))
707 711 #define SOP_SETSOCKOPT(so, level, optionname, optval, optlen, cr) \
708 712 ((so)->so_ops->sop_setsockopt((so), (level), (optionname), \
709 713 (optval), (optlen), (cr)))
710 714 #define SOP_IOCTL(so, cmd, arg, mode, cr, rvalp) \
711 715 ((so)->so_ops->sop_ioctl((so), (cmd), (arg), (mode), (cr), (rvalp)))
712 716 #define SOP_POLL(so, events, anyyet, reventsp, phpp) \
713 717 ((so)->so_ops->sop_poll((so), (events), (anyyet), (reventsp), (phpp)))
714 718 #define SOP_CLOSE(so, flag, cr) \
715 719 ((so)->so_ops->sop_close((so), (flag), (cr)))
716 720
717 721 #endif /* defined(_KERNEL) || defined(_KMEMUSER) */
718 722
719 723 #ifdef _KERNEL
720 724
721 725 #define ISALIGNED_cmsghdr(addr) \
722 726 (((uintptr_t)(addr) & (_CMSG_HDR_ALIGNMENT - 1)) == 0)
723 727
724 728 #define ROUNDUP_cmsglen(len) \
725 729 (((len) + _CMSG_HDR_ALIGNMENT - 1) & ~(_CMSG_HDR_ALIGNMENT - 1))
726 730
727 731 #define IS_NON_STREAM_SOCK(vp) \
728 732 ((vp)->v_type == VSOCK && (vp)->v_stream == NULL)
729 733 /*
730 734 * Macros that operate on struct cmsghdr.
731 735 * Used in parsing msg_control.
732 736 * The CMSG_VALID macro does not assume that the last option buffer is padded.
733 737 */
734 738 #define CMSG_NEXT(cmsg) \
735 739 (struct cmsghdr *)((uintptr_t)(cmsg) + \
736 740 ROUNDUP_cmsglen((cmsg)->cmsg_len))
737 741 #define CMSG_CONTENT(cmsg) (&((cmsg)[1]))
738 742 #define CMSG_CONTENTLEN(cmsg) ((cmsg)->cmsg_len - sizeof (struct cmsghdr))
739 743 #define CMSG_VALID(cmsg, start, end) \
740 744 (ISALIGNED_cmsghdr(cmsg) && \
741 745 ((uintptr_t)(cmsg) >= (uintptr_t)(start)) && \
742 746 ((uintptr_t)(cmsg) < (uintptr_t)(end)) && \
743 747 ((ssize_t)(cmsg)->cmsg_len >= sizeof (struct cmsghdr)) && \
744 748 ((uintptr_t)(cmsg) + (cmsg)->cmsg_len <= (uintptr_t)(end)))
745 749
746 750 /*
747 751 * Maximum size of any argument that is copied in (addresses, options,
748 752 * access rights). MUST be at least MAXPATHLEN + 3.
749 753 * BSD and SunOS 4.X limited this to MLEN or MCLBYTES.
750 754 */
751 755 #define SO_MAXARGSIZE 8192
752 756
753 757 /*
754 758 * Convert between vnode and sonode
755 759 */
756 760 #define VTOSO(vp) ((struct sonode *)((vp)->v_data))
757 761 #define SOTOV(sp) ((sp)->so_vnode)
758 762
759 763 /*
760 764 * Internal flags for sobind()
761 765 */
762 766 #define _SOBIND_REBIND 0x01 /* Bind to existing local address */
763 767 #define _SOBIND_UNSPEC 0x02 /* Bind to unspecified address */
764 768 #define _SOBIND_LOCK_HELD 0x04 /* so_excl_lock held by caller */
765 769 #define _SOBIND_NOXLATE 0x08 /* No addr translation for AF_UNIX */
766 770 #define _SOBIND_XPG4_2 0x10 /* xpg4.2 semantics */
767 771 #define _SOBIND_SOCKBSD 0x20 /* BSD semantics */
768 772 #define _SOBIND_LISTEN 0x40 /* Make into SS_ACCEPTCONN */
769 773 #define _SOBIND_SOCKETPAIR 0x80 /* Internal flag for so_socketpair() */
770 774 /* to enable listen with backlog = 1 */
771 775
772 776 /*
773 777 * Internal flags for sounbind()
774 778 */
775 779 #define _SOUNBIND_REBIND 0x01 /* Don't clear fields - will rebind */
776 780
777 781 /*
778 782 * Internal flags for soconnect()
779 783 */
780 784 #define _SOCONNECT_NOXLATE 0x01 /* No addr translation for AF_UNIX */
781 785 #define _SOCONNECT_DID_BIND 0x02 /* Unbind when connect fails */
782 786 #define _SOCONNECT_XPG4_2 0x04 /* xpg4.2 semantics */
783 787
784 788 /*
785 789 * Internal flags for sodisconnect()
786 790 */
787 791 #define _SODISCONNECT_LOCK_HELD 0x01 /* so_excl_lock held by caller */
788 792
789 793 /*
790 794 * Internal flags for sotpi_getsockopt().
791 795 */
792 796 #define _SOGETSOCKOPT_XPG4_2 0x01 /* xpg4.2 semantics */
793 797
794 798 /*
795 799 * Internal flags for soallocproto*()
796 800 */
797 801 #define _ALLOC_NOSLEEP 0 /* Don't sleep for memory */
798 802 #define _ALLOC_INTR 1 /* Sleep until interrupt */
799 803 #define _ALLOC_SLEEP 2 /* Sleep forever */
800 804
801 805 /*
802 806 * Internal structure for handling AF_UNIX file descriptor passing
803 807 */
804 808 struct fdbuf {
805 809 int fd_size; /* In bytes, for kmem_free */
806 810 int fd_numfd; /* Number of elements below */
807 811 char *fd_ebuf; /* Extra buffer to free */
808 812 int fd_ebuflen;
809 813 frtn_t fd_frtn;
810 814 struct file *fd_fds[1]; /* One or more */
811 815 };
812 816 #define FDBUF_HDRSIZE (sizeof (struct fdbuf) - sizeof (struct file *))
813 817
814 818 /*
815 819 * Variable that can be patched to set what version of socket socket()
816 820 * will create.
817 821 */
818 822 extern int so_default_version;
819 823
820 824 #ifdef DEBUG
821 825 /* Turn on extra testing capabilities */
822 826 #define SOCK_TEST
823 827 #endif /* DEBUG */
824 828
825 829 #ifdef DEBUG
826 830 char *pr_state(uint_t, uint_t);
827 831 char *pr_addr(int, struct sockaddr *, t_uscalar_t);
828 832 int so_verify_oobstate(struct sonode *);
829 833 #endif /* DEBUG */
830 834
831 835 /*
832 836 * DEBUG macros
833 837 */
834 838 #if defined(DEBUG)
835 839 #define SOCK_DEBUG
836 840
837 841 extern int sockdebug;
838 842 extern int sockprinterr;
839 843
840 844 #define eprint(args) printf args
841 845 #define eprintso(so, args) \
842 846 { if (sockprinterr && ((so)->so_options & SO_DEBUG)) printf args; }
843 847 #define eprintline(error) \
844 848 { \
845 849 if (error != EINTR && (sockprinterr || sockdebug > 0)) \
846 850 printf("socket error %d: line %d file %s\n", \
847 851 (error), __LINE__, __FILE__); \
848 852 }
849 853
850 854 #define eprintsoline(so, error) \
851 855 { if (sockprinterr && ((so)->so_options & SO_DEBUG)) \
852 856 printf("socket(%p) error %d: line %d file %s\n", \
853 857 (void *)(so), (error), __LINE__, __FILE__); \
854 858 }
855 859 #define dprint(level, args) { if (sockdebug > (level)) printf args; }
856 860 #define dprintso(so, level, args) \
857 861 { if (sockdebug > (level) && ((so)->so_options & SO_DEBUG)) printf args; }
858 862
859 863 #else /* define(DEBUG) */
860 864
861 865 #define eprint(args) {}
862 866 #define eprintso(so, args) {}
863 867 #define eprintline(error) {}
864 868 #define eprintsoline(so, error) {}
865 869 #define dprint(level, args) {}
866 870 #define dprintso(so, level, args) {}
867 871
868 872 #endif /* defined(DEBUG) */
869 873
870 874 extern struct vfsops sock_vfsops;
871 875 extern struct vnodeops *socket_vnodeops;
872 876 extern const struct fs_operation_def socket_vnodeops_template[];
873 877
874 878 extern dev_t sockdev;
875 879
876 880 extern krwlock_t sockconf_lock;
877 881
878 882 /*
879 883 * sockfs functions
880 884 */
881 885 extern int sock_getmsg(vnode_t *, struct strbuf *, struct strbuf *,
882 886 uchar_t *, int *, int, rval_t *);
883 887 extern int sock_putmsg(vnode_t *, struct strbuf *, struct strbuf *,
884 888 uchar_t, int, int);
885 889 extern int sogetvp(char *, vnode_t **, int);
886 890 extern int sockinit(int, char *);
887 891 extern int solookup(int, int, int, struct sockparams **);
888 892 extern void so_lock_single(struct sonode *);
889 893 extern void so_unlock_single(struct sonode *, int);
890 894 extern int so_lock_read(struct sonode *, int);
891 895 extern int so_lock_read_intr(struct sonode *, int);
892 896 extern void so_unlock_read(struct sonode *);
893 897 extern void *sogetoff(mblk_t *, t_uscalar_t, t_uscalar_t, uint_t);
894 898 extern void so_getopt_srcaddr(void *, t_uscalar_t,
895 899 void **, t_uscalar_t *);
896 900 extern int so_getopt_unix_close(void *, t_uscalar_t);
897 901 extern void fdbuf_free(struct fdbuf *);
898 902 extern mblk_t *fdbuf_allocmsg(int, struct fdbuf *);
899 903 extern int fdbuf_create(void *, int, struct fdbuf **);
900 904 extern void so_closefds(void *, t_uscalar_t, int, int);
901 905 extern int so_getfdopt(void *, t_uscalar_t, int, void **, int *);
902 906 t_uscalar_t so_optlen(void *, t_uscalar_t, int);
903 907 extern void so_cmsg2opt(void *, t_uscalar_t, int, mblk_t *);
904 908 extern t_uscalar_t
905 909 so_cmsglen(mblk_t *, void *, t_uscalar_t, int);
906 910 extern int so_opt2cmsg(mblk_t *, void *, t_uscalar_t, int,
907 911 void *, t_uscalar_t);
908 912 extern void soisconnecting(struct sonode *);
909 913 extern void soisconnected(struct sonode *);
910 914 extern void soisdisconnected(struct sonode *, int);
911 915 extern void socantsendmore(struct sonode *);
912 916 extern void socantrcvmore(struct sonode *);
913 917 extern void soseterror(struct sonode *, int);
914 918 extern int sogeterr(struct sonode *, boolean_t);
915 919 extern int sowaitconnected(struct sonode *, int, int);
916 920
917 921 extern ssize_t soreadfile(file_t *, uchar_t *, u_offset_t, int *, size_t);
918 922 extern void *sock_kstat_init(zoneid_t);
919 923 extern void sock_kstat_fini(zoneid_t, void *);
920 924 extern struct sonode *getsonode(int, int *, file_t **);
921 925 /*
922 926 * Function wrappers (mostly around the sonode switch) for
923 927 * backward compatibility.
924 928 */
925 929 extern int soaccept(struct sonode *, int, struct sonode **);
926 930 extern int sobind(struct sonode *, struct sockaddr *, socklen_t,
927 931 int, int);
928 932 extern int solisten(struct sonode *, int);
929 933 extern int soconnect(struct sonode *, struct sockaddr *, socklen_t,
930 934 int, int);
931 935 extern int sorecvmsg(struct sonode *, struct nmsghdr *, struct uio *);
932 936 extern int sosendmsg(struct sonode *, struct nmsghdr *, struct uio *);
933 937 extern int soshutdown(struct sonode *, int);
934 938 extern int sogetsockopt(struct sonode *, int, int, void *, socklen_t *,
935 939 int);
936 940 extern int sosetsockopt(struct sonode *, int, int, const void *,
937 941 t_uscalar_t);
938 942
939 943 extern struct sonode *socreate(struct sockparams *, int, int, int, int,
940 944 int *);
941 945
942 946 extern int so_copyin(const void *, void *, size_t, int);
943 947 extern int so_copyout(const void *, void *, size_t, int);
944 948
945 949 #endif
946 950
947 951 /*
948 952 * Internal structure for obtaining sonode information from the socklist.
949 953 * These types match those corresponding in the sonode structure.
950 954 * This is not a published interface, and may change at any time.
951 955 */
952 956 struct sockinfo {
953 957 uint_t si_size; /* real length of this struct */
954 958 short si_family;
955 959 short si_type;
956 960 ushort_t si_flag;
957 961 uint_t si_state;
958 962 uint_t si_ux_laddr_sou_magic;
959 963 uint_t si_ux_faddr_sou_magic;
960 964 t_scalar_t si_serv_type;
961 965 t_uscalar_t si_laddr_soa_len;
962 966 t_uscalar_t si_faddr_soa_len;
963 967 uint16_t si_laddr_family;
964 968 uint16_t si_faddr_family;
965 969 char si_laddr_sun_path[MAXPATHLEN + 1]; /* NULL terminated */
966 970 char si_faddr_sun_path[MAXPATHLEN + 1];
967 971 boolean_t si_faddr_noxlate;
↓ open down ↓ |
449 lines elided |
↑ open up ↑ |
968 972 zoneid_t si_szoneid;
969 973 };
970 974
971 975 /*
972 976 * Subcodes for sockconf() system call
973 977 */
974 978 #define SOCKCONFIG_ADD_SOCK 0
975 979 #define SOCKCONFIG_REMOVE_SOCK 1
976 980 #define SOCKCONFIG_ADD_FILTER 2
977 981 #define SOCKCONFIG_REMOVE_FILTER 3
982 +#define SOCKCONFIG_GET_SOCKTABLE 4
978 983
979 984 /*
980 985 * Data structures for configuring socket filters.
981 986 */
982 987
983 988 /*
984 989 * Placement hint for automatic filters
985 990 */
986 991 typedef enum {
987 992 SOF_HINT_NONE,
988 993 SOF_HINT_TOP,
989 994 SOF_HINT_BOTTOM,
990 995 SOF_HINT_BEFORE,
991 996 SOF_HINT_AFTER
992 997 } sof_hint_t;
993 998
994 999 /*
995 1000 * Socket tuple. Used by sockconfig_filter_props to list socket
996 1001 * types of interest.
997 1002 */
998 1003 typedef struct sof_socktuple {
999 1004 int sofst_family;
1000 1005 int sofst_type;
1001 1006 int sofst_protocol;
1002 1007 } sof_socktuple_t;
1003 1008
1004 1009 /*
1005 1010 * Socket filter properties used by sockconfig() system call.
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
1006 1011 */
1007 1012 struct sockconfig_filter_props {
1008 1013 char *sfp_modname;
1009 1014 boolean_t sfp_autoattach;
1010 1015 sof_hint_t sfp_hint;
1011 1016 char *sfp_hintarg;
1012 1017 uint_t sfp_socktuple_cnt;
1013 1018 sof_socktuple_t *sfp_socktuple;
1014 1019 };
1015 1020
1021 +/*
1022 + * Data structures for the in-kernel socket configuration table.
1023 + */
1024 +typedef struct sockconfig_socktable_entry {
1025 + int se_family;
1026 + int se_type;
1027 + int se_protocol;
1028 + int se_refcnt;
1029 + int se_flags;
1030 + char se_modname[MODMAXNAMELEN];
1031 + char se_strdev[MAXPATHLEN];
1032 +} sockconfig_socktable_entry_t;
1033 +
1034 +typedef struct sockconfig_socktable {
1035 + uint_t num_of_entries;
1036 + sockconfig_socktable_entry_t *st_entries;
1037 +} sockconfig_socktable_t;
1038 +
1016 1039 #ifdef _SYSCALL32
1017 1040
1018 1041 typedef struct sof_socktuple32 {
1019 1042 int32_t sofst_family;
1020 1043 int32_t sofst_type;
1021 1044 int32_t sofst_protocol;
1022 1045 } sof_socktuple32_t;
1023 1046
1024 1047 struct sockconfig_filter_props32 {
1025 1048 caddr32_t sfp_modname;
1026 1049 boolean_t sfp_autoattach;
1027 1050 sof_hint_t sfp_hint;
1028 1051 caddr32_t sfp_hintarg;
1029 1052 uint32_t sfp_socktuple_cnt;
1030 1053 caddr32_t sfp_socktuple;
1031 1054 };
1032 1055
1056 +typedef struct sockconfig_socktable32 {
1057 + uint_t num_of_entries;
1058 + caddr32_t st_entries;
1059 +} sockconfig_socktable32_t;
1060 +
1033 1061 #endif /* _SYSCALL32 */
1034 1062
1035 1063 #define SOCKMOD_PATH "socketmod" /* dir where sockmods are stored */
1036 1064
1037 1065 #ifdef __cplusplus
1038 1066 }
1039 1067 #endif
1040 1068
1041 1069 #endif /* _SYS_SOCKETVAR_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX