summaryrefslogtreecommitdiffstats
path: root/sys/netinet/sctp_var.h
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2007-02-12 23:24:31 +0000
committerrrs <rrs@FreeBSD.org>2007-02-12 23:24:31 +0000
commite176cc33f53a2dee7896aec59f970825b57845b8 (patch)
tree6152741c43ebcb3fc304c4834897a4966cc8bdbd /sys/netinet/sctp_var.h
parent725b149c2db3f8bc35268426a9c1719420d722fa (diff)
downloadFreeBSD-src-e176cc33f53a2dee7896aec59f970825b57845b8.zip
FreeBSD-src-e176cc33f53a2dee7896aec59f970825b57845b8.tar.gz
- Copyright updates (aka 2007)
- ZONE get now also take a type cast so it does the cast like mtod does. - New macro SCTP_LIST_EMPTY, which in bsd is just LIST_EMPTY - Removal of const in some of the static hmac functions (not needed) - Store length changes to allow for new fields in auth - Auth code updated to current draft (this should be the RFC version we think). - use uint8_t instead of u_char in LOOPBACK address comparison - Some u_int32_t converted to uint32_t (in crc code) - A bug was found in the mib counts for ordered/unordered count, this was fixed (was referencing a freed mbuf). - SCTP_ASOCLOG_OF_TSNS added (code will probably disappear after my testing completes. It allows us to keep a small log on each assoc of the last 40 TSN's in/out and stream assignment. It is NOT in options and so is only good for private builds. - Some CMT changes in prep for Jana fixing his problem with reneging when CMT is enabled (Concurrent Multipath Transfer = CMT). - Some missing mib stats added. - Correction to number of open assoc's count in mib - Correction to os_bsd.h to get right sha2 macros - Add of special AUTH_04 flags so you can compile the code with the old format (in case the peer does not yet support the latest auth code). - Nonce sum was incorrectly being set in when ecn_nonce was NOT on. - LOR in listen with implicit bind found and fixed. - Moved away from using mbuf's for socket options to using just data pointers. The mbufs were used to harmonize NetBSD code since both Net and Open used this method. We have decided to move away from that and more conform to FreeBSD style (which makes more sense). - Very very nasty bug found in some of my "debug" code. The cookie_how collision case tracking had an endless loop in it if you got a second retransmission of a cookie collision case. This would lock up a CPU .. ugly.. - auth function goes to using size_t instead of int which conforms to socketapi better - Found the nasty bug that happens after 9 days of testing.. you get the data chunk, deliver it and due to the reference to a ch-> that every now and then has been deleted (depending on the postion in the mbuf) you have an invalid ch->ch.flags.. and thus you don't advance the stream sequence number.. so you block the stream permanently. The fix is to make local variables of these guys and set them up before you have any chance of trimming the mbuf. - style fix in sctp_util.h, not sure how this got bad maybe in the last patch? (aka it may not be in the real source). - Found interesting bug when using the extended snd/rcv info where we would get an error on receiving with this. Thats because it was NOT padded to the same size as the snd_rcv info. We increase (add the pad) so the two structs are the same size in sctp_uio.h - In sctp_usrreq.c one of the most common things we did for socket options was to cast the pointer and validate the size. This as been macro-ized to help make the code more readable. - in sctputil.c two things, the socketapi class found a missing flag type (the next msg is a notification) and a missing scope recovery was also fixed. Reviewed by: gnn
Diffstat (limited to 'sys/netinet/sctp_var.h')
-rw-r--r--sys/netinet/sctp_var.h160
1 files changed, 79 insertions, 81 deletions
diff --git a/sys/netinet/sctp_var.h b/sys/netinet/sctp_var.h
index 8cfe411..5463673 100644
--- a/sys/netinet/sctp_var.h
+++ b/sys/netinet/sctp_var.h
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef _NETINET_SCTP_VAR_H_
#define _NETINET_SCTP_VAR_H_
-#include <sys/socketvar.h>
+
#include <netinet/sctp_uio.h>
/* SCTP Kernel structures */
@@ -250,77 +250,75 @@ extern uint32_t sctp_system_free_resc_limit;
*/
#define sctp_free_a_readq(_stcb, _readq) { \
- SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_readq, (_readq)); \
- SCTP_DECR_READQ_COUNT(); \
+ SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_readq, (_readq)); \
+ SCTP_DECR_READQ_COUNT(); \
}
#define sctp_alloc_a_readq(_stcb, _readq) { \
- (_readq) = (struct sctp_queued_to_read *)SCTP_ZONE_GET(sctppcbinfo.ipi_zone_readq); \
+ (_readq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_readq, struct sctp_queued_to_read); \
if ((_readq)) { \
SCTP_INCR_READQ_COUNT(); \
} \
}
-
-
#define sctp_free_a_strmoq(_stcb, _strmoq) { \
- if (((_stcb)->asoc.free_strmoq_cnt > sctp_asoc_free_resc_limit) || \
- (sctppcbinfo.ipi_free_strmoq > sctp_system_free_resc_limit)) { \
+ if (((_stcb)->asoc.free_strmoq_cnt > sctp_asoc_free_resc_limit) || \
+ (sctppcbinfo.ipi_free_strmoq > sctp_system_free_resc_limit)) { \
SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_strmoq, (_strmoq)); \
SCTP_DECR_STRMOQ_COUNT(); \
- } else { \
+ } else { \
TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \
- (_stcb)->asoc.free_strmoq_cnt++; \
- atomic_add_int(&sctppcbinfo.ipi_free_strmoq, 1); \
- } \
+ (_stcb)->asoc.free_strmoq_cnt++; \
+ atomic_add_int(&sctppcbinfo.ipi_free_strmoq, 1); \
+ } \
}
#define sctp_alloc_a_strmoq(_stcb, _strmoq) { \
- if(TAILQ_EMPTY(&(_stcb)->asoc.free_strmoq)) { \
- (_strmoq) = (struct sctp_stream_queue_pending *)SCTP_ZONE_GET(sctppcbinfo.ipi_zone_strmoq); \
- if ((_strmoq)) { \
- SCTP_INCR_STRMOQ_COUNT(); \
+ if (TAILQ_EMPTY(&(_stcb)->asoc.free_strmoq)) { \
+ (_strmoq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_strmoq, struct sctp_stream_queue_pending); \
+ if ((_strmoq)) { \
+ SCTP_INCR_STRMOQ_COUNT(); \
+ } \
+ } else { \
+ (_strmoq) = TAILQ_FIRST(&(_stcb)->asoc.free_strmoq); \
+ TAILQ_REMOVE(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \
+ atomic_subtract_int(&sctppcbinfo.ipi_free_strmoq, 1); \
+ (_stcb)->asoc.free_strmoq_cnt--; \
} \
- } else { \
- (_strmoq) = TAILQ_FIRST(&(_stcb)->asoc.free_strmoq); \
- TAILQ_REMOVE(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \
- atomic_subtract_int(&sctppcbinfo.ipi_free_strmoq, 1); \
- (_stcb)->asoc.free_strmoq_cnt--; \
- } \
}
#define sctp_free_a_chunk(_stcb, _chk) { \
- if (((_stcb)->asoc.free_chunk_cnt > sctp_asoc_free_resc_limit) || \
- (sctppcbinfo.ipi_free_chunks > sctp_system_free_resc_limit)) { \
+ if (((_stcb)->asoc.free_chunk_cnt > sctp_asoc_free_resc_limit) || \
+ (sctppcbinfo.ipi_free_chunks > sctp_system_free_resc_limit)) { \
SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, (_chk)); \
SCTP_DECR_CHK_COUNT(); \
- } else { \
+ } else { \
TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
- (_stcb)->asoc.free_chunk_cnt++; \
- atomic_add_int(&sctppcbinfo.ipi_free_chunks, 1); \
- } \
+ (_stcb)->asoc.free_chunk_cnt++; \
+ atomic_add_int(&sctppcbinfo.ipi_free_chunks, 1); \
+ } \
}
#define sctp_alloc_a_chunk(_stcb, _chk) { \
- if(TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \
- (_chk) = (struct sctp_tmit_chunk *)SCTP_ZONE_GET(sctppcbinfo.ipi_zone_chunk); \
- if ((_chk)) { \
- SCTP_INCR_CHK_COUNT(); \
+ if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \
+ (_chk) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_chunk, struct sctp_tmit_chunk); \
+ if ((_chk)) { \
+ SCTP_INCR_CHK_COUNT(); \
+ } \
+ } else { \
+ (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \
+ TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
+ atomic_subtract_int(&sctppcbinfo.ipi_free_chunks, 1); \
+ (_stcb)->asoc.free_chunk_cnt--; \
} \
- } else { \
- (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \
- TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
- atomic_subtract_int(&sctppcbinfo.ipi_free_chunks, 1); \
- (_stcb)->asoc.free_chunk_cnt--; \
- } \
}
#define sctp_free_remote_addr(__net) { \
if ((__net)) { \
- if (atomic_fetchadd_int(&(__net)->ref_count, -1) == 1) { \
+ if (atomic_fetchadd_int(&(__net)->ref_count, -1) == 1) { \
SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \
SCTP_OS_TIMER_STOP(&(__net)->fr_timer.timer); \
@@ -332,37 +330,37 @@ extern uint32_t sctp_system_free_resc_limit;
}
#define sctp_sbfree(ctl, stcb, sb, m) { \
- uint32_t val; \
- val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \
- if(val < SCTP_BUF_LEN((m))) { \
- panic("sb_cc goes negative"); \
- } \
- val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(MSIZE)); \
- if(val < MSIZE) { \
- panic("sb_mbcnt goes negative"); \
- } \
- if (SCTP_BUF_IS_EXTENDED(m)) { \
- val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \
- if(val < SCTP_BUF_EXTEND_SIZE(m)) { \
- panic("sb_mbcnt goes negative2"); \
- } \
- } \
- if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
- val = atomic_fetchadd_int(&(stcb)->asoc.sb_cc,-(SCTP_BUF_LEN((m)))); \
- if(val < SCTP_BUF_LEN((m))) {\
- panic("stcb->sb_cc goes negative"); \
- } \
- val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(MSIZE)); \
- if(val < MSIZE) { \
- panic("asoc->mbcnt goes negative"); \
- } \
+ uint32_t val; \
+ val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \
+ if (val < SCTP_BUF_LEN((m))) { \
+ panic("sb_cc goes negative"); \
+ } \
+ val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(MSIZE)); \
+ if (val < MSIZE) { \
+ panic("sb_mbcnt goes negative"); \
+ } \
+ if (SCTP_BUF_IS_EXTENDED(m)) { \
+ val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \
+ if (val < SCTP_BUF_EXTEND_SIZE(m)) { \
+ panic("sb_mbcnt goes negative2"); \
+ } \
+ } \
+ if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
+ val = atomic_fetchadd_int(&(stcb)->asoc.sb_cc,-(SCTP_BUF_LEN((m)))); \
+ if (val < SCTP_BUF_LEN((m))) {\
+ panic("stcb->sb_cc goes negative"); \
+ } \
+ val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(MSIZE)); \
+ if (val < MSIZE) { \
+ panic("asoc->mbcnt goes negative"); \
+ } \
if (SCTP_BUF_IS_EXTENDED(m)) { \
- val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \
- if(val < SCTP_BUF_EXTEND_SIZE(m)) { \
+ val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \
+ if (val < SCTP_BUF_EXTEND_SIZE(m)) { \
panic("assoc stcb->mbcnt would go negative"); \
- } \
- } \
- } \
+ } \
+ } \
+ } \
if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
@@ -374,12 +372,12 @@ extern uint32_t sctp_system_free_resc_limit;
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
if (SCTP_BUF_IS_EXTENDED(m)) \
atomic_add_int(&(sb)->sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \
- if(stcb) { \
- atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \
- atomic_add_int(&(stcb)->asoc.sb_mbcnt, MSIZE); \
- if (SCTP_BUF_IS_EXTENDED(m)) \
- atomic_add_int(&(stcb)->asoc.sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \
- } \
+ if (stcb) { \
+ atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \
+ atomic_add_int(&(stcb)->asoc.sb_mbcnt, MSIZE); \
+ if (SCTP_BUF_IS_EXTENDED(m)) \
+ atomic_add_int(&(stcb)->asoc.sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \
+ } \
if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
@@ -399,14 +397,14 @@ extern uint32_t sctp_system_free_resc_limit;
}
#define sctp_mbuf_crush(data) do { \
- struct mbuf *_m; \
+ struct mbuf *_m; \
+ _m = (data); \
+ while(_m && (SCTP_BUF_LEN(_m) == 0)) { \
+ (data) = SCTP_BUF_NEXT(_m); \
+ SCTP_BUF_NEXT(_m) = NULL; \
+ sctp_m_free(_m); \
_m = (data); \
- while(_m && (SCTP_BUF_LEN(_m) == 0)) { \
- (data) = SCTP_BUF_NEXT(_m); \
- SCTP_BUF_NEXT(_m) = NULL; \
- sctp_m_free(_m); \
- _m = (data); \
- } \
+ } \
} while (0)
OpenPOWER on IntegriCloud