Deleted Added
full compact
in_pcb.h (222217) in_pcb.h (222488)
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California.
4 * Copyright (c) 2010-2011 Juniper Networks, Inc.
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Robert N. M. Watson under
8 * contract to Juniper Networks, Inc.

--- 18 unchanged lines hidden (view full) ---

27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California.
4 * Copyright (c) 2010-2011 Juniper Networks, Inc.
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Robert N. M. Watson under
8 * contract to Juniper Networks, Inc.

--- 18 unchanged lines hidden (view full) ---

27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
35 * $FreeBSD: head/sys/netinet/in_pcb.h 222217 2011-05-23 19:32:02Z rwatson $
35 * $FreeBSD: head/sys/netinet/in_pcb.h 222488 2011-05-30 09:43:55Z rwatson $
36 */
37
38#ifndef _NETINET_IN_PCB_H_
39#define _NETINET_IN_PCB_H_
40
41#include <sys/queue.h>
42#include <sys/_lock.h>
43#include <sys/_mutex.h>

--- 219 unchanged lines hidden (view full) ---

263 struct inpcbhead phd_pcblist;
264 u_short phd_port;
265};
266
267/*-
268 * Global data structure for each high-level protocol (UDP, TCP, ...) in both
269 * IPv4 and IPv6. Holds inpcb lists and information for managing them.
270 *
36 */
37
38#ifndef _NETINET_IN_PCB_H_
39#define _NETINET_IN_PCB_H_
40
41#include <sys/queue.h>
42#include <sys/_lock.h>
43#include <sys/_mutex.h>

--- 219 unchanged lines hidden (view full) ---

263 struct inpcbhead phd_pcblist;
264 u_short phd_port;
265};
266
267/*-
268 * Global data structure for each high-level protocol (UDP, TCP, ...) in both
269 * IPv4 and IPv6. Holds inpcb lists and information for managing them.
270 *
271 * Each pcbinfo is protected by ipi_lock, covering mutable global fields (such
272 * as the global pcb list) and hashed lookup tables. The lock order is:
271 * Each pcbinfo is protected by two locks: ipi_lock and ipi_hash_lock,
272 * the former covering mutable global fields (such as the global pcb list),
273 * and the latter covering the hashed lookup tables. The lock order is:
273 *
274 *
274 * ipi_lock (before) inpcb locks
275 * ipi_lock (before) inpcb locks (before) ipi_hash_lock
275 *
276 * Locking key:
277 *
278 * (c) Constant or nearly constant after initialisation
279 * (g) Locked by ipi_lock
276 *
277 * Locking key:
278 *
279 * (c) Constant or nearly constant after initialisation
280 * (g) Locked by ipi_lock
280 * (h) Read using either ipi_lock or inpcb lock; write requires both.
281 * (h) Read using either ipi_hash_lock or inpcb lock; write requires both.
281 * (x) Synchronisation properties poorly defined
282 */
283struct inpcbinfo {
284 /*
282 * (x) Synchronisation properties poorly defined
283 */
284struct inpcbinfo {
285 /*
285 * Global lock protecting global inpcb list, inpcb count, hash tables,
286 * etc.
286 * Global lock protecting global inpcb list, inpcb count, etc.
287 */
288 struct rwlock ipi_lock;
289
290 /*
291 * Global list of inpcbs on the protocol.
292 */
293 struct inpcbhead *ipi_listhead; /* (g) */
294 u_int ipi_count; /* (g) */

--- 12 unchanged lines hidden (view full) ---

307 u_short ipi_lasthi; /* (x) */
308
309 /*
310 * UMA zone from which inpcbs are allocated for this protocol.
311 */
312 struct uma_zone *ipi_zone; /* (c) */
313
314 /*
287 */
288 struct rwlock ipi_lock;
289
290 /*
291 * Global list of inpcbs on the protocol.
292 */
293 struct inpcbhead *ipi_listhead; /* (g) */
294 u_int ipi_count; /* (g) */

--- 12 unchanged lines hidden (view full) ---

307 u_short ipi_lasthi; /* (x) */
308
309 /*
310 * UMA zone from which inpcbs are allocated for this protocol.
311 */
312 struct uma_zone *ipi_zone; /* (c) */
313
314 /*
315 * Global lock protecting hash lookup tables.
316 */
317 struct rwlock ipi_hash_lock;
318
319 /*
315 * Global hash of inpcbs, hashed by local and foreign addresses and
316 * port numbers.
317 */
320 * Global hash of inpcbs, hashed by local and foreign addresses and
321 * port numbers.
322 */
318 struct inpcbhead *ipi_hashbase; /* (g) */
319 u_long ipi_hashmask; /* (g) */
323 struct inpcbhead *ipi_hashbase; /* (h) */
324 u_long ipi_hashmask; /* (h) */
320
321 /*
322 * Global hash of inpcbs, hashed by only local port number.
323 */
325
326 /*
327 * Global hash of inpcbs, hashed by only local port number.
328 */
324 struct inpcbporthead *ipi_porthashbase; /* (g) */
325 u_long ipi_porthashmask; /* (g) */
329 struct inpcbporthead *ipi_porthashbase; /* (h) */
330 u_long ipi_porthashmask; /* (h) */
326
327 /*
328 * Pointer to network stack instance
329 */
330 struct vnet *ipi_vnet; /* (c) */
331
332 /*
333 * general use 2

--- 67 unchanged lines hidden (view full) ---

401#define INP_INFO_TRY_UPGRADE(ipi) rw_try_upgrade(&(ipi)->ipi_lock)
402#define INP_INFO_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_lock)
403#define INP_INFO_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_lock)
404#define INP_INFO_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_LOCKED)
405#define INP_INFO_RLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_RLOCKED)
406#define INP_INFO_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_WLOCKED)
407#define INP_INFO_UNLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_UNLOCKED)
408
331
332 /*
333 * Pointer to network stack instance
334 */
335 struct vnet *ipi_vnet; /* (c) */
336
337 /*
338 * general use 2

--- 67 unchanged lines hidden (view full) ---

406#define INP_INFO_TRY_UPGRADE(ipi) rw_try_upgrade(&(ipi)->ipi_lock)
407#define INP_INFO_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_lock)
408#define INP_INFO_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_lock)
409#define INP_INFO_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_LOCKED)
410#define INP_INFO_RLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_RLOCKED)
411#define INP_INFO_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_WLOCKED)
412#define INP_INFO_UNLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_UNLOCKED)
413
414#define INP_HASH_LOCK_INIT(ipi, d) \
415 rw_init_flags(&(ipi)->ipi_hash_lock, (d), 0)
416#define INP_HASH_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_hash_lock)
417#define INP_HASH_RLOCK(ipi) rw_rlock(&(ipi)->ipi_hash_lock)
418#define INP_HASH_WLOCK(ipi) rw_wlock(&(ipi)->ipi_hash_lock)
419#define INP_HASH_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_hash_lock)
420#define INP_HASH_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_hash_lock)
421#define INP_HASH_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \
422 RA_LOCKED)
423#define INP_HASH_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \
424 RA_WLOCKED)
425
409#define INP_PCBHASH(faddr, lport, fport, mask) \
410 (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
411#define INP_PCBPORTHASH(lport, mask) \
412 (ntohs((lport)) & (mask))
413
414/*
415 * Flags for inp_vflags -- historically version flags only
416 */

--- 44 unchanged lines hidden (view full) ---

461 IN6P_MTU)
462
463/*
464 * Flags for inp_flags2.
465 */
466#define INP_LLE_VALID 0x00000001 /* cached lle is valid */
467#define INP_RT_VALID 0x00000002 /* cached rtentry is valid */
468
426#define INP_PCBHASH(faddr, lport, fport, mask) \
427 (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
428#define INP_PCBPORTHASH(lport, mask) \
429 (ntohs((lport)) & (mask))
430
431/*
432 * Flags for inp_vflags -- historically version flags only
433 */

--- 44 unchanged lines hidden (view full) ---

478 IN6P_MTU)
479
480/*
481 * Flags for inp_flags2.
482 */
483#define INP_LLE_VALID 0x00000001 /* cached lle is valid */
484#define INP_RT_VALID 0x00000002 /* cached rtentry is valid */
485
469#define INPLOOKUP_WILDCARD 1
486/*
487 * Flags passed to in_pcblookup*() functions.
488 */
489#define INPLOOKUP_WILDCARD 0x00000001 /* Allow wildcard sockets. */
490#define INPLOOKUP_RLOCKPCB 0x00000002 /* Return inpcb read-locked. */
491#define INPLOOKUP_WLOCKPCB 0x00000004 /* Return inpcb write-locked. */
492
493#define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \
494 INPLOOKUP_WLOCKPCB)
495
470#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
471#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
472
473#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
474
475#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
476
477#ifdef _KERNEL

--- 44 unchanged lines hidden (view full) ---

522void in_pcbdisconnect(struct inpcb *);
523void in_pcbdrop(struct inpcb *);
524void in_pcbfree(struct inpcb *);
525int in_pcbinshash(struct inpcb *);
526struct inpcb *
527 in_pcblookup_local(struct inpcbinfo *,
528 struct in_addr, u_short, int, struct ucred *);
529struct inpcb *
496#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
497#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
498
499#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
500
501#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
502
503#ifdef _KERNEL

--- 44 unchanged lines hidden (view full) ---

548void in_pcbdisconnect(struct inpcb *);
549void in_pcbdrop(struct inpcb *);
550void in_pcbfree(struct inpcb *);
551int in_pcbinshash(struct inpcb *);
552struct inpcb *
553 in_pcblookup_local(struct inpcbinfo *,
554 struct in_addr, u_short, int, struct ucred *);
555struct inpcb *
530 in_pcblookup_hash(struct inpcbinfo *, struct in_addr, u_int,
556 in_pcblookup(struct inpcbinfo *, struct in_addr, u_int,
531 struct in_addr, u_int, int, struct ifnet *);
532void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr,
533 int, struct inpcb *(*)(struct inpcb *, int));
534void in_pcbref(struct inpcb *);
535void in_pcbrehash(struct inpcb *);
536int in_pcbrele(struct inpcb *);
537int in_pcbrele_rlocked(struct inpcb *);
538int in_pcbrele_wlocked(struct inpcb *);
539void in_pcbsetsolabel(struct socket *so);
540int in_getpeeraddr(struct socket *so, struct sockaddr **nam);
541int in_getsockaddr(struct socket *so, struct sockaddr **nam);
542struct sockaddr *
543 in_sockaddr(in_port_t port, struct in_addr *addr);
544void in_pcbsosetlabel(struct socket *so);
545#endif /* _KERNEL */
546
547#endif /* !_NETINET_IN_PCB_H_ */
557 struct in_addr, u_int, int, struct ifnet *);
558void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr,
559 int, struct inpcb *(*)(struct inpcb *, int));
560void in_pcbref(struct inpcb *);
561void in_pcbrehash(struct inpcb *);
562int in_pcbrele(struct inpcb *);
563int in_pcbrele_rlocked(struct inpcb *);
564int in_pcbrele_wlocked(struct inpcb *);
565void in_pcbsetsolabel(struct socket *so);
566int in_getpeeraddr(struct socket *so, struct sockaddr **nam);
567int in_getsockaddr(struct socket *so, struct sockaddr **nam);
568struct sockaddr *
569 in_sockaddr(in_port_t port, struct in_addr *addr);
570void in_pcbsosetlabel(struct socket *so);
571#endif /* _KERNEL */
572
573#endif /* !_NETINET_IN_PCB_H_ */