Deleted Added
sdiff udiff text old ( 165220 ) new ( 167598 )
full compact
1#ifndef __sctp_lock_bsd_h__
2#define __sctp_lock_bsd_h__
3/*-
4 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

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

64
65/*
66 * When working with the global SCTP lists we lock and unlock the INP_INFO
67 * lock. So when we go to lookup an association we will want to do a
68 * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to
69 * the sctppcbinfo list's we will do a SCTP_INP_INFO_WLOCK().
70 */
71#include <sys/cdefs.h>
72__FBSDID("$FreeBSD: head/sys/netinet/sctp_lock_bsd.h 165220 2006-12-14 17:02:55Z rrs $");
73
74
75extern struct sctp_foo_stuff sctp_logoff[];
76extern int sctp_logoff_stuff;
77
78#define SCTP_IPI_COUNT_INIT()
79
80#define SCTP_STATLOG_INIT_LOCK()

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

101} while (0)
102
103
104#define SCTP_INP_INFO_WLOCK() do { \
105 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
106} while (0)
107
108
109
110#define SCTP_IPI_ADDR_INIT() \
111 mtx_init(&sctppcbinfo.ipi_addr_mtx, "sctp-addr-wq", "sctp_addr_wq", MTX_DEF)
112
113#define SCTP_IPI_ADDR_DESTROY() \
114 mtx_destroy(&sctppcbinfo.ipi_addr_mtx)
115
116#define SCTP_IPI_ADDR_LOCK() do { \
117 mtx_lock(&sctppcbinfo.ipi_addr_mtx); \
118} while (0)
119
120#define SCTP_IPI_ADDR_UNLOCK() mtx_unlock(&sctppcbinfo.ipi_addr_mtx)
121
122#define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
123#define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
124
125/*
126 * The INP locks we will use for locking an SCTP endpoint, so for example if
127 * we want to change something at the endpoint level for example random_store
128 * or cookie secrets we lock the INP level.
129 */

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

185#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_send_mtx)
186
187#define SCTP_TCB_SEND_LOCK(_tcb) do { \
188 mtx_lock(&(_tcb)->tcb_send_mtx); \
189} while (0)
190
191#define SCTP_TCB_SEND_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_send_mtx)
192
193#ifdef INVARIANTS
194
195#define SCTP_INP_INCR_REF(_inp) { int x; \
196 atomic_add_int(&((_inp)->refcount), 1); \
197 x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \
198 if(x == 30000) \
199 sctp_logoff_stuff = x = 0; \
200 sctp_logoff[x].inp = _inp; \
201 sctp_logoff[x].ticks = ticks; \
202 sctp_logoff[x].lineno = __LINE__; \
203 sctp_logoff[x].updown = 1; \
204}
205
206#define SCTP_INP_DECR_REF(_inp) { int x; \
207 if (atomic_fetchadd_int(&((_inp)->refcount), -1) == 0 ) panic("refcount goes negative"); \
208 x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \
209 if(x == 30000) \
210 sctp_logoff_stuff = x = 0; \
211 sctp_logoff[x].inp = _inp; \
212 sctp_logoff[x].ticks = ticks; \
213 sctp_logoff[x].lineno = __LINE__; \
214 sctp_logoff[x].updown = 0; \
215}
216
217#else
218
219#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
220#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
221
222#endif
223
224#ifdef SCTP_LOCK_LOGGING
225#define SCTP_ASOC_CREATE_LOCK(_inp) \
226 do { \
227 sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
228 mtx_lock(&(_inp)->inp_create_mtx); \
229 } while (0)
230#else

--- 157 unchanged lines hidden ---