1 /*	$NetBSD: socketvar.h,v 1.140 2016/06/01 04:15:54 pgoyette Exp $	*/
2 
3 /*-
4  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Andrew Doran.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /*-
33  * Copyright (c) 1982, 1986, 1990, 1993
34  *	The Regents of the University of California.  All rights reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  * 1. Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  * 2. Redistributions in binary form must reproduce the above copyright
42  *    notice, this list of conditions and the following disclaimer in the
43  *    documentation and/or other materials provided with the distribution.
44  * 3. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  *	@(#)socketvar.h	8.3 (Berkeley) 2/19/95
61  */
62 
63 #ifndef _SYS_SOCKETVAR_H_
64 #define	_SYS_SOCKETVAR_H_
65 
66 #include <sys/select.h>
67 #include <sys/selinfo.h>		/* for struct selinfo */
68 #include <sys/queue.h>
69 #include <sys/mutex.h>
70 #include <sys/condvar.h>
71 
72 #if !defined(_KERNEL)
73 struct uio;
74 struct lwp;
75 struct uidinfo;
76 #else
77 #include <sys/uidinfo.h>
78 #endif
79 
80 TAILQ_HEAD(soqhead, socket);
81 
82 /*
83  * Variables for socket buffering.
84  */
85 struct sockbuf {
86 	struct selinfo sb_sel;		/* process selecting read/write */
87 	struct mowner *sb_mowner;	/* who owns data for this sockbuf */
88 	struct socket *sb_so;		/* back pointer to socket */
89 	kcondvar_t sb_cv;		/* notifier */
90 	/* When re-zeroing this struct, we zero from sb_startzero to the end */
91 #define	sb_startzero	sb_cc
92 	u_long	sb_cc;			/* actual chars in buffer */
93 	u_long	sb_hiwat;		/* max actual char count */
94 	u_long	sb_mbcnt;		/* chars of mbufs used */
95 	u_long	sb_mbmax;		/* max chars of mbufs to use */
96 	long	sb_lowat;		/* low water mark */
97 	struct mbuf *sb_mb;		/* the mbuf chain */
98 	struct mbuf *sb_mbtail;		/* the last mbuf in the chain */
99 	struct mbuf *sb_lastrecord;	/* first mbuf of last record in
100 					   socket buffer */
101 	int	sb_flags;		/* flags, see below */
102 	int	sb_timeo;		/* timeout for read/write */
103 	u_long	sb_overflowed;		/* # of drops due to full buffer */
104 };
105 
106 #ifndef SB_MAX
107 #define	SB_MAX		(256*1024)	/* default for max chars in sockbuf */
108 #endif
109 
110 #define	SB_LOCK		0x01		/* lock on data queue */
111 #define	SB_NOTIFY	0x04		/* someone is waiting for data/space */
112 #define	SB_ASYNC	0x10		/* ASYNC I/O, need signals */
113 #define	SB_UPCALL	0x20		/* someone wants an upcall */
114 #define	SB_NOINTR	0x40		/* operations not interruptible */
115 #define	SB_KNOTE	0x100		/* kernel note attached */
116 #define	SB_AUTOSIZE	0x800		/* automatically size socket buffer */
117 
118 /*
119  * Kernel structure per socket.
120  * Contains send and receive buffer queues,
121  * handle on protocol and pointer to protocol
122  * private data and error information.
123  */
124 struct so_accf {
125 	struct accept_filter	*so_accept_filter;
126 	void	*so_accept_filter_arg;	/* saved filter args */
127 	char	*so_accept_filter_str;	/* saved user args */
128 };
129 
130 struct sockaddr;
131 
132 struct socket {
133 	kmutex_t * volatile so_lock;	/* pointer to lock on structure */
134 	kcondvar_t	so_cv;		/* notifier */
135 	short		so_type;	/* generic type, see socket.h */
136 	short		so_options;	/* from socket call, see socket.h */
137 	u_short		so_linger;	/* time to linger while closing */
138 	short		so_state;	/* internal state flags SS_*, below */
139 	int		so_unused;	/* used to be so_nbio */
140 	void		*so_pcb;	/* protocol control block */
141 	const struct protosw *so_proto;	/* protocol handle */
142 /*
143  * Variables for connection queueing.
144  * Socket where accepts occur is so_head in all subsidiary sockets.
145  * If so_head is 0, socket is not related to an accept.
146  * For head socket so_q0 queues partially completed connections,
147  * while so_q is a queue of connections ready to be accepted.
148  * If a connection is aborted and it has so_head set, then
149  * it has to be pulled out of either so_q0 or so_q.
150  * We allow connections to queue up based on current queue lengths
151  * and limit on number of queued connections for this socket.
152  */
153 	struct socket	*so_head;	/* back pointer to accept socket */
154 	struct soqhead	*so_onq;	/* queue (q or q0) that we're on */
155 	struct soqhead	so_q0;		/* queue of partial connections */
156 	struct soqhead	so_q;		/* queue of incoming connections */
157 	TAILQ_ENTRY(socket) so_qe;	/* our queue entry (q or q0) */
158 	short		so_q0len;	/* partials on so_q0 */
159 	short		so_qlen;	/* number of connections on so_q */
160 	short		so_qlimit;	/* max number queued connections */
161 	short		so_timeo;	/* connection timeout */
162 	u_short		so_error;	/* error affecting connection */
163 	u_short		so_aborting;	/* references from soabort() */
164 	pid_t		so_pgid;	/* pgid for signals */
165 	u_long		so_oobmark;	/* chars to oob mark */
166 	struct sockbuf	so_snd;		/* send buffer */
167 	struct sockbuf	so_rcv;		/* receive buffer */
168 
169 	void		*so_internal;	/* Space for svr4 stream data */
170 	void		(*so_upcall) (struct socket *, void *, int, int);
171 	void *		so_upcallarg;	/* Arg for above */
172 	int		(*so_send) (struct socket *, struct sockaddr *,
173 					struct uio *, struct mbuf *,
174 					struct mbuf *, int, struct lwp *);
175 	int		(*so_receive) (struct socket *,
176 					struct mbuf **,
177 					struct uio *, struct mbuf **,
178 					struct mbuf **, int *);
179 	struct mowner	*so_mowner;	/* who owns mbufs for this socket */
180 	struct uidinfo	*so_uidinfo;	/* who opened the socket */
181 	gid_t		so_egid;	/* creator effective gid */
182 	pid_t		so_cpid;	/* creator pid */
183 	struct so_accf	*so_accf;
184 	kauth_cred_t	so_cred;	/* socket credentials */
185 };
186 
187 /*
188  * Socket state bits.
189  */
190 #define	SS_NOFDREF		0x001	/* no file table ref any more */
191 #define	SS_ISCONNECTED		0x002	/* socket connected to a peer */
192 #define	SS_ISCONNECTING		0x004	/* in process of connecting to peer */
193 #define	SS_ISDISCONNECTING	0x008	/* in process of disconnecting */
194 #define	SS_CANTSENDMORE		0x010	/* can't send more data to peer */
195 #define	SS_CANTRCVMORE		0x020	/* can't receive more data from peer */
196 #define	SS_RCVATMARK		0x040	/* at mark on input */
197 #define	SS_ISABORTING		0x080	/* aborting fd references - close() */
198 #define	SS_RESTARTSYS		0x100	/* restart blocked system calls */
199 #define	SS_ISDISCONNECTED	0x800	/* socket disconnected from peer */
200 
201 #define	SS_ASYNC		0x100	/* async i/o notify */
202 #define	SS_MORETOCOME		0x400	/*
203 					 * hint from sosend to lower layer;
204 					 * more data coming
205 					 */
206 #define	SS_ISAPIPE 		0x1000	/* socket is implementing a pipe */
207 #define	SS_NBIO			0x2000	/* socket is in non blocking I/O */
208 
209 #ifdef _KERNEL
210 
211 struct accept_filter {
212 	char	accf_name[16];
213 	void	(*accf_callback)
214 		(struct socket *, void *, int, int);
215 	void *	(*accf_create)
216 		(struct socket *, char *);
217 	void	(*accf_destroy)
218 		(struct socket *);
219 	LIST_ENTRY(accept_filter) accf_next;
220 	u_int	accf_refcnt;
221 };
222 
223 struct sockopt {
224 	int		sopt_level;		/* option level */
225 	int		sopt_name;		/* option name */
226 	size_t		sopt_size;		/* data length */
227 	void *		sopt_data;		/* data pointer */
228 	uint8_t		sopt_buf[sizeof(int)];	/* internal storage */
229 };
230 
231 #define	SB_EMPTY_FIXUP(sb)						\
232 do {									\
233 	KASSERT(solocked((sb)->sb_so));					\
234 	if ((sb)->sb_mb == NULL) {					\
235 		(sb)->sb_mbtail = NULL;					\
236 		(sb)->sb_lastrecord = NULL;				\
237 	}								\
238 } while (/*CONSTCOND*/0)
239 
240 extern u_long		sb_max;
241 extern int		somaxkva;
242 extern int		sock_loan_thresh;
243 extern kmutex_t		*softnet_lock;
244 
245 struct mbuf;
246 struct lwp;
247 struct msghdr;
248 struct stat;
249 struct knote;
250 
251 struct	mbuf *getsombuf(struct socket *, int);
252 
253 /*
254  * File operations on sockets.
255  */
256 int	soo_read(file_t *, off_t *, struct uio *, kauth_cred_t, int);
257 int	soo_write(file_t *, off_t *, struct uio *, kauth_cred_t, int);
258 int	soo_fcntl(file_t *, u_int cmd, void *);
259 int	soo_ioctl(file_t *, u_long cmd, void *);
260 int	soo_poll(file_t *, int);
261 int	soo_kqfilter(file_t *, struct knote *);
262 int 	soo_close(file_t *);
263 int	soo_stat(file_t *, struct stat *);
264 void	soo_restart(file_t *);
265 void	sbappend(struct sockbuf *, struct mbuf *);
266 void	sbappendstream(struct sockbuf *, struct mbuf *);
267 int	sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
268 	    struct mbuf *);
269 int	sbappendaddrchain(struct sockbuf *, const struct sockaddr *,
270 	     struct mbuf *, int);
271 int	sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *);
272 void	sbappendrecord(struct sockbuf *, struct mbuf *);
273 void	sbcheck(struct sockbuf *);
274 void	sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *);
275 struct mbuf *
276 	sbcreatecontrol(void *, int, int, int);
277 struct mbuf *
278 	sbcreatecontrol1(void **, int, int, int, int);
279 void	sbdrop(struct sockbuf *, int);
280 void	sbdroprecord(struct sockbuf *);
281 void	sbflush(struct sockbuf *);
282 void	sbinsertoob(struct sockbuf *, struct mbuf *);
283 void	sbrelease(struct sockbuf *, struct socket *);
284 int	sbreserve(struct sockbuf *, u_long, struct socket *);
285 int	sbwait(struct sockbuf *);
286 int	sb_max_set(u_long);
287 void	soinit(void);
288 void	soinit1(void);
289 void	soinit2(void);
290 int	soabort(struct socket *);
291 int	soaccept(struct socket *, struct sockaddr *);
292 int	sofamily(const struct socket *);
293 int	sobind(struct socket *, struct sockaddr *, struct lwp *);
294 void	socantrcvmore(struct socket *);
295 void	socantsendmore(struct socket *);
296 int	soclose(struct socket *);
297 int	soconnect(struct socket *, struct sockaddr *, struct lwp *);
298 int	soconnect2(struct socket *, struct socket *);
299 int	socreate(int, struct socket **, int, int, struct lwp *,
300 		 struct socket *);
301 int	fsocreate(int, struct socket **, int, int, int *);
302 int	sodisconnect(struct socket *);
303 void	sofree(struct socket *);
304 int	sogetopt(struct socket *, struct sockopt *);
305 void	sohasoutofband(struct socket *);
306 void	soisconnected(struct socket *);
307 void	soisconnecting(struct socket *);
308 void	soisdisconnected(struct socket *);
309 void	soisdisconnecting(struct socket *);
310 int	solisten(struct socket *, int, struct lwp *);
311 struct socket *
312 	sonewconn(struct socket *, bool);
313 void	soqinsque(struct socket *, struct socket *, int);
314 bool	soqremque(struct socket *, int);
315 int	soreceive(struct socket *, struct mbuf **, struct uio *,
316 	    struct mbuf **, struct mbuf **, int *);
317 int	soreserve(struct socket *, u_long, u_long);
318 void	sorflush(struct socket *);
319 int	sosend(struct socket *, struct sockaddr *, struct uio *,
320 	    struct mbuf *, struct mbuf *, int, struct lwp *);
321 int	sosetopt(struct socket *, struct sockopt *);
322 int	so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t);
323 int	soshutdown(struct socket *, int);
324 void	sorestart(struct socket *);
325 void	sowakeup(struct socket *, struct sockbuf *, int);
326 int	sockargs(struct mbuf **, const void *, size_t, int);
327 int	sopoll(struct socket *, int);
328 struct	socket *soget(bool);
329 void	soput(struct socket *);
330 bool	solocked(struct socket *);
331 bool	solocked2(struct socket *, struct socket *);
332 int	sblock(struct sockbuf *, int);
333 void	sbunlock(struct sockbuf *);
334 int	sowait(struct socket *, bool, int);
335 void	solockretry(struct socket *, kmutex_t *);
336 void	sosetlock(struct socket *);
337 void	solockreset(struct socket *, kmutex_t *);
338 
339 void	sockopt_init(struct sockopt *, int, int, size_t);
340 void	sockopt_destroy(struct sockopt *);
341 int	sockopt_set(struct sockopt *, const void *, size_t);
342 int	sockopt_setint(struct sockopt *, int);
343 int	sockopt_get(const struct sockopt *, void *, size_t);
344 int	sockopt_getint(const struct sockopt *, int *);
345 int	sockopt_setmbuf(struct sockopt *, struct mbuf *);
346 struct mbuf *sockopt_getmbuf(const struct sockopt *);
347 
348 int	copyout_sockname(struct sockaddr *, unsigned int *, int, struct mbuf *);
349 int	copyout_msg_control(struct lwp *, struct msghdr *, struct mbuf *);
350 void	free_control_mbuf(struct lwp *, struct mbuf *, struct mbuf *);
351 
352 int	do_sys_getpeername(int, struct sockaddr *);
353 int	do_sys_getsockname(int, struct sockaddr *);
354 int	do_sys_sendmsg(struct lwp *, int, struct msghdr *, int, register_t *);
355 int	do_sys_recvmsg(struct lwp *, int, struct msghdr *, struct mbuf **,
356 	    struct mbuf **, register_t *);
357 
358 int	do_sys_bind(struct lwp *, int, struct sockaddr *);
359 int	do_sys_connect(struct lwp *, int, struct sockaddr *);
360 int	do_sys_accept(struct lwp *, int, struct sockaddr *, register_t *,
361 	    const sigset_t *, int, int);
362 
363 /*
364  * Inline functions for sockets and socket buffering.
365  */
366 
367 #include <sys/protosw.h>
368 #include <sys/mbuf.h>
369 
370 /*
371  * Do we need to notify the other side when I/O is possible?
372  */
373 static inline int
sb_notify(struct sockbuf * sb)374 sb_notify(struct sockbuf *sb)
375 {
376 
377 	KASSERT(solocked(sb->sb_so));
378 
379 	return sb->sb_flags & (SB_NOTIFY | SB_ASYNC | SB_UPCALL | SB_KNOTE);
380 }
381 
382 /*
383  * How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
384  * This is problematical if the fields are unsigned, as the space might
385  * still be negative (cc > hiwat or mbcnt > mbmax).  Should detect
386  * overflow and return 0.
387  */
388 static inline long
sbspace(struct sockbuf * sb)389 sbspace(struct sockbuf *sb)
390 {
391 
392 	KASSERT(solocked(sb->sb_so));
393 
394 	return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt);
395 }
396 
397 /* do we have to send all at once on a socket? */
398 static inline int
sosendallatonce(struct socket * so)399 sosendallatonce(struct socket *so)
400 {
401 
402 	return so->so_proto->pr_flags & PR_ATOMIC;
403 }
404 
405 /* can we read something from so? */
406 static inline int
soreadable(struct socket * so)407 soreadable(struct socket *so)
408 {
409 
410 	KASSERT(solocked(so));
411 
412 	return so->so_rcv.sb_cc >= so->so_rcv.sb_lowat ||
413 	    (so->so_state & SS_CANTRCVMORE) != 0 ||
414 	    so->so_qlen != 0 || so->so_error != 0;
415 }
416 
417 /* can we write something to so? */
418 static inline int
sowritable(struct socket * so)419 sowritable(struct socket *so)
420 {
421 
422 	KASSERT(solocked(so));
423 
424 	return (sbspace(&so->so_snd) >= so->so_snd.sb_lowat &&
425 	    ((so->so_state & SS_ISCONNECTED) != 0 ||
426 	    (so->so_proto->pr_flags & PR_CONNREQUIRED) == 0)) ||
427 	    (so->so_state & SS_CANTSENDMORE) != 0 ||
428 	    so->so_error != 0;
429 }
430 
431 /* adjust counters in sb reflecting allocation of m */
432 static inline void
sballoc(struct sockbuf * sb,struct mbuf * m)433 sballoc(struct sockbuf *sb, struct mbuf *m)
434 {
435 
436 	KASSERT(solocked(sb->sb_so));
437 
438 	sb->sb_cc += m->m_len;
439 	sb->sb_mbcnt += MSIZE;
440 	if (m->m_flags & M_EXT)
441 		sb->sb_mbcnt += m->m_ext.ext_size;
442 }
443 
444 /* adjust counters in sb reflecting freeing of m */
445 static inline void
sbfree(struct sockbuf * sb,struct mbuf * m)446 sbfree(struct sockbuf *sb, struct mbuf *m)
447 {
448 
449 	KASSERT(solocked(sb->sb_so));
450 
451 	sb->sb_cc -= m->m_len;
452 	sb->sb_mbcnt -= MSIZE;
453 	if (m->m_flags & M_EXT)
454 		sb->sb_mbcnt -= m->m_ext.ext_size;
455 }
456 
457 static inline void
sorwakeup(struct socket * so)458 sorwakeup(struct socket *so)
459 {
460 
461 	KASSERT(solocked(so));
462 
463 	if (sb_notify(&so->so_rcv))
464 		sowakeup(so, &so->so_rcv, POLL_IN);
465 }
466 
467 static inline void
sowwakeup(struct socket * so)468 sowwakeup(struct socket *so)
469 {
470 
471 	KASSERT(solocked(so));
472 
473 	if (sb_notify(&so->so_snd))
474 		sowakeup(so, &so->so_snd, POLL_OUT);
475 }
476 
477 static inline void
solock(struct socket * so)478 solock(struct socket *so)
479 {
480 	kmutex_t *lock;
481 
482 	lock = so->so_lock;
483 	mutex_enter(lock);
484 	if (__predict_false(lock != so->so_lock))
485 		solockretry(so, lock);
486 }
487 
488 static inline void
sounlock(struct socket * so)489 sounlock(struct socket *so)
490 {
491 
492 	mutex_exit(so->so_lock);
493 }
494 
495 #ifdef SOCKBUF_DEBUG
496 /*
497  * SBLASTRECORDCHK: check sb->sb_lastrecord is maintained correctly.
498  * SBLASTMBUFCHK: check sb->sb_mbtail is maintained correctly.
499  *
500  * => panic if the socket buffer is inconsistent.
501  * => 'where' is used for a panic message.
502  */
503 void	sblastrecordchk(struct sockbuf *, const char *);
504 #define	SBLASTRECORDCHK(sb, where)	sblastrecordchk((sb), (where))
505 
506 void	sblastmbufchk(struct sockbuf *, const char *);
507 #define	SBLASTMBUFCHK(sb, where)	sblastmbufchk((sb), (where))
508 #define	SBCHECK(sb)			sbcheck(sb)
509 #else
510 #define	SBLASTRECORDCHK(sb, where)	/* nothing */
511 #define	SBLASTMBUFCHK(sb, where)	/* nothing */
512 #define	SBCHECK(sb)			/* nothing */
513 #endif /* SOCKBUF_DEBUG */
514 
515 /* sosend loan */
516 vaddr_t	sokvaalloc(vaddr_t, vsize_t, struct socket *);
517 void	sokvafree(vaddr_t, vsize_t);
518 void	soloanfree(struct mbuf *, void *, size_t, void *);
519 
520 /*
521  * Values for socket-buffer-append priority argument to sbappendaddrchain().
522  * The following flags are reserved for future implementation:
523  *
524  *  SB_PRIO_NONE:  honour normal socket-buffer limits.
525  *
526  *  SB_PRIO_ONESHOT_OVERFLOW:  if the socket has any space,
527  *	deliver the entire chain. Intended for large requests
528  *      that should be delivered in their entirety, or not at all.
529  *
530  * SB_PRIO_OVERDRAFT:  allow a small (2*MLEN) overflow, over and
531  *	aboce normal socket limits. Intended messages indicating
532  *      buffer overflow in earlier normal/lower-priority messages .
533  *
534  * SB_PRIO_BESTEFFORT: Ignore  limits entirely.  Intended only for
535  * 	kernel-generated messages to specially-marked scokets which
536  *	require "reliable" delivery, nd where the source socket/protocol
537  *	message generator enforce some hard limit (but possibly well
538  *	above kern.sbmax). It is entirely up to the in-kernel source to
539  *	avoid complete mbuf exhaustion or DoS scenarios.
540  */
541 #define SB_PRIO_NONE 	 	0
542 #define SB_PRIO_ONESHOT_OVERFLOW 1
543 #define SB_PRIO_OVERDRAFT	2
544 #define SB_PRIO_BESTEFFORT	3
545 
546 /*
547  * Accept filter functions (duh).
548  */
549 int	accept_filt_getopt(struct socket *, struct sockopt *);
550 int	accept_filt_setopt(struct socket *, const struct sockopt *);
551 int	accept_filt_clear(struct socket *);
552 int	accept_filt_add(struct accept_filter *);
553 int	accept_filt_del(struct accept_filter *);
554 struct	accept_filter *accept_filt_get(char *);
555 #ifdef ACCEPT_FILTER_MOD
556 #ifdef SYSCTL_DECL
557 SYSCTL_DECL(_net_inet_accf);
558 #endif
559 void	accept_filter_init(void);
560 #endif
561 
562 #endif /* _KERNEL */
563 
564 #endif /* !_SYS_SOCKETVAR_H_ */
565