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