| 1 | /*	$OpenBSD: socketvar.h,v 1.160 2025/10/24 15:09:56 bluhm Exp $	*/ |
| 2 | /*	$NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $	*/ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1982, 1986, 1990, 1993 |
| 6 | *	The Regents of the University of California. All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the name of the University nor the names of its contributors |
| 17 | * may be used to endorse or promote products derived from this software |
| 18 | * without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | * SUCH DAMAGE. |
| 31 | * |
| 32 | *	@(#)socketvar.h	8.1 (Berkeley) 6/2/93 |
| 33 | */ |
| 34 | |
| 35 | #ifndef _SYS_SOCKETVAR_H_ |
| 36 | #define _SYS_SOCKETVAR_H_ |
| 37 | |
| 38 | #include <sys/event.h> |
| 39 | #include <sys/queue.h> |
| 40 | #include <sys/sigio.h>				/* for struct sigio_ref */ |
| 41 | #include <sys/task.h> |
| 42 | #include <sys/timeout.h> |
| 43 | #include <sys/mutex.h> |
| 44 | #include <sys/rwlock.h> |
| 45 | #include <sys/refcnt.h> |
| 46 | |
| 47 | #ifndef	_SOCKLEN_T_DEFINED_ |
| 48 | #define	_SOCKLEN_T_DEFINED_ |
| 49 | typedef	__socklen_t	socklen_t;	/* length type for network syscalls */ |
| 50 | #endif |
| 51 | |
| 52 | TAILQ_HEAD(soqhead, socket); |
| 53 | |
| 54 | /* |
| 55 | * Locks used to protect global data and struct members: |
| 56 | *	I	immutable after creation |
| 57 | *	a	atomic |
| 58 | *	mr	sb_mxt of so_rcv buffer |
| 59 | *	ms	sb_mtx of so_snd buffer |
| 60 | *	m	sb_mtx |
| 61 | *	br	sblock() of so_rcv buffer |
| 62 | *	bs	sblock() od so_snd buffer |
| 63 | *	s	solock() |
| 64 | */ |
| 65 | |
| 66 | /* |
| 67 | * Variables for socket splicing, allocated only when needed. |
| 68 | */ |
| 69 | struct sosplice { |
| 70 | 	struct	socket *ssp_socket;	/* [mr ms] send data to drain socket */ |
| 71 | 	struct	socket *ssp_soback;	/* [ms ms] back ref to source socket */ |
| 72 | 	off_t	ssp_len;		/* [mr] number of bytes spliced */ |
| 73 | 	off_t	ssp_max;		/* [I] maximum number of bytes */ |
| 74 | 	struct	timeval ssp_idletv;	/* [I] idle timeout */ |
| 75 | 	struct	timeout ssp_idleto; |
| 76 | 	struct	task ssp_task;		/* task for somove */ |
| 77 | 	struct	taskq *ssp_queue;	/* [I] softnet queue where we add */ |
| 78 | }; |
| 79 | |
| 80 | /* |
| 81 | * Variables for socket buffering. |
| 82 | */ |
| 83 | struct sockbuf { |
| 84 | 	struct rwlock sb_lock; |
| 85 | 	struct mutex sb_mtx; |
| 86 | /* The following fields are all zeroed on flush. */ |
| 87 | #define	sb_startzero	sb_cc |
| 88 | 	u_long	sb_cc;			/* [m] actual chars in buffer */ |
| 89 | 	u_long	sb_datacc;		/* [m] data only chars in buffer */ |
| 90 | 	u_long	sb_hiwat;		/* [m] max actual char count */ |
| 91 | 	u_long sb_wat;			/* [m] default watermark */ |
| 92 | 	u_long	sb_mbcnt;		/* [m] chars of mbufs used */ |
| 93 | 	u_long	sb_mbmax;		/* [m] max chars of mbufs to use */ |
| 94 | 	long	sb_lowat;		/* [m] low water mark */ |
| 95 | 	struct mbuf *sb_mb;		/* [m] the mbuf chain */ |
| 96 | 	struct mbuf *sb_mbtail;		/* [m] the last mbuf in the chain */ |
| 97 | 	struct mbuf *sb_lastrecord;	/* [m] first mbuf of last record in |
| 98 | 					 socket buffer */ |
| 99 | 	short	sb_flags;		/* [m] flags, see below */ |
| 100 | /* End area that is zeroed on flush. */ |
| 101 | #define	sb_endzero	sb_flags |
| 102 | 	short	sb_state;		/* [m] socket state on sockbuf */ |
| 103 | 	uint64_t sb_timeo_nsecs;	/* [m] timeout for read/write */ |
| 104 | 	struct klist sb_klist;		/* [m] list of knotes */ |
| 105 | }; |
| 106 | |
| 107 | #define SB_MAX		(2*1024*1024)	/* default for max chars in sockbuf */ |
| 108 | #define SB_WAIT		0x0001		/* someone is waiting for data/space */ |
| 109 | #define SB_ASYNC	0x0002		/* ASYNC I/O, need signals */ |
| 110 | #define SB_SPLICE	0x0004		/* buffer is splice source or drain */ |
| 111 | #define SB_NOINTR	0x0008		/* operations not interruptible */ |
| 112 | |
| 113 | /* |
| 114 | * Kernel structure per socket. |
| 115 | * Contains send and receive buffer queues, |
| 116 | * handle on protocol and pointer to protocol |
| 117 | * private data and error information. |
| 118 | */ |
| 119 | struct socket { |
| 120 | 	const struct protosw *so_proto;	/* [I] protocol handle */ |
| 121 | 	struct rwlock so_lock;		/* this socket lock */ |
| 122 | 	struct refcnt so_refcnt;	/* references to this socket */ |
| 123 | 	void	*so_pcb;		/* [s] protocol control block */ |
| 124 | 	u_int	so_state;		/* [s] internal state flags SS_*, |
| 125 | 					 see below */ |
| 126 | 	short	so_type;		/* [I] generic type, see socket.h */ |
| 127 | 	short	so_options;		/* [s] from socket call, see |
| 128 | 					 socket.h */ |
| 129 | 	short	so_linger;		/* [s] time to linger while closing */ |
| 130 | /* |
| 131 | * Variables for connection queueing. |
| 132 | * Socket where accepts occur is so_head in all subsidiary sockets. |
| 133 | * If so_head is 0, socket is not related to an accept. |
| 134 | * For head socket so_q0 queues partially completed connections, |
| 135 | * while so_q is a queue of connections ready to be accepted. |
| 136 | * If a connection is aborted and it has so_head set, then |
| 137 | * it has to be pulled out of either so_q0 or so_q. |
| 138 | * We allow connections to queue up based on current queue lengths |
| 139 | * and limit on number of queued connections for this socket. |
| 140 | * |
| 141 | * Connections queue relies on both socket locks of listening and |
| 142 | * unaccepted sockets. Socket lock of listening socket should be |
| 143 | * always taken first. |
| 144 | */ |
| 145 | 	struct	socket	*so_head;	/* [s] back pointer to accept socket */ |
| 146 | 	struct	soqhead	*so_onq;	/* [s] queue (q or q0) that we're on */ |
| 147 | 	struct	soqhead	so_q0;		/* [s] queue of partial connections */ |
| 148 | 	struct	soqhead	so_q;		/* [s] queue of incoming connections */ |
| 149 | 	struct	sigio_ref so_sigio;	/* async I/O registration */ |
| 150 | 	TAILQ_ENTRY(socket) so_qe;	/* [s] our queue entry (q or q0) */ |
| 151 | 	short	so_q0len;		/* [s] partials on so_q0 */ |
| 152 | 	short	so_qlen;		/* [s] number of connections on so_q */ |
| 153 | 	short	so_qlimit;		/* [s] max number queued connections */ |
| 154 | 	short	so_timeo;		/* [s] connection timeout */ |
| 155 | 	u_long	so_oobmark;		/* [mr] chars to oob mark */ |
| 156 | 	u_int	so_error;		/* [a] error affecting connection */ |
| 157 | |
| 158 | 	struct sosplice *so_sp;		/* [s br] */ |
| 159 | |
| 160 | 	struct sockbuf so_rcv; |
| 161 | 	struct sockbuf so_snd; |
| 162 | |
| 163 | 	void	(*so_upcall)(struct socket *, caddr_t, int); /* [s] */ |
| 164 | 	caddr_t	so_upcallarg;		/* [s] Arg for above */ |
| 165 | 	uid_t	so_euid;		/* [I] who opened the socket */ |
| 166 | 	uid_t	so_ruid;		/* [I] */ |
| 167 | 	gid_t	so_egid;		/* [I] */ |
| 168 | 	gid_t	so_rgid;		/* [I] */ |
| 169 | 	pid_t	so_cpid;		/* [I] pid of process that opened |
| 170 | 					 socket */ |
| 171 | }; |
| 172 | |
| 173 | /* |
| 174 | * Socket state bits. |
| 175 | * |
| 176 | * NOTE: The following states should be used with corresponding socket's |
| 177 | * buffer `sb_state' only: |
| 178 | * |
| 179 | *	SS_CANTSENDMORE		with `so_snd' |
| 180 | *	SS_ISSENDING		with `so_snd' |
| 181 | *	SS_CANTRCVMORE		with `so_rcv' |
| 182 | *	SS_RCVATMARK		with `so_rcv' |
| 183 | */ |
| 184 | |
| 185 | #define	SS_NOFDREF		0x001	/* no file table ref any more */ |
| 186 | #define	SS_ISCONNECTED		0x002	/* socket connected to a peer */ |
| 187 | #define	SS_ISCONNECTING		0x004	/* in process of connecting to peer */ |
| 188 | #define	SS_ISDISCONNECTING	0x008	/* in process of disconnecting */ |
| 189 | #define	SS_CANTSENDMORE		0x010	/* can't send more data to peer */ |
| 190 | #define	SS_CANTRCVMORE		0x020	/* can't receive more data from peer */ |
| 191 | #define	SS_RCVATMARK		0x040	/* at mark on input */ |
| 192 | #define	SS_ISDISCONNECTED	0x800	/* socket disconnected from peer */ |
| 193 | |
| 194 | #define	SS_PRIV			0x080	/* privileged for broadcast, raw... */ |
| 195 | #define	SS_CONNECTOUT		0x1000	/* connect, not accept, at this end */ |
| 196 | #define	SS_ISSENDING		0x2000	/* hint for lower layer */ |
| 197 | #define	SS_DNS			0x4000	/* created using SOCK_DNS socket(2) */ |
| 198 | #define	SS_YP			0x8000	/* created using ypconnect(2) */ |
| 199 | |
| 200 | #ifdef _KERNEL |
| 201 | |
| 202 | #include <sys/protosw.h> |
| 203 | #include <lib/libkern/libkern.h> |
| 204 | |
| 205 | struct mbuf; |
| 206 | struct sockaddr; |
| 207 | struct proc; |
| 208 | struct msghdr; |
| 209 | struct stat; |
| 210 | struct knote; |
| 211 | |
| 212 | void	soassertlocked(struct socket *); |
| 213 | void	soassertlocked_readonly(struct socket *); |
| 214 | void	sbmtxassertlocked(struct sockbuf *); |
| 215 | |
| 216 | int	soo_read(struct file *, struct uio *, int); |
| 217 | int	soo_write(struct file *, struct uio *, int); |
| 218 | int	soo_ioctl(struct file *, u_long, caddr_t, struct proc *); |
| 219 | int	soo_kqfilter(struct file *, struct knote *); |
| 220 | int	soo_close(struct file *, struct proc *); |
| 221 | int	soo_stat(struct file *, struct stat *, struct proc *); |
| 222 | void	sbappend(struct sockbuf *, struct mbuf *); |
| 223 | void	sbappendstream(struct sockbuf *, struct mbuf *); |
| 224 | int	sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *, |
| 225 | 	 struct mbuf *); |
| 226 | int	sbappendcontrol(struct sockbuf *, struct mbuf *, struct mbuf *); |
| 227 | void	sbappendrecord(struct sockbuf *, struct mbuf *); |
| 228 | void	sbcompress(struct sockbuf *, struct mbuf *, struct mbuf *); |
| 229 | struct mbuf * |
| 230 | 	sbcreatecontrol(const void *, size_t, int, int); |
| 231 | void	sbdrop(struct sockbuf *, int); |
| 232 | void	sbdroprecord(struct sockbuf *); |
| 233 | void	sbflush(struct sockbuf *); |
| 234 | void	sbrelease(struct sockbuf *); |
| 235 | int	sbcheckreserve(u_long, u_long); |
| 236 | int	sbchecklowmem(void); |
| 237 | int	sbreserve(struct sockbuf *, u_long); |
| 238 | int	sbwait(struct sockbuf *); |
| 239 | void	soinit(void); |
| 240 | void	soabort(struct socket *); |
| 241 | int	soaccept(struct socket *, struct mbuf *); |
| 242 | int	sobind(struct socket *, struct mbuf *, struct proc *); |
| 243 | void	socantrcvmore(struct socket *); |
| 244 | void	socantsendmore(struct socket *); |
| 245 | int	soclose(struct socket *, int); |
| 246 | int	soconnect(struct socket *, struct mbuf *); |
| 247 | int	soconnect2(struct socket *, struct socket *); |
| 248 | int	socreate(int, struct socket **, int, int); |
| 249 | int	sodisconnect(struct socket *); |
| 250 | struct socket *soalloc(const struct protosw *, int); |
| 251 | void	sofree(struct socket *, int); |
| 252 | void	sorele(struct socket *); |
| 253 | int	sogetopt(struct socket *, int, int, struct mbuf *); |
| 254 | void	sohasoutofband(struct socket *); |
| 255 | void	soisconnected(struct socket *); |
| 256 | void	soisconnecting(struct socket *); |
| 257 | void	soisdisconnected(struct socket *); |
| 258 | void	soisdisconnecting(struct socket *); |
| 259 | int	solisten(struct socket *, int); |
| 260 | struct socket *sonewconn(struct socket *, int, int); |
| 261 | void	soqinsque(struct socket *, struct socket *, int); |
| 262 | int	soqremque(struct socket *, int); |
| 263 | int	soreceive(struct socket *, struct mbuf **, struct uio *, |
| 264 | 	 struct mbuf **, struct mbuf **, int *, socklen_t); |
| 265 | int	soreserve(struct socket *, u_long, u_long); |
| 266 | int	sosend(struct socket *, struct mbuf *, struct uio *, |
| 267 | 	 struct mbuf *, struct mbuf *, int); |
| 268 | int	sosetopt(struct socket *, int, int, struct mbuf *); |
| 269 | int	soshutdown(struct socket *, int); |
| 270 | void	sowakeup(struct socket *, struct sockbuf *); |
| 271 | void	sorwakeup(struct socket *); |
| 272 | void	sowwakeup(struct socket *); |
| 273 | int	sockargs(struct mbuf **, const void *, size_t, int); |
| 274 | |
| 275 | int	sosleep_nsec(struct socket *, void *, int, const char *, uint64_t); |
| 276 | void	solock(struct socket *); |
| 277 | void	solock_shared(struct socket *); |
| 278 | void	solock_nonet(struct socket *); |
| 279 | int	solock_persocket(struct socket *); |
| 280 | void	solock_pair(struct socket *, struct socket *); |
| 281 | void	sounlock(struct socket *); |
| 282 | void	sounlock_shared(struct socket *); |
| 283 | void	sounlock_nonet(struct socket *); |
| 284 | void	sounlock_pair(struct socket *, struct socket *); |
| 285 | |
| 286 | int	sendit(struct proc *, int, struct msghdr *, int, register_t *); |
| 287 | int	recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *); |
| 288 | int	doaccept(struct proc *, int, struct sockaddr *, socklen_t *, int, |
| 289 | 	 register_t *); |
| 290 | |
| 291 | #ifdef SOCKBUF_DEBUG |
| 292 | void	sblastrecordchk(struct sockbuf *, const char *); |
| 293 | #define	SBLASTRECORDCHK(sb, where)	sblastrecordchk((sb), (where)) |
| 294 | |
| 295 | void	sblastmbufchk(struct sockbuf *, const char *); |
| 296 | #define	SBLASTMBUFCHK(sb, where)	sblastmbufchk((sb), (where)) |
| 297 | void	sbcheck(struct socket *, struct sockbuf *); |
| 298 | #define	SBCHECK(so, sb)			sbcheck((so), (sb)) |
| 299 | #else |
| 300 | #define	SBLASTRECORDCHK(sb, where)	/* nothing */ |
| 301 | #define	SBLASTMBUFCHK(sb, where)	/* nothing */ |
| 302 | #define	SBCHECK(so, sb)			/* nothing */ |
| 303 | #endif /* SOCKBUF_DEBUG */ |
| 304 | |
| 305 | /* |
| 306 | * Flags to sblock() |
| 307 | */ |
| 308 | #define SBL_WAIT	0x01	/* Wait if lock not immediately available. */ |
| 309 | #define SBL_NOINTR	0x02	/* Enforce non-interruptible sleep. */ |
| 310 | |
| 311 | int	sblock(struct sockbuf *, int); |
| 312 | void	sbunlock(struct sockbuf *); |
| 313 | |
| 314 | extern u_long		sb_max; |
| 315 | extern struct pool	socket_pool; |
| 316 | |
| 317 | static inline struct socket * |
| 318 | soref(struct socket *so) |
| 319 | { |
| 320 | 	if (so == NULL) |
| 321 | 		return NULL; |
| 322 | 	refcnt_take(&so->so_refcnt); |
| 323 | 	return so; |
| 324 | } |
| 325 | |
| 326 | /* |
| 327 | * Macros for sockets and socket buffering. |
| 328 | */ |
| 329 | |
| 330 | #define isspliced(so)		((so)->so_sp && (so)->so_sp->ssp_socket) |
| 331 | #define issplicedback(so)	((so)->so_sp && (so)->so_sp->ssp_soback) |
| 332 | |
| 333 | /* |
| 334 | * Do we need to notify the other side when I/O is possible? |
| 335 | */ |
| 336 | static inline int |
| 337 | sb_notify(struct sockbuf *sb) |
| 338 | { |
| 339 | 	int rv; |
| 340 | |
| 341 | 	mtx_enter(&sb->sb_mtx); |
| 342 | 	rv = ((sb->sb_flags & (SB_WAIT|SB_ASYNC|SB_SPLICE)) != 0 || |
| 343 | 	 !klist_empty(&sb->sb_klist)); |
| 344 | 	mtx_leave(&sb->sb_mtx); |
| 345 | |
| 346 | 	return rv; |
| 347 | } |
| 348 | |
| 349 | /* |
| 350 | * How much space is there in a socket buffer (so->so_snd or so->so_rcv)? |
| 351 | * This is problematical if the fields are unsigned, as the space might |
| 352 | * still be negative (cc > hiwat or mbcnt > mbmax). Should detect |
| 353 | * overflow and return 0. |
| 354 | */ |
| 355 | |
| 356 | static inline long |
| 357 | sbspace_locked(struct sockbuf *sb) |
| 358 | { |
| 359 | 	sbmtxassertlocked(sb); |
| 360 | |
| 361 | 	return lmin(sb->sb_hiwat - sb->sb_cc, sb->sb_mbmax - sb->sb_mbcnt); |
| 362 | } |
| 363 | |
| 364 | static inline long |
| 365 | sbspace(struct sockbuf *sb) |
| 366 | { |
| 367 | 	long ret; |
| 368 | |
| 369 | 	mtx_enter(&sb->sb_mtx); |
| 370 | 	ret = sbspace_locked(sb); |
| 371 | 	mtx_leave(&sb->sb_mtx); |
| 372 | |
| 373 | 	return ret; |
| 374 | } |
| 375 | |
| 376 | /* do we have to send all at once on a socket? */ |
| 377 | #define	sosendallatonce(so) \ |
| 378 | ((so)->so_proto->pr_flags & PR_ATOMIC) |
| 379 | |
| 380 | /* are we sending on this socket? */ |
| 381 | #define	soissending(so) \ |
| 382 | ((so)->so_snd.sb_state & SS_ISSENDING) |
| 383 | |
| 384 | /* can we read something from so? */ |
| 385 | static inline int |
| 386 | soreadable(struct socket *so) |
| 387 | { |
| 388 | 	soassertlocked_readonly(so); |
| 389 | 	if (isspliced(so)) |
| 390 | 		return 0; |
| 391 | 	return (so->so_rcv.sb_state & SS_CANTRCVMORE) || |
| 392 | 	 so->so_error || so->so_rcv.sb_cc >= so->so_rcv.sb_lowat; |
| 393 | } |
| 394 | |
| 395 | /* can we write something to so? */ |
| 396 | static inline int |
| 397 | sowriteable(struct socket *so) |
| 398 | { |
| 399 | 	soassertlocked_readonly(so); |
| 400 | 	return ((sbspace(&so->so_snd) >= so->so_snd.sb_lowat && |
| 401 | 	 ((so->so_state & SS_ISCONNECTED) || |
| 402 | 	 (so->so_proto->pr_flags & PR_CONNREQUIRED)==0)) || |
| 403 | 	 (so->so_snd.sb_state & SS_CANTSENDMORE) || so->so_error); |
| 404 | } |
| 405 | |
| 406 | /* adjust counters in sb reflecting allocation of m */ |
| 407 | static inline void |
| 408 | sballoc(struct sockbuf *sb, struct mbuf *m) |
| 409 | { |
| 410 | 	sb->sb_cc += m->m_len; |
| 411 | 	if (m->m_type != MT_CONTROL && m->m_type != MT_SONAME) |
| 412 | 		sb->sb_datacc += m->m_len; |
| 413 | 	sb->sb_mbcnt += MSIZE; |
| 414 | 	if (m->m_flags & M_EXT) |
| 415 | 		sb->sb_mbcnt += m->m_ext.ext_size; |
| 416 | } |
| 417 | |
| 418 | /* adjust counters in sb reflecting freeing of m */ |
| 419 | static inline void |
| 420 | sbfree(struct sockbuf *sb, struct mbuf *m) |
| 421 | { |
| 422 | 	sb->sb_cc -= m->m_len; |
| 423 | 	if (m->m_type != MT_CONTROL && m->m_type != MT_SONAME) |
| 424 | 		sb->sb_datacc -= m->m_len; |
| 425 | 	sb->sb_mbcnt -= MSIZE; |
| 426 | 	if (m->m_flags & M_EXT) |
| 427 | 		sb->sb_mbcnt -= m->m_ext.ext_size; |
| 428 | } |
| 429 | |
| 430 | static inline void |
| 431 | sbassertlocked(struct sockbuf *sb) |
| 432 | { |
| 433 | 	rw_assert_wrlock(&sb->sb_lock); |
| 434 | } |
| 435 | |
| 436 | #define	SB_EMPTY_FIXUP(sb) do {						\ |
| 437 | 	if ((sb)->sb_mb == NULL) {					\ |
| 438 | 		(sb)->sb_mbtail = NULL;					\ |
| 439 | 		(sb)->sb_lastrecord = NULL;				\ |
| 440 | 	}								\ |
| 441 | } while (/*CONSTCOND*/0) |
| 442 | |
| 443 | #endif /* _KERNEL */ |
| 444 | #endif /* _SYS_SOCKETVAR_H_ */ |