summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2007-06-14 22:59:04 +0000
committerrrs <rrs@FreeBSD.org>2007-06-14 22:59:04 +0000
commit5db775aaced05bbda585e596739fe8150a74d68d (patch)
tree54d00675be01f15ab0ef5ba5c19c020edee43762 /sys/netinet
parent491996f8103df505e60bc52e817f90a4bccba59e (diff)
downloadFreeBSD-src-5db775aaced05bbda585e596739fe8150a74d68d.zip
FreeBSD-src-5db775aaced05bbda585e596739fe8150a74d68d.tar.gz
- Fix so ifn's are properly deleted when the ref count goes to 0.
- Fix so VRF's will clean themselves up when no references are around. - Allow sctp_ifa to be passed into inpcb_bind, addr_mgmt_ep_sa to bypass normal validation checks. - turn auto-asconf off for subset bound sockets - Moves all logging to use KTR. This gets rid of most of the logging #ifdef's with a few exceptions reducing the number of config options for SCTP.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/sctp.h34
-rw-r--r--sys/netinet/sctp_asconf.c6
-rw-r--r--sys/netinet/sctp_asconf.h2
-rw-r--r--sys/netinet/sctp_bsd_addr.c6
-rw-r--r--sys/netinet/sctp_constants.h16
-rw-r--r--sys/netinet/sctp_indata.c700
-rw-r--r--sys/netinet/sctp_input.c58
-rw-r--r--sys/netinet/sctp_lock_bsd.h17
-rw-r--r--sys/netinet/sctp_os_bsd.h13
-rw-r--r--sys/netinet/sctp_output.c210
-rw-r--r--sys/netinet/sctp_pcb.c76
-rw-r--r--sys/netinet/sctp_pcb.h8
-rw-r--r--sys/netinet/sctp_peeloff.c10
-rw-r--r--sys/netinet/sctp_sysctl.c7
-rw-r--r--sys/netinet/sctp_sysctl.h15
-rw-r--r--sys/netinet/sctp_timer.c151
-rw-r--r--sys/netinet/sctp_uio.h2
-rw-r--r--sys/netinet/sctp_usrreq.c38
-rw-r--r--sys/netinet/sctputil.c928
-rw-r--r--sys/netinet/sctputil.h58
20 files changed, 1120 insertions, 1235 deletions
diff --git a/sys/netinet/sctp.h b/sys/netinet/sctp.h
index 0f81850..6374bce 100644
--- a/sys/netinet/sctp.h
+++ b/sys/netinet/sctp.h
@@ -477,7 +477,41 @@ __attribute__((packed));
#include <netinet/sctp_uio.h>
+/* This dictates the size of the packet
+ * collection buffer. This only applies
+ * if SCTP_PACKET_LOGGING is enabled in
+ * your config.
+ */
#define SCTP_PACKET_LOG_SIZE 65536
+/* Types of logging/KTR tracing that can be enabled via the
+ * sysctl net.inet.sctp.sctp_logging. You must also enable
+ * SUBSYS tracing.
+ * Note that you must have the SCTP option in the kernel
+ * to enable these as well.
+ */
+#define SCTP_BLK_LOGGING_ENABLE 0x00000001
+#define SCTP_CWND_MONITOR_ENABLE 0x00000002
+#define SCTP_CWND_LOGGING_ENABLE 0x00000004
+#define SCTP_EARLYFR_LOGGING_ENABLE 0x00000010
+#define SCTP_FLIGHT_LOGGING_ENABLE 0x00000020
+#define SCTP_FR_LOGGING_ENABLE 0x00000040
+#define SCTP_LOCK_LOGGING_ENABLE 0x00000080
+#define SCTP_MAP_LOGGING_ENABLE 0x00000100
+#define SCTP_MBCNT_LOGGING_ENABLE 0x00000200
+#define SCTP_MBUF_LOGGING_ENABLE 0x00000400
+#define SCTP_NAGLE_LOGGING_ENABLE 0x00000800
+#define SCTP_RECV_RWND_LOGGING_ENABLE 0x00001000
+#define SCTP_RTTVAR_LOGGING_ENABLE 0x00002000
+#define SCTP_SACK_LOGGING_ENABLE 0x00004000
+#define SCTP_SACK_RWND_LOGGING_ENABLE 0x00008000
+#define SCTP_SB_LOGGING_ENABLE 0x00010000
+#define SCTP_STR_LOGGING_ENABLE 0x00020000
+#define SCTP_WAKE_LOGGING_ENABLE 0x00040000
+#define SCTP_LOG_MAXBURST_ENABLE 0x00080000
+#define SCTP_LOG_RWND_ENABLE 0x00100000
+#define SCTP_LOG_SACK_ARRIVALS_ENABLE 0x00200000
+#define SCTP_LTRACE_CHUNK_ENABLE 0x00400000
+#define SCTP_LTRACE_ERROR_ENABLE 0x00800000
#endif /* !_NETINET_SCTP_H_ */
diff --git a/sys/netinet/sctp_asconf.c b/sys/netinet/sctp_asconf.c
index b2c932c..1b54257 100644
--- a/sys/netinet/sctp_asconf.c
+++ b/sys/netinet/sctp_asconf.c
@@ -2543,14 +2543,16 @@ sctp_check_address_list(struct sctp_tcb *stcb, struct mbuf *m, int offset,
*/
uint32_t
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa,
- uint32_t type, uint32_t vrf_id)
+ uint32_t type, uint32_t vrf_id, struct sctp_ifa *sctp_ifap)
{
struct sctp_ifa *ifa;
if (sa->sa_len == 0) {
return (EINVAL);
}
- if (type == SCTP_ADD_IP_ADDRESS) {
+ if (sctp_ifap) {
+ ifa = sctp_ifap;
+ } else if (type == SCTP_ADD_IP_ADDRESS) {
/* For an add the address MUST be on the system */
ifa = sctp_find_ifa_by_addr(sa, vrf_id, 0);
} else if (type == SCTP_DEL_IP_ADDRESS) {
diff --git a/sys/netinet/sctp_asconf.h b/sys/netinet/sctp_asconf.h
index 11d8bb2..d47aa96 100644
--- a/sys/netinet/sctp_asconf.h
+++ b/sys/netinet/sctp_asconf.h
@@ -55,7 +55,7 @@ sctp_handle_asconf_ack(struct mbuf *, int,
extern uint32_t
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *,
- uint32_t, uint32_t);
+ uint32_t, uint32_t, struct sctp_ifa *);
int sctp_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val);
diff --git a/sys/netinet/sctp_bsd_addr.c b/sys/netinet/sctp_bsd_addr.c
index 6b4ca68..be6a19d 100644
--- a/sys/netinet/sctp_bsd_addr.c
+++ b/sys/netinet/sctp_bsd_addr.c
@@ -364,8 +364,10 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
SCTP_BUF_NEXT(m) = NULL;
}
#ifdef SCTP_MBUF_LOGGING
- if (SCTP_BUF_IS_EXTENDED(m)) {
- sctp_log_mb(m, SCTP_MBUF_IALLOC);
+ if (sctp_logging_level & SCTP_MBUF_LOGGING_ENABLE) {
+ if (SCTP_BUF_IS_EXTENDED(m)) {
+ sctp_log_mb(m, SCTP_MBUF_IALLOC);
+ }
}
#endif
return (m);
diff --git a/sys/netinet/sctp_constants.h b/sys/netinet/sctp_constants.h
index c3d2997..bcf1aae 100644
--- a/sys/netinet/sctp_constants.h
+++ b/sys/netinet/sctp_constants.h
@@ -71,7 +71,6 @@ __FBSDID("$FreeBSD$");
#define SCTP_VERSION_STRING "KAME-BSD 1.1"
/* #define SCTP_AUDITING_ENABLED 1 used for debug/auditing */
#define SCTP_AUDIT_SIZE 256
-#define SCTP_STAT_LOG_SIZE 80000
#define SCTP_USE_THREAD_BASED_ITERATOR 1
@@ -204,12 +203,13 @@ __FBSDID("$FreeBSD$");
#define SCTP_LOG_MAX_TYPES 118
/*
- * To turn on various logging, you must first define SCTP_STAT_LOGGING. Then
- * to get something to log you define one of the logging defines i.e.
+ * To turn on various logging, you must first enable 'options KTR' and
+ * you might want to bump the entires 'options KTR_ENTRIES=80000'.
+ * To get something to log you define one of the logging defines.
+ * (see LINT).
*
- * SCTP_CWND_LOGGING SCTP_BLK_LOGGING SCTP_STR_LOGGING SCTP_FR_LOGGING
- *
- * Any one or a combination of the logging can be turned on.
+ * This gets the compile in place, but you still need to turn the
+ * logging flag on too in the sysctl (see in sctp.h).
*/
#define SCTP_LOG_EVENT_UNKNOWN 0
#define SCTP_LOG_EVENT_CWND 1
@@ -229,8 +229,10 @@ __FBSDID("$FreeBSD$");
#define SCTP_LOG_MISC_EVENT 15
#define SCTP_LOG_EVENT_CLOSE 16
#define SCTP_LOG_EVENT_MBUF 17
+#define SCTP_LOG_CHUNK_PROC 18
+#define SCTP_LOG_ERROR_RET 19
-#define SCTP_LOG_MAX_EVENT 18
+#define SCTP_LOG_MAX_EVENT 20
#define SCTP_LOCK_UNKNOWN 2
diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c
index 085f694..49fd598 100644
--- a/sys/netinet/sctp_indata.c
+++ b/sys/netinet/sctp_indata.c
@@ -559,9 +559,9 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
sctp_ucount_incr(asoc->cnt_on_all_streams);
strm = &asoc->strmin[control->sinfo_stream];
nxt_todel = strm->last_sequence_delivered + 1;
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INTO_STRD);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INTO_STRD);
+ }
SCTPDBG(SCTP_DEBUG_INDATA1,
"queue to stream called for ssn:%u lastdel:%u nxt:%u\n",
(uint32_t) control->sinfo_stream,
@@ -606,9 +606,9 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
if (nxt_todel == control->sinfo_ssn) {
/* can be delivered right away? */
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_IMMED_DEL);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_IMMED_DEL);
+ }
queue_needed = 0;
asoc->size_on_all_streams -= control->length;
sctp_ucount_decr(asoc->cnt_on_all_streams);
@@ -632,10 +632,10 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
* d-queue. And we have a finite number that
* can be delivered from the strq.
*/
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, NULL,
- SCTP_STR_LOG_FROM_IMMED_DEL);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, NULL,
+ SCTP_STR_LOG_FROM_IMMED_DEL);
+ }
sctp_add_to_readq(stcb->sctp_ep, stcb,
control,
&stcb->sctp_socket->so_rcv, 1);
@@ -652,9 +652,9 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if (TAILQ_EMPTY(&strm->inqueue)) {
/* Empty queue */
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INSERT_HD);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, NULL, SCTP_STR_LOG_FROM_INSERT_HD);
+ }
TAILQ_INSERT_HEAD(&strm->inqueue, control, next);
} else {
TAILQ_FOREACH(at, &strm->inqueue, next) {
@@ -664,10 +664,10 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
* one in queue is bigger than the
* new one, insert before this one
*/
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, at,
- SCTP_STR_LOG_FROM_INSERT_MD);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, at,
+ SCTP_STR_LOG_FROM_INSERT_MD);
+ }
TAILQ_INSERT_BEFORE(at, control, next);
break;
} else if (at->sinfo_ssn == control->sinfo_ssn) {
@@ -699,10 +699,10 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb, struct sctp_association *asoc,
* We are at the end, insert
* it after this one
*/
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del(control, at,
- SCTP_STR_LOG_FROM_INSERT_TL);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del(control, at,
+ SCTP_STR_LOG_FROM_INSERT_TL);
+ }
TAILQ_INSERT_AFTER(&strm->inqueue,
at, control, next);
break;
@@ -1452,12 +1452,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
chunk_flags = ch->ch.chunk_flags;
protocol_id = ch->dp.protocol_id;
ordered = ((ch->ch.chunk_flags & SCTP_DATA_UNORDERED) == 0);
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, tsn, asoc->cumulative_tsn, SCTP_MAP_PREPARE_SLIDE);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, tsn, asoc->cumulative_tsn, SCTP_MAP_PREPARE_SLIDE);
+ }
if (stcb == NULL) {
return (0);
}
+ SCTP_LTRACE_CHK(stcb->sctp_ep, stcb, ch->ch.chunk_type, tsn);
if (compare_with_wrap(asoc->cumulative_tsn, tsn, MAX_TSN) ||
asoc->cumulative_tsn == tsn) {
/* It is a duplicate */
@@ -1592,9 +1593,9 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
if (compare_with_wrap(tsn, asoc->highest_tsn_inside_map, MAX_TSN)) {
/* we have a new high score */
asoc->highest_tsn_inside_map = tsn;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, 2, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, 2, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
+ }
}
if (tsn == (asoc->cumulative_tsn + 1)) {
/* Update cum-ack */
@@ -1667,7 +1668,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
(offset + sizeof(struct sctp_data_chunk)),
the_len, M_DONTWAIT);
#ifdef SCTP_MBUF_LOGGING
- {
+ if (sctp_logging_level & SCTP_MBUF_LOGGING_ENABLE) {
struct mbuf *mat;
mat = dmbuf;
@@ -1743,10 +1744,10 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
asoc->strmin[strmno].last_sequence_delivered++;
}
SCTP_STAT_INCR(sctps_recvexpress);
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del_alt(stcb, tsn, strmseq, strmno,
- SCTP_STR_LOG_FROM_EXPRS_DEL);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del_alt(stcb, tsn, strmseq, strmno,
+ SCTP_STR_LOG_FROM_EXPRS_DEL);
+ }
control = NULL;
goto finish_express_del;
}
@@ -2065,9 +2066,9 @@ finish_express_del:
if (compare_with_wrap(tsn, asoc->highest_tsn_inside_map, MAX_TSN)) {
/* we have a new high score */
asoc->highest_tsn_inside_map = tsn;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, 2, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, 2, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
+ }
}
if (tsn == (asoc->cumulative_tsn + 1)) {
/* Update cum-ack */
@@ -2083,13 +2084,13 @@ finish_express_del:
}
SCTP_STAT_INCR(sctps_recvdata);
/* Set it present please */
-#ifdef SCTP_STR_LOGGING
- sctp_log_strm_del_alt(stcb, tsn, strmseq, strmno, SCTP_STR_LOG_FROM_MARK_TSN);
-#endif
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
- asoc->highest_tsn_inside_map, SCTP_MAP_PREPARE_SLIDE);
-#endif
+ if (sctp_logging_level & SCTP_STR_LOGGING_ENABLE) {
+ sctp_log_strm_del_alt(stcb, tsn, strmseq, strmno, SCTP_STR_LOG_FROM_MARK_TSN);
+ }
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
+ asoc->highest_tsn_inside_map, SCTP_MAP_PREPARE_SLIDE);
+ }
SCTP_TCB_LOCK_ASSERT(stcb);
SCTP_SET_TSN_PRESENT(asoc->mapping_array, gap);
/* check the special flag for stream resets */
@@ -2198,17 +2199,13 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
int i, at;
int all_ones, last_all_ones = 0;
int slide_from, slide_end, lgap, distance;
-
-#ifdef SCTP_MAP_LOGGING
uint32_t old_cumack, old_base, old_highest;
unsigned char aux_array[64];
-#endif
asoc = &stcb->asoc;
at = 0;
-#ifdef SCTP_MAP_LOGGING
old_cumack = asoc->cumulative_tsn;
old_base = asoc->mapping_array_base_tsn;
old_highest = asoc->highest_tsn_inside_map;
@@ -2217,7 +2214,6 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
asoc->mapping_array_size);
else
memcpy(aux_array, asoc->mapping_array, 64);
-#endif
/*
* We could probably improve this a small bit by calculating the
@@ -2274,12 +2270,12 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
memset(asoc->mapping_array, 0, clr);
/* base becomes one ahead of the cum-ack */
asoc->mapping_array_base_tsn = asoc->cumulative_tsn + 1;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(old_base, old_cumack, old_highest,
- SCTP_MAP_PREPARE_SLIDE);
- sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
- asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_CLEARED);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(old_base, old_cumack, old_highest,
+ SCTP_MAP_PREPARE_SLIDE);
+ sctp_log_map(asoc->mapping_array_base_tsn, asoc->cumulative_tsn,
+ asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_CLEARED);
+ }
} else if (at >= 8) {
/* we can slide the mapping array down */
/* Calculate the new byte postion we can move down */
@@ -2300,12 +2296,12 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
panic("impossible slide");
}
distance = (slide_end - slide_from) + 1;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(old_base, old_cumack, old_highest,
- SCTP_MAP_PREPARE_SLIDE);
- sctp_log_map((uint32_t) slide_from, (uint32_t) slide_end,
- (uint32_t) lgap, SCTP_MAP_SLIDE_FROM);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(old_base, old_cumack, old_highest,
+ SCTP_MAP_PREPARE_SLIDE);
+ sctp_log_map((uint32_t) slide_from, (uint32_t) slide_end,
+ (uint32_t) lgap, SCTP_MAP_SLIDE_FROM);
+ }
if (distance + slide_from > asoc->mapping_array_size ||
distance < 0) {
/*
@@ -2315,11 +2311,11 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
* don't think this should happen :-0
*/
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map((uint32_t) distance, (uint32_t) slide_from,
- (uint32_t) asoc->mapping_array_size,
- SCTP_MAP_SLIDE_NONE);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map((uint32_t) distance, (uint32_t) slide_from,
+ (uint32_t) asoc->mapping_array_size,
+ SCTP_MAP_SLIDE_NONE);
+ }
} else {
int ii;
@@ -2331,11 +2327,11 @@ sctp_sack_check(struct sctp_tcb *stcb, int ok_to_sack, int was_a_gap, int *abort
asoc->mapping_array[ii] = 0;
}
asoc->mapping_array_base_tsn += (slide_from << 3);
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(asoc->mapping_array_base_tsn,
- asoc->cumulative_tsn, asoc->highest_tsn_inside_map,
- SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(asoc->mapping_array_base_tsn,
+ asoc->cumulative_tsn, asoc->highest_tsn_inside_map,
+ SCTP_MAP_SLIDE_RESULT);
+ }
}
}
/*
@@ -2781,11 +2777,8 @@ sctp_handle_segments(struct sctp_tcb *stcb, struct sctp_association *asoc,
struct sctp_tmit_chunk *tp1;
int i;
unsigned int j;
-
-#ifdef SCTP_FR_LOGGING
int num_frs = 0;
-#endif
uint16_t frag_strt, frag_end, primary_flag_set;
u_long last_frag_high;
@@ -2849,10 +2842,8 @@ sctp_handle_segments(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
for (j = frag_strt + last_tsn; j <= frag_end + last_tsn; j++) {
while (tp1) {
-#ifdef SCTP_FR_LOGGING
if (tp1->rec.data.doing_fast_retransmit)
num_frs++;
-#endif
/*
* CMT: CUCv2 algorithm. For each TSN being
@@ -2922,14 +2913,14 @@ sctp_handle_segments(struct sctp_tcb *stcb, struct sctp_association *asoc,
* ewack
*/
if (*this_sack_lowest_newack == 0) {
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(*this_sack_lowest_newack,
- last_tsn,
- tp1->rec.data.TSN_seq,
- 0,
- 0,
- SCTP_LOG_TSN_ACKED);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(*this_sack_lowest_newack,
+ last_tsn,
+ tp1->rec.data.TSN_seq,
+ 0,
+ 0,
+ SCTP_LOG_TSN_ACKED);
+ }
*this_sack_lowest_newack = tp1->rec.data.TSN_seq;
}
/*
@@ -2964,30 +2955,30 @@ sctp_handle_segments(struct sctp_tcb *stcb, struct sctp_association *asoc,
}
tp1->whoTo->find_pseudo_cumack = 1;
}
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
+ }
if (tp1->rec.data.TSN_seq == tp1->whoTo->rtx_pseudo_cumack) {
if (tp1->rec.data.chunk_was_revoked == 0) {
tp1->whoTo->new_pseudo_cumack = 1;
}
tp1->whoTo->find_rtx_pseudo_cumack = 1;
}
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(*biggest_newly_acked_tsn,
- last_tsn,
- tp1->rec.data.TSN_seq,
- frag_strt,
- frag_end,
- SCTP_LOG_TSN_ACKED);
-#endif
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_GAP,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(*biggest_newly_acked_tsn,
+ last_tsn,
+ tp1->rec.data.TSN_seq,
+ frag_strt,
+ frag_end,
+ SCTP_LOG_TSN_ACKED);
+ }
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_GAP,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(tp1);
sctp_total_flight_decrease(stcb, tp1);
@@ -3053,12 +3044,12 @@ sctp_handle_segments(struct sctp_tcb *stcb, struct sctp_association *asoc,
} /* end for (j = fragStart */
frag++; /* next one */
}
-#ifdef SCTP_FR_LOGGING
- /*
- * if (num_frs) sctp_log_fr(*biggest_tsn_acked,
- * *biggest_newly_acked_tsn, last_tsn, SCTP_FR_LOG_BIGGEST_TSNS);
- */
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ if (num_frs)
+ sctp_log_fr(*biggest_tsn_acked,
+ *biggest_newly_acked_tsn,
+ last_tsn, SCTP_FR_LOG_BIGGEST_TSNS);
+ }
}
static void
@@ -3092,13 +3083,13 @@ sctp_check_for_revoked(struct sctp_tcb *stcb,
* We must add this stuff back in to assure
* timers and such get started.
*/
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_increase(tp1);
sctp_total_flight_increase(stcb, tp1);
/*
@@ -3107,14 +3098,14 @@ sctp_check_for_revoked(struct sctp_tcb *stcb,
*/
tp1->whoTo->cwnd += tp1->book_size;
tot_revoked++;
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(asoc->last_acked_seq,
- cumack,
- tp1->rec.data.TSN_seq,
- 0,
- 0,
- SCTP_LOG_TSN_REVOKED);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(asoc->last_acked_seq,
+ cumack,
+ tp1->rec.data.TSN_seq,
+ 0,
+ 0,
+ SCTP_LOG_TSN_REVOKED);
+ }
} else if (tp1->sent == SCTP_DATAGRAM_MARKED) {
/* it has been re-acked in this SACK */
tp1->sent = SCTP_DATAGRAM_ACKED;
@@ -3184,13 +3175,13 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
tp1 = TAILQ_NEXT(tp1, sctp_next);
continue;
}
-#ifdef SCTP_FR_LOGGING
- if (tp1->sent < SCTP_DATAGRAM_RESEND)
- sctp_log_fr(biggest_tsn_newly_acked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_CHECK_STRIKE);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ if (tp1->sent < SCTP_DATAGRAM_RESEND)
+ sctp_log_fr(biggest_tsn_newly_acked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_CHECK_STRIKE);
+ }
if (compare_with_wrap(tp1->rec.data.TSN_seq, biggest_tsn_acked,
MAX_TSN) ||
tp1->sent == SCTP_DATAGRAM_UNSENT) {
@@ -3279,12 +3270,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
* Strike the TSN if in fast-recovery and cum-ack
* moved.
*/
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(biggest_tsn_newly_acked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(biggest_tsn_newly_acked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
tp1->sent++;
}
@@ -3303,12 +3294,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) &&
compare_with_wrap(this_sack_lowest_newack, tp1->rec.data.TSN_seq, MAX_TSN)) {
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(16 + num_dests_sacked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(16 + num_dests_sacked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
tp1->sent++;
}
}
@@ -3342,12 +3333,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
* beyond where things were when we
* did a FR.
*/
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(biggest_tsn_newly_acked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(biggest_tsn_newly_acked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
tp1->sent++;
}
@@ -3376,12 +3367,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
(num_dests_sacked == 1) &&
compare_with_wrap(this_sack_lowest_newack,
tp1->rec.data.TSN_seq, MAX_TSN)) {
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(32 + num_dests_sacked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(32 + num_dests_sacked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
tp1->sent++;
@@ -3404,12 +3395,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
;
} else {
/* Strike the TSN */
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(biggest_tsn_newly_acked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(biggest_tsn_newly_acked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
tp1->sent++;
}
@@ -3428,12 +3419,12 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
*/
if ((tp1->sent < SCTP_DATAGRAM_RESEND) && (num_dests_sacked == 1) &&
compare_with_wrap(this_sack_lowest_newack, tp1->rec.data.TSN_seq, MAX_TSN)) {
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(48 + num_dests_sacked,
- tp1->rec.data.TSN_seq,
- tp1->sent,
- SCTP_FR_LOG_STRIKE_CHUNK);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(48 + num_dests_sacked,
+ tp1->rec.data.TSN_seq,
+ tp1->sent,
+ SCTP_FR_LOG_STRIKE_CHUNK);
+ }
tp1->sent++;
}
}
@@ -3443,10 +3434,10 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
struct sctp_nets *alt;
/* printf("OK, we are now ready to FR this guy\n"); */
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(tp1->rec.data.TSN_seq, tp1->snd_count,
- 0, SCTP_FR_MARKED);
-#endif
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(tp1->rec.data.TSN_seq, tp1->snd_count,
+ 0, SCTP_FR_MARKED);
+ }
if (strike_flag) {
/* This is a subsequent FR */
SCTP_STAT_INCR(sctps_sendmultfastretrans);
@@ -3530,21 +3521,21 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
tp1->do_rtt = 0;
}
/* fix counts and things */
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
if (tp1->whoTo) {
tp1->whoTo->net_ack++;
sctp_flight_size_decrease(tp1);
}
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd(SCTP_INCREASE_PEER_RWND,
- asoc->peers_rwnd, tp1->send_size, sctp_peer_chunk_oh);
-#endif
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd(SCTP_INCREASE_PEER_RWND,
+ asoc->peers_rwnd, tp1->send_size, sctp_peer_chunk_oh);
+ }
/* add back to the rwnd */
asoc->peers_rwnd += (tp1->send_size + sctp_peer_chunk_oh);
@@ -3659,9 +3650,9 @@ sctp_try_advance_peer_ack_point(struct sctp_tcb *stcb,
if (stcb->sctp_socket) {
sctp_sowwakeup(stcb->sctp_ep,
stcb->sctp_socket);
-#ifdef SCTP_WAKE_LOGGING
- sctp_wakeup_log(stcb, tp1->rec.data.TSN_seq, 1, SCTP_WAKESND_FROM_FWDTSN);
-#endif
+ if (sctp_logging_level & SCTP_WAKE_LOGGING_ENABLE) {
+ sctp_wakeup_log(stcb, tp1->rec.data.TSN_seq, 1, SCTP_WAKESND_FROM_FWDTSN);
+ }
}
}
} else {
@@ -3777,14 +3768,14 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net)
/* normal mode */
if (net->net_ack > net->mtu) {
net->cwnd += net->mtu;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_SS);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->mtu, SCTP_CWND_LOG_FROM_SS);
+ }
} else {
net->cwnd += net->net_ack;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->net_ack, SCTP_CWND_LOG_FROM_SS);
+ }
}
} else {
for (i = net->last_hs_used; i < SCTP_HS_TABLE_SIZE; i++) {
@@ -3796,9 +3787,9 @@ sctp_hs_cwnd_increase(struct sctp_tcb *stcb, struct sctp_nets *net)
net->last_hs_used = indx;
incr = ((sctp_cwnd_adjust[indx].increase) << 10);
net->cwnd += incr;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, incr, SCTP_CWND_LOG_FROM_SS);
+ }
}
}
@@ -3806,12 +3797,8 @@ static void
sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net)
{
int cur_val, i, indx;
-
-#ifdef SCTP_CWND_MONITOR
int old_cwnd = net->cwnd;
-#endif
-
cur_val = net->cwnd >> 10;
indx = net->last_hs_used;
if (cur_val < sctp_cwnd_adjust[0].cwnd) {
@@ -3842,10 +3829,9 @@ sctp_hs_cwnd_decrease(struct sctp_tcb *stcb, struct sctp_nets *net)
net->last_hs_used = indx;
}
}
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR);
-#endif
-
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_FR);
+ }
}
#endif
@@ -3913,9 +3899,9 @@ sctp_cwnd_update(struct sctp_tcb *stcb,
}
/* if nothing was acked on this destination skip it */
if (net->net_ack == 0) {
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FROM_SACK);
+ }
continue;
}
if (net->net_ack2 > 0) {
@@ -3972,18 +3958,14 @@ sctp_cwnd_update(struct sctp_tcb *stcb,
#else
if (net->net_ack > (net->mtu * sctp_L2_abc_variable)) {
net->cwnd += (net->mtu * sctp_L2_abc_variable);
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->mtu,
- SCTP_CWND_LOG_FROM_SS);
-#endif
-
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->mtu,
+ SCTP_CWND_LOG_FROM_SS);
+ }
} else {
net->cwnd += net->net_ack;
-#ifdef SCTP_CWND_MONITOR
sctp_log_cwnd(stcb, net, net->net_ack,
SCTP_CWND_LOG_FROM_SS);
-#endif
-
}
#endif
} else {
@@ -3991,10 +3973,10 @@ sctp_cwnd_update(struct sctp_tcb *stcb,
dif = net->cwnd - (net->flight_size +
net->net_ack);
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, net->net_ack,
- SCTP_CWND_LOG_NOADV_SS);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->net_ack,
+ SCTP_CWND_LOG_NOADV_SS);
+ }
}
} else {
/* We are in congestion avoidance */
@@ -4023,33 +4005,32 @@ sctp_cwnd_update(struct sctp_tcb *stcb,
0;
}
net->cwnd += net->mtu;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->mtu,
- SCTP_CWND_LOG_FROM_CA);
-#endif
- }
-#ifdef SCTP_CWND_LOGGING
- else {
- sctp_log_cwnd(stcb, net, net->net_ack,
- SCTP_CWND_LOG_NOADV_CA);
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->mtu,
+ SCTP_CWND_LOG_FROM_CA);
+ }
+ } else {
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->net_ack,
+ SCTP_CWND_LOG_NOADV_CA);
+ }
}
-#endif
} else {
unsigned int dif;
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, net->net_ack,
- SCTP_CWND_LOG_NOADV_CA);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->net_ack,
+ SCTP_CWND_LOG_NOADV_CA);
+ }
dif = net->cwnd - (net->flight_size +
net->net_ack);
}
}
} else {
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, net->mtu,
- SCTP_CWND_LOG_NO_CUMACK);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->mtu,
+ SCTP_CWND_LOG_NO_CUMACK);
+ }
}
skip_cwnd_update:
/*
@@ -4113,13 +4094,13 @@ sctp_window_probe_recovery(struct sctp_tcb *stcb,
/* First setup this one and get it moved back */
tp1->sent = SCTP_DATAGRAM_UNSENT;
tp1->window_probe = 0;
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_WP,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_WP,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(tp1);
sctp_total_flight_decrease(stcb, tp1);
TAILQ_REMOVE(&asoc->sent_queue, tp1, sctp_next);
@@ -4159,10 +4140,10 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
int j, done_once = 0;
-#ifdef SCTP_LOG_SACK_ARRIVALS
- sctp_misc_ints(SCTP_SACK_LOG_EXPRESS, cumack,
- rwnd, stcb->asoc.last_acked_seq, stcb->asoc.peers_rwnd);
-#endif
+ if (sctp_logging_level & SCTP_LOG_SACK_ARRIVALS_ENABLE) {
+ sctp_misc_ints(SCTP_SACK_LOG_EXPRESS, cumack,
+ rwnd, stcb->asoc.last_acked_seq, stcb->asoc.peers_rwnd);
+ }
SCTP_TCB_LOCK_ASSERT(stcb);
asoc = &stcb->asoc;
old_rwnd = asoc->peers_rwnd;
@@ -4261,14 +4242,13 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
* occur during marking
*/
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
-
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(tp1);
sctp_total_flight_decrease(stcb, tp1);
}
@@ -4310,9 +4290,9 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
tp1->whoTo->find_pseudo_cumack = 1;
tp1->whoTo->find_rtx_pseudo_cumack = 1;
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
+ }
}
if (tp1->sent == SCTP_DATAGRAM_RESEND) {
sctp_ucount_decr(asoc->sent_queue_retran_cnt);
@@ -4332,14 +4312,14 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
sctp_free_bufspace(stcb, asoc, tp1, 1);
sctp_m_freem(tp1->data);
}
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(asoc->last_acked_seq,
- cumack,
- tp1->rec.data.TSN_seq,
- 0,
- 0,
- SCTP_LOG_FREE_SENT);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(asoc->last_acked_seq,
+ cumack,
+ tp1->rec.data.TSN_seq,
+ 0,
+ 0,
+ SCTP_LOG_FREE_SENT);
+ }
tp1->data = NULL;
asoc->sent_queue_cnt--;
sctp_free_remote_addr(tp1->whoTo);
@@ -4349,14 +4329,14 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
}
if (stcb->sctp_socket) {
SOCKBUF_LOCK(&stcb->sctp_socket->so_snd);
-#ifdef SCTP_WAKE_LOGGING
- sctp_wakeup_log(stcb, cumack, 1, SCTP_WAKESND_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_WAKE_LOGGING_ENABLE) {
+ sctp_wakeup_log(stcb, cumack, 1, SCTP_WAKESND_FROM_SACK);
+ }
sctp_sowwakeup_locked(stcb->sctp_ep, stcb->sctp_socket);
-#ifdef SCTP_WAKE_LOGGING
} else {
- sctp_wakeup_log(stcb, cumack, 1, SCTP_NOWAKE_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_WAKE_LOGGING_ENABLE) {
+ sctp_wakeup_log(stcb, cumack, 1, SCTP_NOWAKE_FROM_SACK);
+ }
}
@@ -4586,14 +4566,13 @@ again:
stcb->sctp_ep, stcb, asoc->primary_destination);
}
}
-#ifdef SCTP_SACK_RWND_LOGGING
- sctp_misc_ints(SCTP_SACK_RWND_UPDATE,
- rwnd,
- stcb->asoc.peers_rwnd,
- stcb->asoc.total_flight,
- stcb->asoc.total_output_queue_size);
-
-#endif
+ if (sctp_logging_level & SCTP_SACK_RWND_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_SACK_RWND_UPDATE,
+ rwnd,
+ stcb->asoc.peers_rwnd,
+ stcb->asoc.total_flight,
+ stcb->asoc.total_output_queue_size);
+ }
}
@@ -4658,10 +4637,10 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
num_seg = ntohs(sack->num_gap_ack_blks);
a_rwnd = rwnd;
-#ifdef SCTP_LOG_SACK_ARRIVALS
- sctp_misc_ints(SCTP_SACK_LOG_NORMAL, cum_ack,
- rwnd, stcb->asoc.last_acked_seq, stcb->asoc.peers_rwnd);
-#endif
+ if (sctp_logging_level & SCTP_LOG_SACK_ARRIVALS_ENABLE) {
+ sctp_misc_ints(SCTP_SACK_LOG_NORMAL, cum_ack,
+ rwnd, stcb->asoc.last_acked_seq, stcb->asoc.peers_rwnd);
+ }
/* CMT DAC algo */
cmt_dac_flag = ch->ch.chunk_flags & SCTP_SACK_CMT_DAC;
num_dup = ntohs(sack->num_dup_tsns);
@@ -4669,16 +4648,15 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
old_rwnd = stcb->asoc.peers_rwnd;
stcb->asoc.overall_error_count = 0;
asoc = &stcb->asoc;
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(asoc->last_acked_seq,
- cum_ack,
- 0,
- num_seg,
- num_dup,
- SCTP_LOG_NEW_SACK);
-#endif
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- if (num_dup) {
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(asoc->last_acked_seq,
+ cum_ack,
+ 0,
+ num_seg,
+ num_dup,
+ SCTP_LOG_NEW_SACK);
+ }
+ if ((num_dup) && (sctp_logging_level & (SCTP_FR_LOGGING_ENABLE | SCTP_EARLYFR_LOGGING_ENABLE))) {
int off_to_dup, iii;
uint32_t *dupdata;
@@ -4695,7 +4673,6 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
off_to_dup, num_dup, sack_length, num_seg);
}
}
-#endif
if (sctp_strict_sacks) {
/* reality check */
if (!TAILQ_EMPTY(&asoc->sent_queue)) {
@@ -4759,10 +4736,10 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
(asoc->stream_queue_cnt == 0)
) {
/* nothing left on send/sent and strmq */
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
- asoc->peers_rwnd, 0, 0, a_rwnd);
-#endif
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
+ asoc->peers_rwnd, 0, 0, a_rwnd);
+ }
asoc->peers_rwnd = a_rwnd;
if (asoc->sent_queue_retran_cnt) {
asoc->sent_queue_retran_cnt = 0;
@@ -4842,13 +4819,13 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
~SCTP_ADDR_UNCONFIRMED;
}
if (tp1->sent < SCTP_DATAGRAM_RESEND) {
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_CA,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(tp1);
sctp_total_flight_decrease(stcb, tp1);
}
@@ -4892,17 +4869,17 @@ sctp_handle_sack(struct sctp_sack_chunk *ch, struct sctp_tcb *stcb,
tp1->whoTo->find_rtx_pseudo_cumack = 1;
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(asoc->last_acked_seq,
- cum_ack,
- tp1->rec.data.TSN_seq,
- 0,
- 0,
- SCTP_LOG_TSN_ACKED);
-#endif
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(asoc->last_acked_seq,
+ cum_ack,
+ tp1->rec.data.TSN_seq,
+ 0,
+ 0,
+ SCTP_LOG_TSN_ACKED);
+ }
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, tp1->whoTo, tp1->rec.data.TSN_seq, SCTP_CWND_LOG_FROM_SACK);
+ }
}
if (tp1->sent == SCTP_DATAGRAM_RESEND) {
sctp_ucount_decr(asoc->sent_queue_retran_cnt);
@@ -5034,14 +5011,14 @@ skip_segments:
asoc->sent_queue_cnt_removeable--;
}
}
-#ifdef SCTP_SACK_LOGGING
- sctp_log_sack(asoc->last_acked_seq,
- cum_ack,
- tp1->rec.data.TSN_seq,
- 0,
- 0,
- SCTP_LOG_FREE_SENT);
-#endif
+ if (sctp_logging_level & SCTP_SACK_LOGGING_ENABLE) {
+ sctp_log_sack(asoc->last_acked_seq,
+ cum_ack,
+ tp1->rec.data.TSN_seq,
+ 0,
+ 0,
+ SCTP_LOG_FREE_SENT);
+ }
tp1->data = NULL;
asoc->sent_queue_cnt--;
sctp_free_remote_addr(tp1->whoTo);
@@ -5054,14 +5031,14 @@ skip_segments:
done_with_it:
if ((wake_him) && (stcb->sctp_socket)) {
SOCKBUF_LOCK(&stcb->sctp_socket->so_snd);
-#ifdef SCTP_WAKE_LOGGING
- sctp_wakeup_log(stcb, cum_ack, wake_him, SCTP_WAKESND_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_WAKE_LOGGING_ENABLE) {
+ sctp_wakeup_log(stcb, cum_ack, wake_him, SCTP_WAKESND_FROM_SACK);
+ }
sctp_sowwakeup_locked(stcb->sctp_ep, stcb->sctp_socket);
-#ifdef SCTP_WAKE_LOGGING
} else {
- sctp_wakeup_log(stcb, cum_ack, wake_him, SCTP_NOWAKE_FROM_SACK);
-#endif
+ if (sctp_logging_level & SCTP_WAKE_LOGGING_ENABLE) {
+ sctp_wakeup_log(stcb, cum_ack, wake_him, SCTP_NOWAKE_FROM_SACK);
+ }
}
if (asoc->fast_retran_loss_recovery && accum_moved) {
@@ -5094,13 +5071,13 @@ done_with_it:
if ((tp1->sent > SCTP_DATAGRAM_RESEND) &&
(tp1->sent < SCTP_FORWARD_TSN_SKIP)) {
tp1->sent = SCTP_DATAGRAM_SENT;
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) tp1->whoTo,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_UP_REVOKE,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) tp1->whoTo,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_increase(tp1);
sctp_total_flight_increase(stcb, tp1);
tp1->rec.data.chunk_was_revoked = 1;
@@ -5153,10 +5130,10 @@ done_with_it:
/**********************************/
if (TAILQ_EMPTY(&asoc->send_queue) && TAILQ_EMPTY(&asoc->sent_queue)) {
/* nothing left on sendqueue.. consider done */
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
- asoc->peers_rwnd, 0, 0, a_rwnd);
-#endif
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
+ asoc->peers_rwnd, 0, 0, a_rwnd);
+ }
asoc->peers_rwnd = a_rwnd;
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
/* SWS sender side engages */
@@ -5315,19 +5292,17 @@ done_with_it:
#ifdef SCTP_HIGH_SPEED
sctp_hs_cwnd_decrease(stcb, net);
#else
-#ifdef SCTP_CWND_MONITOR
int old_cwnd = net->cwnd;
-#endif
net->ssthresh = net->cwnd / 2;
if (net->ssthresh < (net->mtu * 2)) {
net->ssthresh = 2 * net->mtu;
}
net->cwnd = net->ssthresh;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
- SCTP_CWND_LOG_FROM_FR);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
+ SCTP_CWND_LOG_FROM_FR);
+ }
#endif
lchk = TAILQ_FIRST(&asoc->send_queue);
@@ -5457,11 +5432,10 @@ done_with_it:
}
/* Adjust and set the new rwnd value */
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
- asoc->peers_rwnd, asoc->total_flight, (asoc->sent_queue_cnt * sctp_peer_chunk_oh), a_rwnd);
-#endif
-
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd_set(SCTP_SET_PEER_RWND_VIA_SACK,
+ asoc->peers_rwnd, asoc->total_flight, (asoc->sent_queue_cnt * sctp_peer_chunk_oh), a_rwnd);
+ }
asoc->peers_rwnd = sctp_sbspace_sub(a_rwnd,
(uint32_t) (asoc->total_flight + (asoc->sent_queue_cnt * sctp_peer_chunk_oh)));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
@@ -5538,15 +5512,13 @@ again:
done_once = 1;
goto again;
}
-#ifdef SCTP_SACK_RWND_LOGGING
- sctp_misc_ints(SCTP_SACK_RWND_UPDATE,
- a_rwnd,
- stcb->asoc.peers_rwnd,
- stcb->asoc.total_flight,
- stcb->asoc.total_output_queue_size);
-
-#endif
-
+ if (sctp_logging_level & SCTP_SACK_RWND_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_SACK_RWND_UPDATE,
+ a_rwnd,
+ stcb->asoc.peers_rwnd,
+ stcb->asoc.total_flight,
+ stcb->asoc.total_output_queue_size);
+ }
}
void
@@ -5686,9 +5658,9 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
if (compare_with_wrap(new_cum_tsn, asoc->highest_tsn_inside_map,
MAX_TSN)) {
asoc->highest_tsn_inside_map = new_cum_tsn;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, 0, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, 0, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
+ }
}
/*
* now we know the new TSN is more advanced, let's find the actual
@@ -5767,9 +5739,9 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
asoc->highest_tsn_inside_map = new_cum_tsn - 1;
asoc->mapping_array_base_tsn = new_cum_tsn;
asoc->cumulative_tsn = asoc->highest_tsn_inside_map;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, 3, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, 3, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
+ }
asoc->last_echo_tsn = asoc->highest_tsn_inside_map;
}
/*************************************************************/
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index 1042159..0baeaba 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -183,10 +183,9 @@ sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb,
TAILQ_FOREACH(lnet, &asoc->nets, sctp_next) {
lnet->ssthresh = asoc->peers_rwnd;
-#if defined(SCTP_CWND_MONITOR) || defined(SCTP_CWND_LOGGING)
- sctp_log_cwnd(stcb, lnet, 0, SCTP_CWND_INITIALIZATION);
-#endif
-
+ if (sctp_logging_level & (SCTP_CWND_MONITOR_ENABLE | SCTP_CWND_LOGGING_ENABLE)) {
+ sctp_log_cwnd(stcb, lnet, 0, SCTP_CWND_INITIALIZATION);
+ }
}
}
SCTP_TCB_SEND_LOCK(stcb);
@@ -233,9 +232,9 @@ sctp_process_init(struct sctp_init_chunk *cp, struct sctp_tcb *stcb,
asoc->streamoutcnt = asoc->pre_open_streams;
/* init tsn's */
asoc->highest_tsn_inside_map = asoc->asconf_seq_in = ntohl(init->initial_tsn) - 1;
-#ifdef SCTP_MAP_LOGGING
- sctp_log_map(0, 5, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
-#endif
+ if (sctp_logging_level & SCTP_MAP_LOGGING_ENABLE) {
+ sctp_log_map(0, 5, asoc->highest_tsn_inside_map, SCTP_MAP_SLIDE_RESULT);
+ }
/* This is the next one we expect */
asoc->str_reset_seq_in = asoc->asconf_seq_in + 1;
@@ -2312,11 +2311,9 @@ sctp_handle_ecn_echo(struct sctp_ecne_chunk *cp,
net = stcb->asoc.primary_destination;
if (compare_with_wrap(tsn, stcb->asoc.last_cwr_tsn, MAX_TSN)) {
-#ifdef SCTP_CWND_MONITOR
int old_cwnd;
old_cwnd = net->cwnd;
-#endif
SCTP_STAT_INCR(sctps_ecnereducedcwnd);
net->ssthresh = net->cwnd / 2;
if (net->ssthresh < net->mtu) {
@@ -2325,9 +2322,9 @@ sctp_handle_ecn_echo(struct sctp_ecne_chunk *cp,
net->RTO <<= 1;
}
net->cwnd = net->ssthresh;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_SAT);
+ }
/*
* we reduce once every RTT. So we will only lower cwnd at
* the next sending seq i.e. the resync_tsn.
@@ -2527,13 +2524,13 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_chunk_desc *desc,
stcb, tp1->whoTo);
/* fix counts and things */
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PDRP,
- tp1->whoTo->flight_size,
- tp1->book_size,
- (uintptr_t) stcb,
- tp1->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PDRP,
+ tp1->whoTo->flight_size,
+ tp1->book_size,
+ (uintptr_t) stcb,
+ tp1->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(tp1);
sctp_total_flight_decrease(stcb, tp1);
} {
@@ -3322,10 +3319,8 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
uint32_t bw_avail;
int rtt, incr;
-#ifdef SCTP_CWND_MONITOR
int old_cwnd = net->cwnd;
-#endif
/* need real RTT for this calc */
rtt = ((net->lastsa >> 2) + net->lastsv) >> 1;
/* get bottle neck bw */
@@ -3420,13 +3415,13 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
/* We always have 1 MTU */
net->cwnd = net->mtu;
}
-#ifdef SCTP_CWND_MONITOR
if (net->cwnd - old_cwnd != 0) {
/* log only changes */
- sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
- SCTP_CWND_LOG_FROM_SAT);
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd),
+ SCTP_CWND_LOG_FROM_SAT);
+ }
}
-#endif
}
}
@@ -3650,6 +3645,7 @@ process_control_chunks:
chk_length = ntohs(ch->chunk_length);
SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_process_control: processing a chunk type=%u, len=%u\n",
ch->chunk_type, chk_length);
+ SCTP_LTRACE_CHK(inp, stcb, ch->chunk_type, chk_length);
if (chk_length < sizeof(*ch) ||
(*offset + (int)chk_length) > length) {
*offset = length;
@@ -4711,12 +4707,14 @@ sctp_input(i_pak, off)
#ifdef SCTP_MBUF_LOGGING
/* Log in any input mbufs */
- mat = m;
- while (mat) {
- if (SCTP_BUF_IS_EXTENDED(mat)) {
- sctp_log_mb(mat, SCTP_MBUF_INPUT);
+ if (sctp_logging_level & SCTP_MBUF_LOGGING_ENABLE) {
+ mat = m;
+ while (mat) {
+ if (SCTP_BUF_IS_EXTENDED(mat)) {
+ sctp_log_mb(mat, SCTP_MBUF_INPUT);
+ }
+ mat = SCTP_BUF_NEXT(mat);
}
- mat = SCTP_BUF_NEXT(mat);
}
#endif
#ifdef SCTP_PACKET_LOGGING
diff --git a/sys/netinet/sctp_lock_bsd.h b/sys/netinet/sctp_lock_bsd.h
index 59cd3f1..b1afc90 100644
--- a/sys/netinet/sctp_lock_bsd.h
+++ b/sys/netinet/sctp_lock_bsd.h
@@ -82,15 +82,6 @@ extern int sctp_logoff_stuff;
#define SCTP_STATLOG_UNLOCK()
#define SCTP_STATLOG_DESTROY()
-#define SCTP_STATLOG_GETREF(x) { \
- x = atomic_fetchadd_int(&global_sctp_cwnd_log_at, 1); \
- if(x == SCTP_STAT_LOG_SIZE) { \
- global_sctp_cwnd_log_at = 1; \
- x = 0; \
- global_sctp_cwnd_log_rolled = 1; \
- } \
-}
-
#define SCTP_INP_INFO_LOCK_INIT() \
mtx_init(&sctppcbinfo.ipi_ep_mtx, "sctp-info", "inp_info", MTX_DEF)
@@ -187,12 +178,12 @@ extern int sctp_logoff_stuff;
#ifdef SCTP_LOCK_LOGGING
#define SCTP_INP_RLOCK(_inp) do { \
- sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
+ if(sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
mtx_lock(&(_inp)->inp_mtx); \
} while (0)
#define SCTP_INP_WLOCK(_inp) do { \
- sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
+ if(sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_INP);\
mtx_lock(&(_inp)->inp_mtx); \
} while (0)
@@ -227,7 +218,7 @@ extern int sctp_logoff_stuff;
#ifdef SCTP_LOCK_LOGGING
#define SCTP_ASOC_CREATE_LOCK(_inp) \
do { \
- sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
+ if(sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
mtx_lock(&(_inp)->inp_create_mtx); \
} while (0)
#else
@@ -257,7 +248,7 @@ extern int sctp_logoff_stuff;
#ifdef SCTP_LOCK_LOGGING
#define SCTP_TCB_LOCK(_tcb) do { \
- sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
+ if(sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
mtx_lock(&(_tcb)->tcb_mtx); \
} while (0)
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index b3dbb9e..8f5b1cf 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include "opt_inet.h"
#include "opt_sctp.h"
#include <sys/param.h>
+#include <sys/ktr.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
@@ -157,6 +158,18 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT);
#endif
#define SCTP_PRINTF(params...) printf(params)
+#ifdef SCTP_LTRACE_CHUNKS
+#define SCTP_LTRACE_CHK(a, b, c, d) if(sctp_logging_level & SCTP_LTRACE_CHUNK_ENABLE) CTR6(KTR_NET, "SCTP:%d[%d]:%x-%x-%x-%x", SCTP_LOG_CHUNK_PROC, 0, a, b, c, d)
+#else
+#define SCTP_LTRACE_CHK(a, b, c, d)
+#endif
+
+#ifdef SCTP_LTRACE_ERRORS
+#define SCTP_LTRACE_ERR(a, b, c, d) if(sctp_logging_level & SCTP_LTRACE_ERROR_ENABLE) CTR6(KTR_NET, "SCTP:%d[%d]:%x-%x-%x-%x", SCTP_LOG_ERROR_RET, 0, a, b, c, d)
+#else
+#define SCTP_LTRACE_ERR(a, b, c, d)
+#endif
+
/*
* Local address and interface list handling
*/
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 1e1fc21..1c52c33 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -3295,6 +3295,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
newm = sctp_get_mbuf_for_msg(sizeof(struct ip), 1, M_DONTWAIT, 1, MT_DATA);
if (newm == NULL) {
sctp_m_freem(m);
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
SCTP_ALIGN_TO_END(newm, sizeof(struct ip));
@@ -3450,6 +3451,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
/* failed to prepend data, give up */
sctp_m_freem(m);
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
#ifdef SCTP_PACKET_LOGGING
@@ -3523,6 +3525,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
newm = sctp_get_mbuf_for_msg(sizeof(struct ip6_hdr), 1, M_DONTWAIT, 1, MT_DATA);
if (newm == NULL) {
sctp_m_freem(m);
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
SCTP_ALIGN_TO_END(newm, sizeof(struct ip6_hdr));
@@ -3666,6 +3669,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
if (SCTP_GET_HEADER_FOR_OUTPUT(o_pak)) {
/* failed to prepend data, give up */
sctp_m_freem(m);
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
#ifdef SCTP_PACKET_LOGGING
@@ -5343,6 +5347,7 @@ sctp_msg_append(struct sctp_tcb *stcb,
}
sctp_alloc_a_strmoq(stcb, sp);
if (sp == NULL) {
+ SCTP_LTRACE_ERR(stcb->sctp_ep, stcb, ENOMEM, 0);
error = ENOMEM;
goto out_now;
}
@@ -5818,6 +5823,7 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,
SCTP_M_COPYAL);
if (ca == NULL) {
sctp_m_freem(m);
+ SCTP_LTRACE_ERR(inp, NULL, ENOMEM, 0);
return (ENOMEM);
}
memset(ca, 0, sizeof(struct sctp_copy_all));
@@ -5835,6 +5841,7 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,
ca->m = sctp_copy_out_all(uio, ca->sndlen);
if (ca->m == NULL) {
SCTP_FREE(ca, SCTP_M_COPYAL);
+ SCTP_LTRACE_ERR(inp, NULL, ENOMEM, 0);
return (ENOMEM);
}
} else {
@@ -5980,19 +5987,19 @@ all_done:
data_list[i]->sent = SCTP_DATAGRAM_SENT;
data_list[i]->snd_count = 1;
data_list[i]->rec.data.chunk_was_revoked = 0;
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
- data_list[i]->whoTo->flight_size,
- data_list[i]->book_size,
- (uintptr_t) data_list[i]->whoTo,
- data_list[i]->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
+ data_list[i]->whoTo->flight_size,
+ data_list[i]->book_size,
+ (uintptr_t) data_list[i]->whoTo,
+ data_list[i]->rec.data.TSN_seq);
+ }
sctp_flight_size_increase(data_list[i]);
sctp_total_flight_increase(stcb, data_list[i]);
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd(SCTP_DECREASE_PEER_RWND,
- asoc->peers_rwnd, data_list[i]->send_size, sctp_peer_chunk_oh);
-#endif
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd(SCTP_DECREASE_PEER_RWND,
+ asoc->peers_rwnd, data_list[i]->send_size, sctp_peer_chunk_oh);
+ }
asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd,
(uint32_t) (data_list[i]->send_size + sctp_peer_chunk_oh));
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
@@ -6827,9 +6834,9 @@ one_more_time:
* copied out of the stream buffers. Note mostly
* copy by reference (we hope).
*/
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FILL_OUTQ_CALLED);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, 0, SCTP_CWND_LOG_FILL_OUTQ_CALLED);
+ }
sctp_fill_outqueue(stcb, net, frag_point, eeor_mode);
}
if (start_at != TAILQ_FIRST(&asoc->nets)) {
@@ -6890,9 +6897,9 @@ again_one_more_time:
ifp = net->ro.ro_rt->rt_ifp;
if ((ifp->if_snd.ifq_len + 2) >= ifp->if_snd.ifq_maxlen) {
SCTP_STAT_INCR(sctps_ifnomemqueued);
-#ifdef SCTP_LOG_MAXBURST
- sctp_log_maxburst(stcb, net, ifp->if_snd.ifq_len, ifp->if_snd.ifq_maxlen, SCTP_MAX_IFP_APPLIED);
-#endif
+ if (sctp_logging_level & SCTP_LOG_MAXBURST_ENABLE) {
+ sctp_log_maxburst(stcb, net, ifp->if_snd.ifq_len, ifp->if_snd.ifq_maxlen, SCTP_MAX_IFP_APPLIED);
+ }
continue;
}
}
@@ -6987,6 +6994,7 @@ again_one_more_time:
chk->send_size, chk->copy_by_ref);
if (outchain == NULL) {
*reason_code = 8;
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
@@ -7231,6 +7239,7 @@ again_one_more_time:
sctp_timer_start(SCTP_TIMER_TYPE_SEND, inp, stcb, net);
}
*reason_code = 3;
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
/* upate our MTU size */
@@ -7428,9 +7437,9 @@ again_one_more_time:
break;
}
}
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, tsns_sent, SCTP_CWND_LOG_FROM_SEND);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, tsns_sent, SCTP_CWND_LOG_FROM_SEND);
+ }
}
if (old_startat == NULL) {
old_startat = send_start_at;
@@ -7441,9 +7450,9 @@ again_one_more_time:
* At the end there should be no NON timed chunks hanging on this
* queue.
*/
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, *num_out, SCTP_CWND_LOG_FROM_SEND);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, *num_out, SCTP_CWND_LOG_FROM_SEND);
+ }
if ((*num_out == 0) && (*reason_code == 0)) {
*reason_code = 4;
} else {
@@ -8140,6 +8149,7 @@ one_chunk_around:
}
m = sctp_copy_mbufchain(chk->data, m, &endofchain, 0, chk->send_size, chk->copy_by_ref);
if (m == NULL) {
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
/* Do clear IP_DF ? */
@@ -8191,6 +8201,7 @@ one_chunk_around:
}
m = sctp_copy_mbufchain(fwd->data, m, &endofchain, 0, fwd->send_size, fwd->copy_by_ref);
if (m == NULL) {
+ SCTP_LTRACE_ERR(inp, stcb, ENOMEM, 0);
return (ENOMEM);
}
/* Do clear IP_DF ? */
@@ -8307,21 +8318,21 @@ one_chunk_around:
} else {
-#ifdef SCTP_LOG_RWND
- sctp_log_rwnd(SCTP_DECREASE_PEER_RWND,
- asoc->peers_rwnd, data_list[i]->send_size, sctp_peer_chunk_oh);
-#endif
+ if (sctp_logging_level & SCTP_LOG_RWND_ENABLE) {
+ sctp_log_rwnd(SCTP_DECREASE_PEER_RWND,
+ asoc->peers_rwnd, data_list[i]->send_size, sctp_peer_chunk_oh);
+ }
asoc->peers_rwnd = sctp_sbspace_sub(asoc->peers_rwnd,
(uint32_t) (data_list[i]->send_size +
sctp_peer_chunk_oh));
}
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_UP_RSND,
- data_list[i]->whoTo->flight_size,
- data_list[i]->book_size,
- (uintptr_t) data_list[i]->whoTo,
- data_list[i]->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_UP_RSND,
+ data_list[i]->whoTo->flight_size,
+ data_list[i]->book_size,
+ (uintptr_t) data_list[i]->whoTo,
+ data_list[i]->rec.data.TSN_seq);
+ }
sctp_flight_size_increase(data_list[i]);
sctp_total_flight_increase(stcb, data_list[i]);
if (asoc->peers_rwnd < stcb->sctp_ep->sctp_ep.sctp_sws_sender) {
@@ -8348,9 +8359,9 @@ one_chunk_around:
}
}
}
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, net, tsns_sent, SCTP_CWND_LOG_FROM_RESEND);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, net, tsns_sent, SCTP_CWND_LOG_FROM_RESEND);
+ }
#ifdef SCTP_AUDITING_ENABLED
sctp_auditing(21, inp, stcb, NULL);
#endif
@@ -8562,13 +8573,12 @@ sctp_chunk_output(struct sctp_inpcb *inp,
old_cwnd = net->cwnd;
net->cwnd = (net->flight_size + (burst_limit * net->mtu));
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_BRST);
-#endif
-
-#ifdef SCTP_LOG_MAXBURST
- sctp_log_maxburst(stcb, net, 0, burst_limit, SCTP_MAX_BURST_APPLIED);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (net->cwnd - old_cwnd), SCTP_CWND_LOG_FROM_BRST);
+ }
+ if (sctp_logging_level & SCTP_LOG_MAXBURST_ENABLE) {
+ sctp_log_maxburst(stcb, net, 0, burst_limit, SCTP_MAX_BURST_APPLIED);
+ }
SCTP_STAT_INCR(sctps_maxburstqueued);
}
net->fast_retran_ip = 0;
@@ -8589,26 +8599,25 @@ sctp_chunk_output(struct sctp_inpcb *inp,
&now, &now_filled, frag_point);
if (error) {
SCTPDBG(SCTP_DEBUG_OUTPUT1, "Error %d was returned from med-c-op\n", error);
-#ifdef SCTP_LOG_MAXBURST
- sctp_log_maxburst(stcb, asoc->primary_destination, error, burst_cnt, SCTP_MAX_BURST_ERROR_STOP);
-#endif
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, NULL, error, SCTP_SEND_NOW_COMPLETES);
- sctp_log_cwnd(stcb, NULL, 0xdeadbeef, SCTP_SEND_NOW_COMPLETES);
-#endif
-
+ if (sctp_logging_level & SCTP_LOG_MAXBURST_ENABLE) {
+ sctp_log_maxburst(stcb, asoc->primary_destination, error, burst_cnt, SCTP_MAX_BURST_ERROR_STOP);
+ }
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, NULL, error, SCTP_SEND_NOW_COMPLETES);
+ sctp_log_cwnd(stcb, NULL, 0xdeadbeef, SCTP_SEND_NOW_COMPLETES);
+ }
break;
}
SCTPDBG(SCTP_DEBUG_OUTPUT3, "m-c-o put out %d\n", num_out);
tot_out += num_out;
burst_cnt++;
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, NULL, num_out, SCTP_SEND_NOW_COMPLETES);
- if (num_out == 0) {
- sctp_log_cwnd(stcb, NULL, reason_code, SCTP_SEND_NOW_COMPLETES);
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, NULL, num_out, SCTP_SEND_NOW_COMPLETES);
+ if (num_out == 0) {
+ sctp_log_cwnd(stcb, NULL, reason_code, SCTP_SEND_NOW_COMPLETES);
+ }
}
-#endif
if (nagle_on) {
/*-
* When nagle is on, we look at how much is un_sent, then
@@ -8640,16 +8649,16 @@ sctp_chunk_output(struct sctp_inpcb *inp,
if (burst_cnt >= burst_limit) {
SCTP_STAT_INCR(sctps_maxburstqueued);
asoc->burst_limit_applied = 1;
-#ifdef SCTP_LOG_MAXBURST
- sctp_log_maxburst(stcb, asoc->primary_destination, 0, burst_cnt, SCTP_MAX_BURST_APPLIED);
-#endif
+ if (sctp_logging_level & SCTP_LOG_MAXBURST_ENABLE) {
+ sctp_log_maxburst(stcb, asoc->primary_destination, 0, burst_cnt, SCTP_MAX_BURST_APPLIED);
+ }
} else {
asoc->burst_limit_applied = 0;
}
}
-#ifdef SCTP_CWND_LOGGING
- sctp_log_cwnd(stcb, NULL, tot_out, SCTP_SEND_NOW_COMPLETES);
-#endif
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
+ sctp_log_cwnd(stcb, NULL, tot_out, SCTP_SEND_NOW_COMPLETES);
+ }
SCTPDBG(SCTP_DEBUG_OUTPUT1, "Ok, we have put out %d chunks\n",
tot_out);
@@ -10011,6 +10020,7 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
}
sctp_alloc_a_chunk(stcb, chk);
if (chk == NULL) {
+ SCTP_LTRACE_ERR(stcb->sctp_ep, stcb, ENOMEM, 0);
return (ENOMEM);
}
chk->copy_by_ref = 0;
@@ -10024,6 +10034,7 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_DONTWAIT, 1, MT_DATA);
if (chk->data == NULL) {
sctp_free_a_chunk(stcb, chk);
+ SCTP_LTRACE_ERR(stcb->sctp_ep, stcb, ENOMEM, 0);
return (ENOMEM);
}
SCTP_BUF_RESV_UF(chk->data, SCTP_MIN_OVERHEAD);
@@ -11130,10 +11141,10 @@ sctp_lower_sosend(struct socket *so,
/* No room right no ! */
SOCKBUF_LOCK(&so->so_snd);
while (SCTP_SB_LIMIT_SND(so) < (stcb->asoc.total_output_queue_size + sctp_add_more_threshold)) {
-#ifdef SCTP_BLK_LOGGING
- sctp_log_block(SCTP_BLOCK_LOG_INTO_BLKA,
- so, asoc, uio->uio_resid);
-#endif
+ if (sctp_logging_level & SCTP_BLK_LOGGING_ENABLE) {
+ sctp_log_block(SCTP_BLOCK_LOG_INTO_BLKA,
+ so, asoc, uio->uio_resid);
+ }
be.error = 0;
stcb->block_entry = &be;
error = sbwait(&so->so_snd);
@@ -11149,10 +11160,10 @@ sctp_lower_sosend(struct socket *so,
SOCKBUF_UNLOCK(&so->so_snd);
goto out_unlocked;
}
-#ifdef SCTP_BLK_LOGGING
- sctp_log_block(SCTP_BLOCK_LOG_OUTOF_BLK,
- so, asoc, stcb->asoc.total_output_queue_size);
-#endif
+ if (sctp_logging_level & SCTP_BLK_LOGGING_ENABLE) {
+ sctp_log_block(SCTP_BLOCK_LOG_OUTOF_BLK,
+ so, asoc, stcb->asoc.total_output_queue_size);
+ }
if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
goto out_unlocked;
}
@@ -11394,25 +11405,28 @@ sctp_lower_sosend(struct socket *so,
* Don't send anything and let SACKs drive out the
* data unless wen have a "full" segment to send.
*/
-#ifdef SCTP_NAGLE_LOGGING
- sctp_log_nagle_event(stcb, SCTP_NAGLE_APPLIED);
-#endif
+ if (sctp_logging_level & SCTP_NAGLE_LOGGING_ENABLE) {
+ sctp_log_nagle_event(stcb, SCTP_NAGLE_APPLIED);
+ }
SCTP_STAT_INCR(sctps_naglequeued);
nagle_applies = 1;
} else {
-#ifdef SCTP_NAGLE_LOGGING
- if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_NODELAY))
- sctp_log_nagle_event(stcb, SCTP_NAGLE_SKIPPED);
-#endif
+ if (sctp_logging_level & SCTP_NAGLE_LOGGING_ENABLE) {
+ if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_NODELAY))
+ sctp_log_nagle_event(stcb, SCTP_NAGLE_SKIPPED);
+ }
SCTP_STAT_INCR(sctps_naglesent);
nagle_applies = 0;
}
/* What about the INIT, send it maybe */
-#ifdef SCTP_BLK_LOGGING
- sctp_misc_ints(SCTP_CWNDLOG_PRESEND, queue_only_for_init, queue_only, nagle_applies, un_sent);
- sctp_misc_ints(SCTP_CWNDLOG_PRESEND, stcb->asoc.total_output_queue_size, stcb->asoc.total_flight,
- stcb->asoc.chunks_on_out_queue, stcb->asoc.total_flight_count);
-#endif
+ if (sctp_logging_level & SCTP_BLK_LOGGING_ENABLE) {
+
+ sctp_misc_ints(SCTP_CWNDLOG_PRESEND, queue_only_for_init, queue_only,
+ nagle_applies, un_sent);
+ sctp_misc_ints(SCTP_CWNDLOG_PRESEND, stcb->asoc.total_output_queue_size,
+ stcb->asoc.total_flight,
+ stcb->asoc.chunks_on_out_queue, stcb->asoc.total_flight_count);
+ }
if (queue_only_for_init) {
if (hold_tcblock == 0) {
SCTP_TCB_LOCK(stcb);
@@ -11472,10 +11486,10 @@ sctp_lower_sosend(struct socket *so,
* wakeup flag in place.
*/
if (SCTP_SB_LIMIT_SND(so) < (stcb->asoc.total_output_queue_size + sctp_add_more_threshold)) {
-#ifdef SCTP_BLK_LOGGING
- sctp_log_block(SCTP_BLOCK_LOG_INTO_BLK,
- so, asoc, uio->uio_resid);
-#endif
+ if (sctp_logging_level & SCTP_BLK_LOGGING_ENABLE) {
+ sctp_log_block(SCTP_BLOCK_LOG_INTO_BLK,
+ so, asoc, uio->uio_resid);
+ }
be.error = 0;
stcb->block_entry = &be;
error = sbwait(&so->so_snd);
@@ -11492,10 +11506,10 @@ sctp_lower_sosend(struct socket *so,
SOCKBUF_UNLOCK(&so->so_snd);
goto out_unlocked;
}
-#ifdef SCTP_BLK_LOGGING
- sctp_log_block(SCTP_BLOCK_LOG_OUTOF_BLK,
- so, asoc, stcb->asoc.total_output_queue_size);
-#endif
+ if (sctp_logging_level & SCTP_BLK_LOGGING_ENABLE) {
+ sctp_log_block(SCTP_BLOCK_LOG_OUTOF_BLK,
+ so, asoc, stcb->asoc.total_output_queue_size);
+ }
}
SOCKBUF_UNLOCK(&so->so_snd);
if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
@@ -11658,16 +11672,16 @@ skip_out_eof:
* Don't send anything and let SACKs drive out the
* data unless wen have a "full" segment to send.
*/
-#ifdef SCTP_NAGLE_LOGGING
- sctp_log_nagle_event(stcb, SCTP_NAGLE_APPLIED);
-#endif
+ if (sctp_logging_level & SCTP_NAGLE_LOGGING_ENABLE) {
+ sctp_log_nagle_event(stcb, SCTP_NAGLE_APPLIED);
+ }
SCTP_STAT_INCR(sctps_naglequeued);
nagle_applies = 1;
} else {
-#ifdef SCTP_NAGLE_LOGGING
- if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_NODELAY))
- sctp_log_nagle_event(stcb, SCTP_NAGLE_SKIPPED);
-#endif
+ if (sctp_logging_level & SCTP_NAGLE_LOGGING_ENABLE) {
+ if (sctp_is_feature_off(inp, SCTP_PCB_FLAGS_NODELAY))
+ sctp_log_nagle_event(stcb, SCTP_NAGLE_SKIPPED);
+ }
SCTP_STAT_INCR(sctps_naglesent);
nagle_applies = 0;
}
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index ce71edc..0160aea 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -155,6 +155,7 @@ sctp_allocate_vrf(int vrf_id)
vrf->vrf_id = vrf_id;
LIST_INIT(&vrf->ifnlist);
vrf->total_ifa_count = 0;
+ vrf->refcount = 0;
/* now also setup table ids */
SCTP_INIT_VRF_TABLEID(vrf);
/* Init the HASH of addresses */
@@ -215,6 +216,19 @@ sctp_find_vrf(uint32_t vrf_id)
return (NULL);
}
+void
+sctp_free_vrf(struct sctp_vrf *vrf)
+{
+ int ret;
+
+ ret = atomic_fetchadd_int(&vrf->refcount, -1);
+ if (ret == 1) {
+ /* We zero'd the count */
+ LIST_REMOVE(vrf, next_vrf);
+ SCTP_FREE(vrf, SCTP_M_VRF);
+ atomic_subtract_int(&sctppcbinfo.ipi_count_vrfs, 1);
+ }
+}
void
sctp_free_ifn(struct sctp_ifn *sctp_ifnp)
@@ -224,6 +238,9 @@ sctp_free_ifn(struct sctp_ifn *sctp_ifnp)
ret = atomic_fetchadd_int(&sctp_ifnp->refcount, -1);
if (ret == 1) {
/* We zero'd the count */
+ if (sctp_ifnp->vrf) {
+ sctp_free_vrf(sctp_ifnp->vrf);
+ }
SCTP_FREE(sctp_ifnp, SCTP_M_IFN);
atomic_subtract_int(&sctppcbinfo.ipi_count_ifns, 1);
}
@@ -249,6 +266,9 @@ sctp_free_ifa(struct sctp_ifa *sctp_ifap)
ret = atomic_fetchadd_int(&sctp_ifap->refcount, -1);
if (ret == 1) {
/* We zero'd the count */
+ if (sctp_ifap->ifn_p) {
+ sctp_free_ifn(sctp_ifap->ifn_p);
+ }
SCTP_FREE(sctp_ifap, SCTP_M_IFA);
atomic_subtract_int(&sctppcbinfo.ipi_count_ifas, 1);
}
@@ -293,15 +313,19 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
/* How granular do we need the locks to be here? */
SCTP_IPI_ADDR_LOCK();
- vrf = sctp_find_vrf(vrf_id);
- if (vrf == NULL) {
- vrf = sctp_allocate_vrf(vrf_id);
+ sctp_ifnp = sctp_find_ifn(ifn, ifn_index);
+ if (sctp_ifnp) {
+ vrf = sctp_ifnp->vrf;
+ } else {
+ vrf = sctp_find_vrf(vrf_id);
if (vrf == NULL) {
- SCTP_IPI_ADDR_UNLOCK();
- return (NULL);
+ vrf = sctp_allocate_vrf(vrf_id);
+ if (vrf == NULL) {
+ SCTP_IPI_ADDR_UNLOCK();
+ return (NULL);
+ }
}
}
- sctp_ifnp = sctp_find_ifn(ifn, ifn_index);
if (sctp_ifnp == NULL) {
/*
* build one and add it, can't hold lock until after malloc
@@ -321,6 +345,7 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
sctp_ifnp->ifa_count = 0;
sctp_ifnp->refcount = 1;
sctp_ifnp->vrf = vrf;
+ atomic_add_int(&vrf->refcount, 1);
sctp_ifnp->ifn_mtu = SCTP_GATHER_MTU_FROM_IFN_INFO(ifn, ifn_index, addr->sa_family);
if (if_name != NULL) {
memcpy(sctp_ifnp->ifn_name, if_name, SCTP_IFNAMSIZ);
@@ -340,10 +365,15 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
/* Hmm, it already exists? */
if ((sctp_ifap->ifn_p) &&
(sctp_ifap->ifn_p->ifn_index == ifn_index)) {
+ if (new_ifn_af) {
+ /* Remove the created one that we don't want */
+ sctp_delete_ifn(sctp_ifap->ifn_p, 1);
+ }
if (sctp_ifap->localifa_flags & SCTP_BEING_DELETED) {
/* easy to solve, just switch back to active */
sctp_ifap->localifa_flags = SCTP_ADDR_VALID;
sctp_ifap->ifn_p = sctp_ifnp;
+ atomic_add_int(&sctp_ifap->ifn_p->refcount, 1);
exit_stage_left:
SCTP_IPI_ADDR_UNLOCK();
return (sctp_ifap);
@@ -356,6 +386,13 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
* The first IFN gets the address,
* duplicates are ignored.
*/
+ if (new_ifn_af) {
+ /*
+ * Remove the created one that we
+ * don't want
+ */
+ sctp_delete_ifn(sctp_ifap->ifn_p, 1);
+ }
goto exit_stage_left;
} else {
/* repair ifnp which was NULL ? */
@@ -2078,7 +2115,8 @@ sctp_isport_inuse(struct sctp_inpcb *inp, uint16_t lport, uint32_t vrf_id)
int
-sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
+sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
+ struct sctp_ifa *sctp_ifap, struct thread *p)
{
/* bind a ep to a socket address */
struct sctppcbhead *head;
@@ -2328,8 +2366,11 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
* zero out the port to find the address! yuck! can't do
* this earlier since need port for sctp_pcb_findep()
*/
- ifa = sctp_find_ifa_by_addr((struct sockaddr *)&store_sa,
- vrf_id, 0);
+ if (sctp_ifap)
+ ifa = sctp_ifap;
+ else
+ ifa = sctp_find_ifa_by_addr((struct sockaddr *)&store_sa,
+ vrf_id, 0);
if (ifa == NULL) {
/* Can't find an interface with that address */
SCTP_INP_WUNLOCK(inp);
@@ -2349,12 +2390,8 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
inp->sctp_flags &= ~SCTP_PCB_FLAGS_BOUNDALL;
/* allow bindx() to send ASCONF's for binding changes */
sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF);
- /* set the automatic addr changes from kernel flag */
- if (sctp_auto_asconf == 0) {
- sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
- } else {
- sctp_feature_on(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
- }
+ /* clear automatic addr changes from kernel flag */
+ sctp_feature_off(inp, SCTP_PCB_FLAGS_AUTO_ASCONF);
/* add this address to the endpoint list */
error = sctp_insert_laddr(&inp->sctp_addr_list, ifa, 0);
@@ -3168,10 +3205,9 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
sctp_set_initial_cc_param(stcb, net);
-#if defined(SCTP_CWND_MONITOR) || defined(SCTP_CWND_LOGGING)
- sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
-#endif
-
+ if (sctp_logging_level & (SCTP_CWND_MONITOR_ENABLE | SCTP_CWND_LOGGING_ENABLE)) {
+ sctp_log_cwnd(stcb, net, 0, SCTP_CWND_INITIALIZATION);
+ }
/*
* CMT: CUC algo - set find_pseudo_cumack to TRUE (1) at beginning
* of assoc (2005/06/27, iyengar@cis.udel.edu)
@@ -3343,7 +3379,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
* ephemerial bind for you.
*/
if ((err = sctp_inpcb_bind(inp->sctp_socket,
- (struct sockaddr *)NULL,
+ (struct sockaddr *)NULL, (struct sctp_ifa *)NULL,
(struct thread *)NULL
))) {
/* bind error, probably perm */
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index f232199..638def0 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -65,6 +65,7 @@ struct sctp_vrf {
uint32_t tbl_id_v6; /* default v6 table id */
uint32_t total_ifa_count;
u_long vrf_addr_hashmark;
+ uint32_t refcount;
};
struct sctp_ifn {
@@ -422,8 +423,8 @@ struct sctp_ifn *
sctp_find_ifn(void *ifn, uint32_t ifn_index);
struct sctp_vrf *sctp_allocate_vrf(int vrfid);
-
struct sctp_vrf *sctp_find_vrf(uint32_t vrfid);
+void sctp_free_vrf(struct sctp_vrf *vrf);
struct sctp_ifa *
sctp_add_addr_to_vrf(uint32_t vrfid,
@@ -448,8 +449,9 @@ struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
-int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct thread *);
-
+int
+sctp_inpcb_bind(struct socket *, struct sockaddr *, struct sctp_ifa *,
+ struct thread *);
struct sctp_tcb *
sctp_findassociation_addr(struct mbuf *, int, int,
diff --git a/sys/netinet/sctp_peeloff.c b/sys/netinet/sctp_peeloff.c
index f35c7e6..479a8ac 100644
--- a/sys/netinet/sctp_peeloff.c
+++ b/sys/netinet/sctp_peeloff.c
@@ -35,14 +35,16 @@
__FBSDID("$FreeBSD$");
#include <netinet/sctp_os.h>
#include <netinet/sctp_pcb.h>
+#include <netinet/sctputil.h>
+#include <netinet/sctp_var.h>
+#include <netinet/sctp_var.h>
+#include <netinet/sctp_sysctl.h>
#include <netinet/sctp.h>
#include <netinet/sctp_uio.h>
-#include <netinet/sctp_var.h>
#include <netinet/sctp_peeloff.h>
#include <netinet/sctputil.h>
#include <netinet/sctp_auth.h>
-
#ifdef SCTP_DEBUG
extern uint32_t sctp_debug_on;
@@ -174,7 +176,9 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
/* We remove it right away */
#ifdef SCTP_LOCK_LOGGING
- sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
+ if (sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) {
+ sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
+ }
#endif
TAILQ_REMOVE(&head->so_comp, newso, so_list);
head->so_qlen--;
diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c
index 04bb078..321a0bb 100644
--- a/sys/netinet/sctp_sysctl.c
+++ b/sys/netinet/sctp_sysctl.c
@@ -63,6 +63,8 @@ uint32_t sctp_max_burst_default = SCTP_DEF_MAX_BURST;
uint32_t sctp_use_cwnd_based_maxburst = 1;
uint32_t sctp_do_drain = 1;
uint32_t sctp_hb_maxburst = SCTP_DEF_MAX_BURST;
+uint32_t sctp_logging_level = SCTPCTL_LOGGING_LEVEL_DEFAULT;
+
uint32_t sctp_max_chunks_on_queue = SCTP_ASOC_MAX_CHUNKS_ON_QUEUE;
uint32_t sctp_delayed_sack_time_default = SCTP_RECV_MSEC;
@@ -683,6 +685,11 @@ SYSCTL_INT(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLFLAG_RW,
&sctp_max_retran_chunk, 0,
SCTPCTL_MAX_RETRAN_CHUNK_DESC);
+SYSCTL_INT(_net_inet_sctp, OID_AUTO, sctp_logging, CTLFLAG_RW,
+ &sctp_logging_level, 0,
+ SCTPCTL_LOGGING_LEVEL_DESC);
+
+
#ifdef SCTP_DEBUG
SYSCTL_INT(_net_inet_sctp, OID_AUTO, debug, CTLFLAG_RW,
&sctp_debug_on, 0, "Configure debug output");
diff --git a/sys/netinet/sctp_sysctl.h b/sys/netinet/sctp_sysctl.h
index e54bb6a..c0a394e 100644
--- a/sys/netinet/sctp_sysctl.h
+++ b/sys/netinet/sctp_sysctl.h
@@ -392,19 +392,25 @@ __FBSDID("$FreeBSD$");
#define SCTPCTL_MAX_RETRAN_CHUNK_MAX 65535
#define SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT 30
+/* sctp_logging: This gives us logging when the options are enabled */
+#define SCTPCTL_LOGGING_LEVEL 51
+#define SCTPCTL_LOGGING_LEVEL_DESC "Ltrace/KTR trace logging level"
+#define SCTPCTL_LOGGING_LEVEL_MIN 0
+#define SCTPCTL_LOGGING_LEVEL_MAX 0x007fffff
+#define SCTPCTL_LOGGING_LEVEL_DEFAULT 0
#ifdef SCTP_DEBUG
/* debug: Configure debug output */
-#define SCTPCTL_DEBUG 51
+#define SCTPCTL_DEBUG 52
#define SCTPCTL_DEBUG_DESC "Configure debug output"
#define SCTPCTL_DEBUG_MIN 0
#define SCTPCTL_DEBUG_MAX 0xFFFFFFFF
#define SCTPCTL_DEBUG_DEFAULT 0
-#define SCTPCTL_MAXID 51
+#define SCTPCTL_MAXID 52
#else
-#define SCTPCTL_MAXID 50
+#define SCTPCTL_MAXID 51
#endif
/*
@@ -464,6 +470,7 @@ __FBSDID("$FreeBSD$");
{ "asoc_resource", CTLTYPE_INT }, \
{ "min_residual", CTLTYPE_INT }, \
{ "max_retran_chunk", CTLTYPE_INT }, \
+ { "sctp_logging", CTLTYPE_INT }, \
{ "debug", CTLTYPE_INT }, \
}
#else
@@ -519,6 +526,7 @@ __FBSDID("$FreeBSD$");
{ "asoc_resource", CTLTYPE_INT }, \
{ "min_residual", CTLTYPE_INT }, \
{ "max_retran_chunk", CTLTYPE_INT }, \
+ { "sctp_logging", CTLTYPE_INT }, \
}
#endif
@@ -579,6 +587,7 @@ extern uint32_t sctp_abort_if_one_2_one_hits_limit;
extern uint32_t sctp_strict_data_order;
extern uint32_t sctp_min_residual;
extern uint32_t sctp_max_retran_chunk;
+extern uint32_t sctp_logging_level;
#if defined(SCTP_DEBUG)
extern uint32_t sctp_debug_on;
diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c
index b66ca43..9e17dd0 100644
--- a/sys/netinet/sctp_timer.c
+++ b/sys/netinet/sctp_timer.c
@@ -120,10 +120,10 @@ sctp_early_fr_timer(struct sctp_inpcb *inp,
continue;
}
}
-#ifdef SCTP_EARLYFR_LOGGING
- sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
- 4, SCTP_FR_MARKED_EARLY);
-#endif
+ if (sctp_logging_level & SCTP_EARLYFR_LOGGING_ENABLE) {
+ sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
+ 4, SCTP_FR_MARKED_EARLY);
+ }
SCTP_STAT_INCR(sctps_earlyfrmrkretrans);
chk->sent = SCTP_DATAGRAM_RESEND;
sctp_ucount_incr(stcb->asoc.sent_queue_retran_cnt);
@@ -137,11 +137,9 @@ sctp_early_fr_timer(struct sctp_inpcb *inp,
}
}
if (cnt) {
-#ifdef SCTP_CWND_MONITOR
int old_cwnd;
old_cwnd = net->cwnd;
-#endif
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_EARLY_FR_TMR);
/*
* make a small adjustment to cwnd and force to CA.
@@ -153,9 +151,9 @@ sctp_early_fr_timer(struct sctp_inpcb *inp,
if (net->cwnd < net->ssthresh)
/* still in SS move to CA */
net->ssthresh = net->cwnd - 1;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, (old_cwnd - net->cwnd), SCTP_CWND_LOG_FROM_FR);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, (old_cwnd - net->cwnd), SCTP_CWND_LOG_FROM_FR);
+ }
} else if (cnt_resend) {
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_EARLY_FR_TMR);
}
@@ -399,10 +397,8 @@ sctp_backoff_on_timeout(struct sctp_tcb *stcb,
}
if ((win_probe == 0) && num_marked) {
/* We don't apply penalty to window probe scenarios */
-#ifdef SCTP_CWND_MONITOR
int old_cwnd = net->cwnd;
-#endif
net->ssthresh = net->cwnd >> 1;
if (net->ssthresh < (net->mtu << 1)) {
net->ssthresh = (net->mtu << 1);
@@ -411,10 +407,9 @@ sctp_backoff_on_timeout(struct sctp_tcb *stcb,
/* floor of 1 mtu */
if (net->cwnd < net->mtu)
net->cwnd = net->mtu;
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
-#endif
-
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->cwnd - old_cwnd, SCTP_CWND_LOG_FROM_RTX);
+ }
net->partial_bytes_acked = 0;
}
}
@@ -469,17 +464,17 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
/* get cur rto in micro-seconds */
cur_rtt = (((net->lastsa >> 2) + net->lastsv) >> 1);
cur_rtt *= 1000;
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(cur_rtt,
- stcb->asoc.peers_rwnd,
- window_probe,
- SCTP_FR_T3_MARK_TIME);
- sctp_log_fr(net->flight_size,
- SCTP_OS_TIMER_PENDING(&net->fr_timer.timer),
- SCTP_OS_TIMER_ACTIVE(&net->fr_timer.timer),
- SCTP_FR_CWND_REPORT);
- sctp_log_fr(net->flight_size, net->cwnd, stcb->asoc.total_flight, SCTP_FR_CWND_REPORT);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(cur_rtt,
+ stcb->asoc.peers_rwnd,
+ window_probe,
+ SCTP_FR_T3_MARK_TIME);
+ sctp_log_fr(net->flight_size,
+ SCTP_OS_TIMER_PENDING(&net->fr_timer.timer),
+ SCTP_OS_TIMER_ACTIVE(&net->fr_timer.timer),
+ SCTP_FR_CWND_REPORT);
+ sctp_log_fr(net->flight_size, net->cwnd, stcb->asoc.total_flight, SCTP_FR_CWND_REPORT);
+ }
tv.tv_sec = cur_rtt / 1000000;
tv.tv_usec = cur_rtt % 1000000;
min_wait = now;
@@ -493,10 +488,10 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
*/
min_wait.tv_sec = min_wait.tv_usec = 0;
}
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(cur_rtt, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME);
- sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(cur_rtt, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME);
+ sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME);
+ }
/*
* Our rwnd will be incorrect here since we are not adding back the
* cnt * mbuf but we will fix that down below.
@@ -529,24 +524,24 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
*/
/* validate its been outstanding long enough */
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(chk->rec.data.TSN_seq,
- chk->sent_rcv_time.tv_sec,
- chk->sent_rcv_time.tv_usec,
- SCTP_FR_T3_MARK_TIME);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(chk->rec.data.TSN_seq,
+ chk->sent_rcv_time.tv_sec,
+ chk->sent_rcv_time.tv_usec,
+ SCTP_FR_T3_MARK_TIME);
+ }
if ((chk->sent_rcv_time.tv_sec > min_wait.tv_sec) && (window_probe == 0)) {
/*
* we have reached a chunk that was sent
* some seconds past our min.. forget it we
* will find no more to send.
*/
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(0,
- chk->sent_rcv_time.tv_sec,
- chk->sent_rcv_time.tv_usec,
- SCTP_FR_T3_STOPPED);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(0,
+ chk->sent_rcv_time.tv_sec,
+ chk->sent_rcv_time.tv_usec,
+ SCTP_FR_T3_STOPPED);
+ }
continue;
} else if ((chk->sent_rcv_time.tv_sec == min_wait.tv_sec) &&
(window_probe == 0)) {
@@ -559,12 +554,12 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
* ok it was sent after our boundary
* time.
*/
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(0,
- chk->sent_rcv_time.tv_sec,
- chk->sent_rcv_time.tv_usec,
- SCTP_FR_T3_STOPPED);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(0,
+ chk->sent_rcv_time.tv_sec,
+ chk->sent_rcv_time.tv_usec,
+ SCTP_FR_T3_STOPPED);
+ }
continue;
}
}
@@ -603,11 +598,10 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
tsnfirst = chk->rec.data.TSN_seq;
}
tsnlast = chk->rec.data.TSN_seq;
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
- 0, SCTP_FR_T3_MARKED);
-
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(chk->rec.data.TSN_seq, chk->snd_count,
+ 0, SCTP_FR_T3_MARKED);
+ }
if (chk->rec.data.chunk_was_revoked) {
/* deflate the cwnd */
chk->whoTo->cwnd -= chk->book_size;
@@ -615,13 +609,13 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
}
net->marked_retrans++;
stcb->asoc.marked_retrans++;
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND_TO,
- chk->whoTo->flight_size,
- chk->book_size,
- (uintptr_t) chk->whoTo,
- chk->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_RSND_TO,
+ chk->whoTo->flight_size,
+ chk->book_size,
+ (uintptr_t) chk->whoTo,
+ chk->rec.data.TSN_seq);
+ }
sctp_flight_size_decrease(chk);
sctp_total_flight_decrease(stcb, chk);
stcb->asoc.peers_rwnd += chk->send_size;
@@ -665,9 +659,9 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
/* we did not subtract the same things? */
audit_tf = 1;
}
-#if defined(SCTP_FR_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
- sctp_log_fr(tsnfirst, tsnlast, num_mk, SCTP_FR_T3_TIMEOUT);
-#endif
+ if (sctp_logging_level & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) {
+ sctp_log_fr(tsnfirst, tsnlast, num_mk, SCTP_FR_T3_TIMEOUT);
+ }
#ifdef SCTP_DEBUG
if (num_mk) {
SCTPDBG(SCTP_DEBUG_TIMER1, "LAST TSN marked was %x\n",
@@ -725,14 +719,13 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb,
}
TAILQ_FOREACH(chk, &stcb->asoc.sent_queue, sctp_next) {
if (chk->sent < SCTP_DATAGRAM_RESEND) {
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
- chk->whoTo->flight_size,
- chk->book_size,
- (uintptr_t) chk->whoTo,
- chk->rec.data.TSN_seq);
-#endif
-
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_UP,
+ chk->whoTo->flight_size,
+ chk->book_size,
+ (uintptr_t) chk->whoTo,
+ chk->rec.data.TSN_seq);
+ }
sctp_flight_size_increase(chk);
sctp_total_flight_increase(stcb, chk);
}
@@ -804,10 +797,10 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
struct sctp_nets *alt;
int win_probe, num_mk;
-#ifdef SCTP_FR_LOGGING
- sctp_log_fr(0, 0, 0, SCTP_FR_T3_TIMEOUT);
-#ifdef SCTP_CWND_LOGGING
- {
+ if (sctp_logging_level & SCTP_FR_LOGGING_ENABLE) {
+ sctp_log_fr(0, 0, 0, SCTP_FR_T3_TIMEOUT);
+ }
+ if (sctp_logging_level & SCTP_CWND_LOGGING_ENABLE) {
struct sctp_nets *lnet;
TAILQ_FOREACH(lnet, &stcb->asoc.nets, sctp_next) {
@@ -818,8 +811,6 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
}
}
}
-#endif
-#endif
/* Find an alternate and mark those for retransmission */
if ((stcb->asoc.peers_rwnd == 0) &&
(stcb->asoc.total_flight < net->mtu)) {
@@ -972,9 +963,9 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
}
}
}
-#ifdef SCTP_CWND_MONITOR
- sctp_log_cwnd(stcb, net, net->cwnd, SCTP_CWND_LOG_FROM_RTX);
-#endif
+ if (sctp_logging_level & SCTP_CWND_MONITOR_ENABLE) {
+ sctp_log_cwnd(stcb, net, net->cwnd, SCTP_CWND_LOG_FROM_RTX);
+ }
return (0);
}
diff --git a/sys/netinet/sctp_uio.h b/sys/netinet/sctp_uio.h
index 1510f9c..97bfc80 100644
--- a/sys/netinet/sctp_uio.h
+++ b/sys/netinet/sctp_uio.h
@@ -697,7 +697,7 @@ struct sctp_mbuf_log {
};
struct sctp_cwnd_log {
- uint32_t time_event;
+ uint64_t time_event;
uint8_t from;
uint8_t event_type;
uint8_t resv[2];
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index bd26286..8dab63e 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -133,13 +133,13 @@ sctp_pathmtu_adjustment(struct sctp_inpcb *inp,
}
chk->sent = SCTP_DATAGRAM_RESEND;
chk->rec.data.doing_fast_retransmit = 0;
-#ifdef SCTP_FLIGHT_LOGGING
- sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU,
- chk->whoTo->flight_size,
- chk->book_size,
- (uintptr_t) chk->whoTo,
- chk->rec.data.TSN_seq);
-#endif
+ if (sctp_logging_level & SCTP_FLIGHT_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_FLIGHT_LOG_DOWN_PMTU,
+ chk->whoTo->flight_size,
+ chk->book_size,
+ (uintptr_t) chk->whoTo,
+ chk->rec.data.TSN_seq);
+ }
/* Clear any time so NO RTT is being done */
chk->do_rtt = 0;
sctp_flight_size_decrease(chk);
@@ -289,7 +289,9 @@ sctp_notify(struct sctp_inpcb *inp,
}
if (inp->sctp_socket) {
#ifdef SCTP_LOCK_LOGGING
- sctp_log_lock(inp, stcb, SCTP_LOG_LOCK_SOCK);
+ if (sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) {
+ sctp_log_lock(inp, stcb, SCTP_LOG_LOCK_SOCK);
+ }
#endif
SOCK_LOCK(inp->sctp_socket);
inp->sctp_socket->so_error = error;
@@ -550,7 +552,7 @@ sctp_bind(struct socket *so, struct sockaddr *addr, struct thread *p)
if (inp == 0)
return EINVAL;
- error = sctp_inpcb_bind(so, addr, p);
+ error = sctp_inpcb_bind(so, addr, NULL, p);
return error;
}
@@ -1321,7 +1323,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) ==
SCTP_PCB_FLAGS_UNBOUND) {
/* Bind a ephemeral port */
- error = sctp_inpcb_bind(so, NULL, p);
+ error = sctp_inpcb_bind(so, NULL, NULL, p);
if (error) {
goto out_now;
}
@@ -1732,11 +1734,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
}
break;
case SCTP_GET_STAT_LOG:
-#ifdef SCTP_STAT_LOGGING
error = sctp_fill_stat_log(optval, optsize);
-#else
- error = EOPNOTSUPP;
-#endif
break;
case SCTP_EVENTS:
{
@@ -2515,11 +2513,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
break;
case SCTP_CLR_STAT_LOG:
-#ifdef SCTP_STAT_LOGGING
- sctp_clr_stat_log();
-#else
error = EOPNOTSUPP;
-#endif
break;
case SCTP_CONTEXT:
{
@@ -3622,7 +3616,7 @@ sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)
if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) ==
SCTP_PCB_FLAGS_UNBOUND) {
/* Bind a ephemeral port */
- error = sctp_inpcb_bind(so, NULL, p);
+ error = sctp_inpcb_bind(so, NULL, NULL, p);
if (error) {
goto out_now;
}
@@ -3711,7 +3705,9 @@ sctp_listen(struct socket *so, int backlog, struct thread *p)
}
SCTP_INP_RLOCK(inp);
#ifdef SCTP_LOCK_LOGGING
- sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
+ if (sctp_logging_level & SCTP_LOCK_LOGGING_ENABLE) {
+ sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
+ }
#endif
SOCK_LOCK(so);
error = solisten_proto_check(so);
@@ -3731,7 +3727,7 @@ sctp_listen(struct socket *so, int backlog, struct thread *p)
/* We must do a bind. */
SOCK_UNLOCK(so);
SCTP_INP_RUNLOCK(inp);
- if ((error = sctp_inpcb_bind(so, NULL, p))) {
+ if ((error = sctp_inpcb_bind(so, NULL, NULL, p))) {
/* bind error, probably perm */
return (error);
}
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index b777333..2a35cf9 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -53,187 +53,194 @@ __FBSDID("$FreeBSD$");
#define NUMBER_OF_MTU_SIZES 18
-#ifdef SCTP_STAT_LOGGING
-int global_sctp_cwnd_log_at = 0;
-int global_sctp_cwnd_log_rolled = 0;
-struct sctp_cwnd_log sctp_clog[SCTP_STAT_LOG_SIZE];
-
-static uint32_t
-sctp_get_time_of_event(void)
-{
- struct timeval now;
- uint32_t timeval;
-
- SCTP_GETPTIME_TIMEVAL(&now);
- timeval = (now.tv_sec % 0x00000fff);
- timeval <<= 20;
- timeval |= now.tv_usec & 0xfffff;
- return (timeval);
-}
-
-
-void
-sctp_clr_stat_log(void)
-{
- global_sctp_cwnd_log_at = 0;
- global_sctp_cwnd_log_rolled = 0;
-}
-
+#ifndef SCTP_SUBSYS_KTR
+#define SCTP_SUBSYS_KTR KTR_GEN
+#endif
void
sctp_sblog(struct sockbuf *sb,
struct sctp_tcb *stcb, int from, int incr)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_SB;
- sctp_clog[sctp_cwnd_log_at].x.sb.stcb = stcb;
- sctp_clog[sctp_cwnd_log_at].x.sb.so_sbcc = sb->sb_cc;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.sb.stcb = stcb;
+ sctp_clog.x.sb.so_sbcc = sb->sb_cc;
if (stcb)
- sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = stcb->asoc.sb_cc;
+ sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_cc;
else
- sctp_clog[sctp_cwnd_log_at].x.sb.stcb_sbcc = 0;
- sctp_clog[sctp_cwnd_log_at].x.sb.incr = incr;
+ sctp_clog.x.sb.stcb_sbcc = 0;
+ sctp_clog.x.sb.incr = incr;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_SB,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = 0;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_CLOSE;
- sctp_clog[sctp_cwnd_log_at].x.close.inp = (void *)inp;
- sctp_clog[sctp_cwnd_log_at].x.close.sctp_flags = inp->sctp_flags;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.close.inp = (void *)inp;
+ sctp_clog.x.close.sctp_flags = inp->sctp_flags;
if (stcb) {
- sctp_clog[sctp_cwnd_log_at].x.close.stcb = (void *)stcb;
- sctp_clog[sctp_cwnd_log_at].x.close.state = (uint16_t) stcb->asoc.state;
+ sctp_clog.x.close.stcb = (void *)stcb;
+ sctp_clog.x.close.state = (uint16_t) stcb->asoc.state;
} else {
- sctp_clog[sctp_cwnd_log_at].x.close.stcb = 0;
- sctp_clog[sctp_cwnd_log_at].x.close.state = 0;
+ sctp_clog.x.close.stcb = 0;
+ sctp_clog.x.close.state = 0;
}
- sctp_clog[sctp_cwnd_log_at].x.close.loc = loc;
+ sctp_clog.x.close.loc = loc;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_CLOSE,
+ 0,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
rto_logging(struct sctp_nets *net, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RTT;
- sctp_clog[sctp_cwnd_log_at].x.rto.net = (void *)net;
- sctp_clog[sctp_cwnd_log_at].x.rto.rtt = net->prev_rtt;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.rto.net = (void *)net;
+ sctp_clog.x.rto.rtt = net->prev_rtt;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_RTT,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t tsn, uint16_t sseq, uint16_t stream, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_STRM;
- sctp_clog[sctp_cwnd_log_at].x.strlog.stcb = stcb;
- sctp_clog[sctp_cwnd_log_at].x.strlog.n_tsn = tsn;
- sctp_clog[sctp_cwnd_log_at].x.strlog.n_sseq = sseq;
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_tsn = 0;
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_sseq = 0;
- sctp_clog[sctp_cwnd_log_at].x.strlog.strm = stream;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.strlog.stcb = stcb;
+ sctp_clog.x.strlog.n_tsn = tsn;
+ sctp_clog.x.strlog.n_sseq = sseq;
+ sctp_clog.x.strlog.e_tsn = 0;
+ sctp_clog.x.strlog.e_sseq = 0;
+ sctp_clog.x.strlog.strm = stream;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_STRM,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_nagle_event(struct sctp_tcb *stcb, int action)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) action;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_NAGLE;
- sctp_clog[sctp_cwnd_log_at].x.nagle.stcb = (void *)stcb;
- sctp_clog[sctp_cwnd_log_at].x.nagle.total_flight = stcb->asoc.total_flight;
- sctp_clog[sctp_cwnd_log_at].x.nagle.total_in_queue = stcb->asoc.total_output_queue_size;
- sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue;
- sctp_clog[sctp_cwnd_log_at].x.nagle.count_in_flight = stcb->asoc.total_flight_count;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.nagle.stcb = (void *)stcb;
+ sctp_clog.x.nagle.total_flight = stcb->asoc.total_flight;
+ sctp_clog.x.nagle.total_in_queue = stcb->asoc.total_output_queue_size;
+ sctp_clog.x.nagle.count_in_queue = stcb->asoc.chunks_on_out_queue;
+ sctp_clog.x.nagle.count_in_flight = stcb->asoc.total_flight_count;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_NAGLE,
+ action,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_sack(uint32_t old_cumack, uint32_t cumack, uint32_t tsn, uint16_t gaps, uint16_t dups, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_SACK;
- sctp_clog[sctp_cwnd_log_at].x.sack.cumack = cumack;
- sctp_clog[sctp_cwnd_log_at].x.sack.oldcumack = old_cumack;
- sctp_clog[sctp_cwnd_log_at].x.sack.tsn = tsn;
- sctp_clog[sctp_cwnd_log_at].x.sack.numGaps = gaps;
- sctp_clog[sctp_cwnd_log_at].x.sack.numDups = dups;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.sack.cumack = cumack;
+ sctp_clog.x.sack.oldcumack = old_cumack;
+ sctp_clog.x.sack.tsn = tsn;
+ sctp_clog.x.sack.numGaps = gaps;
+ sctp_clog.x.sack.numDups = dups;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_SACK,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_map(uint32_t map, uint32_t cum, uint32_t high, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_MAP;
- sctp_clog[sctp_cwnd_log_at].x.map.base = map;
- sctp_clog[sctp_cwnd_log_at].x.map.cum = cum;
- sctp_clog[sctp_cwnd_log_at].x.map.high = high;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.map.base = map;
+ sctp_clog.x.map.cum = cum;
+ sctp_clog.x.map.high = high;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_MAP,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn,
int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_FR;
- sctp_clog[sctp_cwnd_log_at].x.fr.largest_tsn = biggest_tsn;
- sctp_clog[sctp_cwnd_log_at].x.fr.largest_new_tsn = biggest_new_tsn;
- sctp_clog[sctp_cwnd_log_at].x.fr.tsn = tsn;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.fr.largest_tsn = biggest_tsn;
+ sctp_clog.x.fr.largest_new_tsn = biggest_new_tsn;
+ sctp_clog.x.fr.tsn = tsn;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_FR,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_mb(struct mbuf *m, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_MBUF;
- sctp_clog[sctp_cwnd_log_at].x.mb.mp = m;
- sctp_clog[sctp_cwnd_log_at].x.mb.mbuf_flags = (uint8_t) (SCTP_BUF_GET_FLAGS(m));
- sctp_clog[sctp_cwnd_log_at].x.mb.size = (uint16_t) (SCTP_BUF_LEN(m));
- sctp_clog[sctp_cwnd_log_at].x.mb.data = SCTP_BUF_AT(m, 0);
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.mb.mp = m;
+ sctp_clog.x.mb.mbuf_flags = (uint8_t) (SCTP_BUF_GET_FLAGS(m));
+ sctp_clog.x.mb.size = (uint16_t) (SCTP_BUF_LEN(m));
+ sctp_clog.x.mb.data = SCTP_BUF_AT(m, 0);
if (SCTP_BUF_IS_EXTENDED(m)) {
- sctp_clog[sctp_cwnd_log_at].x.mb.ext = SCTP_BUF_EXTEND_BASE(m);
- sctp_clog[sctp_cwnd_log_at].x.mb.refcnt = (uint8_t) (SCTP_BUF_EXTEND_REFCNT(m));
+ sctp_clog.x.mb.ext = SCTP_BUF_EXTEND_BASE(m);
+ sctp_clog.x.mb.refcnt = (uint8_t) (SCTP_BUF_EXTEND_REFCNT(m));
} else {
- sctp_clog[sctp_cwnd_log_at].x.mb.ext = 0;
- sctp_clog[sctp_cwnd_log_at].x.mb.refcnt = 0;
- }
+ sctp_clog.x.mb.ext = 0;
+ sctp_clog.x.mb.refcnt = 0;
+ }
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_MBUF,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
@@ -241,332 +248,280 @@ void
sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_read *poschk,
int from)
{
- int sctp_cwnd_log_at;
+ struct sctp_cwnd_log sctp_clog;
if (control == NULL) {
SCTP_PRINTF("Gak log of NULL?\n");
return;
}
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_STRM;
- sctp_clog[sctp_cwnd_log_at].x.strlog.stcb = control->stcb;
- sctp_clog[sctp_cwnd_log_at].x.strlog.n_tsn = control->sinfo_tsn;
- sctp_clog[sctp_cwnd_log_at].x.strlog.n_sseq = control->sinfo_ssn;
- sctp_clog[sctp_cwnd_log_at].x.strlog.strm = control->sinfo_stream;
+ sctp_clog.x.strlog.stcb = control->stcb;
+ sctp_clog.x.strlog.n_tsn = control->sinfo_tsn;
+ sctp_clog.x.strlog.n_sseq = control->sinfo_ssn;
+ sctp_clog.x.strlog.strm = control->sinfo_stream;
if (poschk != NULL) {
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_tsn = poschk->sinfo_tsn;
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_sseq = poschk->sinfo_ssn;
+ sctp_clog.x.strlog.e_tsn = poschk->sinfo_tsn;
+ sctp_clog.x.strlog.e_sseq = poschk->sinfo_ssn;
} else {
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_tsn = 0;
- sctp_clog[sctp_cwnd_log_at].x.strlog.e_sseq = 0;
+ sctp_clog.x.strlog.e_tsn = 0;
+ sctp_clog.x.strlog.e_sseq = 0;
}
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_STRM,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net, int augment, uint8_t from)
{
- int sctp_cwnd_log_at;
+ struct sctp_cwnd_log sctp_clog;
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_CWND;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.net = net;
+ sctp_clog.x.cwnd.net = net;
if (stcb->asoc.send_queue_cnt > 255)
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_send = 255;
+ sctp_clog.x.cwnd.cnt_in_send = 255;
else
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
+ sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
if (stcb->asoc.stream_queue_cnt > 255)
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_str = 255;
+ sctp_clog.x.cwnd.cnt_in_str = 255;
else
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
+ sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
if (net) {
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cwnd_new_value = net->cwnd;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.inflight = net->flight_size;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.pseudo_cumack = net->pseudo_cumack;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.meets_pseudo_cumack = net->new_pseudo_cumack;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.need_new_pseudo_cumack = net->find_pseudo_cumack;
+ sctp_clog.x.cwnd.cwnd_new_value = net->cwnd;
+ sctp_clog.x.cwnd.inflight = net->flight_size;
+ sctp_clog.x.cwnd.pseudo_cumack = net->pseudo_cumack;
+ sctp_clog.x.cwnd.meets_pseudo_cumack = net->new_pseudo_cumack;
+ sctp_clog.x.cwnd.need_new_pseudo_cumack = net->find_pseudo_cumack;
}
if (SCTP_CWNDLOG_PRESEND == from) {
- sctp_clog[sctp_cwnd_log_at].x.cwnd.meets_pseudo_cumack = stcb->asoc.peers_rwnd;
+ sctp_clog.x.cwnd.meets_pseudo_cumack = stcb->asoc.peers_rwnd;
}
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cwnd_augment = augment;
+ sctp_clog.x.cwnd.cwnd_augment = augment;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_CWND,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from)
{
- int sctp_cwnd_log_at;
+ struct sctp_cwnd_log sctp_clog;
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_LOCK_EVENT;
if (inp) {
- sctp_clog[sctp_cwnd_log_at].x.lock.sock = (void *)inp->sctp_socket;
+ sctp_clog.x.lock.sock = (void *)inp->sctp_socket;
} else {
- sctp_clog[sctp_cwnd_log_at].x.lock.sock = (void *)NULL;
+ sctp_clog.x.lock.sock = (void *)NULL;
}
- sctp_clog[sctp_cwnd_log_at].x.lock.inp = (void *)inp;
+ sctp_clog.x.lock.inp = (void *)inp;
if (stcb) {
- sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx);
+ sctp_clog.x.lock.tcb_lock = mtx_owned(&stcb->tcb_mtx);
} else {
- sctp_clog[sctp_cwnd_log_at].x.lock.tcb_lock = SCTP_LOCK_UNKNOWN;
+ sctp_clog.x.lock.tcb_lock = SCTP_LOCK_UNKNOWN;
}
if (inp) {
- sctp_clog[sctp_cwnd_log_at].x.lock.inp_lock = mtx_owned(&inp->inp_mtx);
- sctp_clog[sctp_cwnd_log_at].x.lock.create_lock = mtx_owned(&inp->inp_create_mtx);
+ sctp_clog.x.lock.inp_lock = mtx_owned(&inp->inp_mtx);
+ sctp_clog.x.lock.create_lock = mtx_owned(&inp->inp_create_mtx);
} else {
- sctp_clog[sctp_cwnd_log_at].x.lock.inp_lock = SCTP_LOCK_UNKNOWN;
- sctp_clog[sctp_cwnd_log_at].x.lock.create_lock = SCTP_LOCK_UNKNOWN;
+ sctp_clog.x.lock.inp_lock = SCTP_LOCK_UNKNOWN;
+ sctp_clog.x.lock.create_lock = SCTP_LOCK_UNKNOWN;
}
- sctp_clog[sctp_cwnd_log_at].x.lock.info_lock = mtx_owned(&sctppcbinfo.ipi_ep_mtx);
+ sctp_clog.x.lock.info_lock = mtx_owned(&sctppcbinfo.ipi_ep_mtx);
if (inp->sctp_socket) {
- sctp_clog[sctp_cwnd_log_at].x.lock.sock_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
- sctp_clog[sctp_cwnd_log_at].x.lock.sockrcvbuf_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
- sctp_clog[sctp_cwnd_log_at].x.lock.socksndbuf_lock = mtx_owned(&(inp->sctp_socket->so_snd.sb_mtx));
+ sctp_clog.x.lock.sock_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
+ sctp_clog.x.lock.sockrcvbuf_lock = mtx_owned(&(inp->sctp_socket->so_rcv.sb_mtx));
+ sctp_clog.x.lock.socksndbuf_lock = mtx_owned(&(inp->sctp_socket->so_snd.sb_mtx));
} else {
- sctp_clog[sctp_cwnd_log_at].x.lock.sock_lock = SCTP_LOCK_UNKNOWN;
- sctp_clog[sctp_cwnd_log_at].x.lock.sockrcvbuf_lock = SCTP_LOCK_UNKNOWN;
- sctp_clog[sctp_cwnd_log_at].x.lock.socksndbuf_lock = SCTP_LOCK_UNKNOWN;
- }
+ sctp_clog.x.lock.sock_lock = SCTP_LOCK_UNKNOWN;
+ sctp_clog.x.lock.sockrcvbuf_lock = SCTP_LOCK_UNKNOWN;
+ sctp_clog.x.lock.socksndbuf_lock = SCTP_LOCK_UNKNOWN;
+ }
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_LOCK_EVENT,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *net, int error, int burst, uint8_t from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_MAXBURST;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.net = net;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cwnd_new_value = error;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.inflight = net->flight_size;
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cwnd_augment = burst;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.cwnd.net = net;
+ sctp_clog.x.cwnd.cwnd_new_value = error;
+ sctp_clog.x.cwnd.inflight = net->flight_size;
+ sctp_clog.x.cwnd.cwnd_augment = burst;
if (stcb->asoc.send_queue_cnt > 255)
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_send = 255;
+ sctp_clog.x.cwnd.cnt_in_send = 255;
else
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
+ sctp_clog.x.cwnd.cnt_in_send = stcb->asoc.send_queue_cnt;
if (stcb->asoc.stream_queue_cnt > 255)
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_str = 255;
+ sctp_clog.x.cwnd.cnt_in_str = 255;
else
- sctp_clog[sctp_cwnd_log_at].x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
+ sctp_clog.x.cwnd.cnt_in_str = stcb->asoc.stream_queue_cnt;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_MAXBURST,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_rwnd(uint8_t from, uint32_t peers_rwnd, uint32_t snd_size, uint32_t overhead)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RWND;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.rwnd = peers_rwnd;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.send_size = snd_size;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.overhead = overhead;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.new_rwnd = 0;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.rwnd.rwnd = peers_rwnd;
+ sctp_clog.x.rwnd.send_size = snd_size;
+ sctp_clog.x.rwnd.overhead = overhead;
+ sctp_clog.x.rwnd.new_rwnd = 0;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_RWND,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_rwnd_set(uint8_t from, uint32_t peers_rwnd, uint32_t flight_size, uint32_t overhead, uint32_t a_rwndval)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_RWND;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.rwnd = peers_rwnd;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.send_size = flight_size;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.overhead = overhead;
- sctp_clog[sctp_cwnd_log_at].x.rwnd.new_rwnd = a_rwndval;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.rwnd.rwnd = peers_rwnd;
+ sctp_clog.x.rwnd.send_size = flight_size;
+ sctp_clog.x.rwnd.overhead = overhead;
+ sctp_clog.x.rwnd.new_rwnd = a_rwndval;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_RWND,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
}
void
sctp_log_mbcnt(uint8_t from, uint32_t total_oq, uint32_t book, uint32_t total_mbcnt_q, uint32_t mbcnt)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_MBCNT;
- sctp_clog[sctp_cwnd_log_at].x.mbcnt.total_queue_size = total_oq;
- sctp_clog[sctp_cwnd_log_at].x.mbcnt.size_change = book;
- sctp_clog[sctp_cwnd_log_at].x.mbcnt.total_queue_mb_size = total_mbcnt_q;
- sctp_clog[sctp_cwnd_log_at].x.mbcnt.mbcnt_change = mbcnt;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.mbcnt.total_queue_size = total_oq;
+ sctp_clog.x.mbcnt.size_change = book;
+ sctp_clog.x.mbcnt.total_queue_mb_size = total_mbcnt_q;
+ sctp_clog.x.mbcnt.mbcnt_change = mbcnt;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_MBCNT,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_misc_ints(uint8_t from, uint32_t a, uint32_t b, uint32_t c, uint32_t d)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_MISC_EVENT;
- sctp_clog[sctp_cwnd_log_at].x.misc.log1 = a;
- sctp_clog[sctp_cwnd_log_at].x.misc.log2 = b;
- sctp_clog[sctp_cwnd_log_at].x.misc.log3 = c;
- sctp_clog[sctp_cwnd_log_at].x.misc.log4 = d;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_MISC_EVENT,
+ from,
+ a, b, c, d);
}
void
sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t cumtsn, uint32_t wake_cnt, int from)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_WAKE;
- sctp_clog[sctp_cwnd_log_at].x.wake.stcb = (void *)stcb;
- sctp_clog[sctp_cwnd_log_at].x.wake.wake_cnt = wake_cnt;
- sctp_clog[sctp_cwnd_log_at].x.wake.flight = stcb->asoc.total_flight_count;
- sctp_clog[sctp_cwnd_log_at].x.wake.send_q = stcb->asoc.send_queue_cnt;
- sctp_clog[sctp_cwnd_log_at].x.wake.sent_q = stcb->asoc.sent_queue_cnt;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.wake.stcb = (void *)stcb;
+ sctp_clog.x.wake.wake_cnt = wake_cnt;
+ sctp_clog.x.wake.flight = stcb->asoc.total_flight_count;
+ sctp_clog.x.wake.send_q = stcb->asoc.send_queue_cnt;
+ sctp_clog.x.wake.sent_q = stcb->asoc.sent_queue_cnt;
if (stcb->asoc.stream_queue_cnt < 0xff)
- sctp_clog[sctp_cwnd_log_at].x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt;
+ sctp_clog.x.wake.stream_qcnt = (uint8_t) stcb->asoc.stream_queue_cnt;
else
- sctp_clog[sctp_cwnd_log_at].x.wake.stream_qcnt = 0xff;
+ sctp_clog.x.wake.stream_qcnt = 0xff;
if (stcb->asoc.chunks_on_out_queue < 0xff)
- sctp_clog[sctp_cwnd_log_at].x.wake.chunks_on_oque = (uint8_t) stcb->asoc.chunks_on_out_queue;
+ sctp_clog.x.wake.chunks_on_oque = (uint8_t) stcb->asoc.chunks_on_out_queue;
else
- sctp_clog[sctp_cwnd_log_at].x.wake.chunks_on_oque = 0xff;
+ sctp_clog.x.wake.chunks_on_oque = 0xff;
- sctp_clog[sctp_cwnd_log_at].x.wake.sctpflags = 0;
+ sctp_clog.x.wake.sctpflags = 0;
/* set in the defered mode stuff */
if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE)
- sctp_clog[sctp_cwnd_log_at].x.wake.sctpflags |= 1;
+ sctp_clog.x.wake.sctpflags |= 1;
if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEOUTPUT)
- sctp_clog[sctp_cwnd_log_at].x.wake.sctpflags |= 2;
+ sctp_clog.x.wake.sctpflags |= 2;
if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_WAKEINPUT)
- sctp_clog[sctp_cwnd_log_at].x.wake.sctpflags |= 4;
+ sctp_clog.x.wake.sctpflags |= 4;
/* what about the sb */
if (stcb->sctp_socket) {
struct socket *so = stcb->sctp_socket;
- sctp_clog[sctp_cwnd_log_at].x.wake.sbflags = (uint8_t) ((so->so_snd.sb_flags & 0x00ff));
+ sctp_clog.x.wake.sbflags = (uint8_t) ((so->so_snd.sb_flags & 0x00ff));
} else {
- sctp_clog[sctp_cwnd_log_at].x.wake.sbflags = 0xff;
+ sctp_clog.x.wake.sbflags = 0xff;
}
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_WAKE,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
void
sctp_log_block(uint8_t from, struct socket *so, struct sctp_association *asoc, int sendlen)
{
- int sctp_cwnd_log_at;
-
- SCTP_STATLOG_GETREF(sctp_cwnd_log_at);
- sctp_clog[sctp_cwnd_log_at].from = (uint8_t) from;
- sctp_clog[sctp_cwnd_log_at].time_event = sctp_get_time_of_event();
- sctp_clog[sctp_cwnd_log_at].event_type = (uint8_t) SCTP_LOG_EVENT_BLOCK;
- sctp_clog[sctp_cwnd_log_at].x.blk.onsb = asoc->total_output_queue_size;
- sctp_clog[sctp_cwnd_log_at].x.blk.send_sent_qcnt = (uint16_t) (asoc->send_queue_cnt + asoc->sent_queue_cnt);
- sctp_clog[sctp_cwnd_log_at].x.blk.peer_rwnd = asoc->peers_rwnd;
- sctp_clog[sctp_cwnd_log_at].x.blk.stream_qcnt = (uint16_t) asoc->stream_queue_cnt;
- sctp_clog[sctp_cwnd_log_at].x.blk.chunks_on_oque = (uint16_t) asoc->chunks_on_out_queue;
- sctp_clog[sctp_cwnd_log_at].x.blk.flight_size = (uint16_t) (asoc->total_flight / 1024);
- sctp_clog[sctp_cwnd_log_at].x.blk.sndlen = sendlen;
+ struct sctp_cwnd_log sctp_clog;
+
+ sctp_clog.x.blk.onsb = asoc->total_output_queue_size;
+ sctp_clog.x.blk.send_sent_qcnt = (uint16_t) (asoc->send_queue_cnt + asoc->sent_queue_cnt);
+ sctp_clog.x.blk.peer_rwnd = asoc->peers_rwnd;
+ sctp_clog.x.blk.stream_qcnt = (uint16_t) asoc->stream_queue_cnt;
+ sctp_clog.x.blk.chunks_on_oque = (uint16_t) asoc->chunks_on_out_queue;
+ sctp_clog.x.blk.flight_size = (uint16_t) (asoc->total_flight / 1024);
+ sctp_clog.x.blk.sndlen = sendlen;
+ CTR6(SCTP_SUBSYS_KTR, "SCTP:%d[%d]:%x-%x-%x-%x",
+ SCTP_LOG_EVENT_BLOCK,
+ from,
+ sctp_clog.x.misc.log1,
+ sctp_clog.x.misc.log2,
+ sctp_clog.x.misc.log3,
+ sctp_clog.x.misc.log4);
+
}
int
sctp_fill_stat_log(void *optval, size_t *optsize)
{
- int sctp_cwnd_log_at;
- struct sctp_cwnd_log_req *req;
- size_t size_limit;
- int num, i, at, cnt_out = 0;
-
- if (*optsize < sizeof(struct sctp_cwnd_log_req)) {
- return (EINVAL);
- }
- size_limit = (*optsize - sizeof(struct sctp_cwnd_log_req));
- if (size_limit < sizeof(struct sctp_cwnd_log)) {
- return (EINVAL);
- }
- sctp_cwnd_log_at = global_sctp_cwnd_log_at;
- req = (struct sctp_cwnd_log_req *)optval;
- num = size_limit / sizeof(struct sctp_cwnd_log);
- if (global_sctp_cwnd_log_rolled) {
- req->num_in_log = SCTP_STAT_LOG_SIZE;
- } else {
- req->num_in_log = sctp_cwnd_log_at;
- /*
- * if the log has not rolled, we don't let you have old
- * data.
- */
- if (req->end_at > sctp_cwnd_log_at) {
- req->end_at = sctp_cwnd_log_at;
- }
- }
- if ((num < SCTP_STAT_LOG_SIZE) &&
- ((global_sctp_cwnd_log_rolled) || (sctp_cwnd_log_at > num))) {
- /* we can't return all of it */
- if (((req->start_at == 0) && (req->end_at == 0)) ||
- (req->start_at >= SCTP_STAT_LOG_SIZE) ||
- (req->end_at >= SCTP_STAT_LOG_SIZE)) {
- /* No user request or user is wacked. */
- req->num_ret = num;
- req->end_at = sctp_cwnd_log_at - 1;
- if ((sctp_cwnd_log_at - num) < 0) {
- int cc;
-
- cc = num - sctp_cwnd_log_at;
- req->start_at = SCTP_STAT_LOG_SIZE - cc;
- } else {
- req->start_at = sctp_cwnd_log_at - num;
- }
- } else {
- /* a user request */
- int cc;
-
- if (req->start_at > req->end_at) {
- cc = (SCTP_STAT_LOG_SIZE - req->start_at) +
- (req->end_at + 1);
- } else {
-
- cc = (req->end_at - req->start_at) + 1;
- }
- if (cc < num) {
- num = cc;
- }
- req->num_ret = num;
- }
- } else {
- /* We can return all of it */
- req->start_at = 0;
- req->end_at = sctp_cwnd_log_at - 1;
- req->num_ret = sctp_cwnd_log_at;
- }
-#ifdef INVARIANTS
- if (req->num_ret > num) {
- panic("Bad statlog get?");
- }
-#endif
- for (i = 0, at = req->start_at; i < req->num_ret; i++) {
- req->log[i] = sctp_clog[at];
- cnt_out++;
- at++;
- if (at >= SCTP_STAT_LOG_SIZE)
- at = 0;
- }
- *optsize = (cnt_out * sizeof(struct sctp_cwnd_log)) + sizeof(struct sctp_cwnd_log_req);
+ /* May need to fix this if ktrdump does not work */
return (0);
}
-#endif
-
#ifdef SCTP_AUDITING_ENABLED
uint8_t sctp_audit_data[SCTP_AUDIT_SIZE][2];
static int sctp_audit_indx = 0;
@@ -2579,9 +2534,9 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
if (net->RTO_measured) {
calc_time -= (net->lastsa >> SCTP_RTT_SHIFT); /* take away 1/8th when
* shift=3 */
-#ifdef SCTP_RTTVAR_LOGGING
- rto_logging(net, SCTP_LOG_RTTVAR);
-#endif
+ if (sctp_logging_level & SCTP_RTTVAR_LOGGING_ENABLE) {
+ rto_logging(net, SCTP_LOG_RTTVAR);
+ }
net->prev_rtt = o_calctime;
net->lastsa += calc_time; /* add 7/8th into sa when
* shift=3 */
@@ -2605,9 +2560,9 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
}
first_measure = 1;
net->prev_rtt = o_calctime;
-#ifdef SCTP_RTTVAR_LOGGING
- rto_logging(net, SCTP_LOG_INITIAL_RTT);
-#endif
+ if (sctp_logging_level & SCTP_RTTVAR_LOGGING_ENABLE) {
+ rto_logging(net, SCTP_LOG_INITIAL_RTT);
+ }
}
calc_rto:
new_rto = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv;
@@ -3124,13 +3079,13 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb,
SCTP_INP_READ_LOCK(stcb->sctp_ep);
}
sb = &stcb->sctp_socket->so_rcv;
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m_notify));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m_notify));
+ }
sctp_sballoc(stcb, sb, m_notify);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
atomic_add_int(&control->length, SCTP_BUF_LEN(m_notify));
control->end_added = 1;
if (stcb->asoc.control_pdapi)
@@ -3996,13 +3951,13 @@ sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp,
TAILQ_INSERT_TAIL(&tmp_queue, control, next);
m = control->data;
while (m) {
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
+ }
sctp_sbfree(control, stcb, &old_so->so_rcv, m);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&old_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
m = SCTP_BUF_NEXT(m);
}
}
@@ -4020,13 +3975,13 @@ sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp,
TAILQ_INSERT_TAIL(&new_inp->read_queue, control, next);
m = control->data;
while (m) {
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
+ }
sctp_sballoc(stcb, &new_so->so_rcv, m);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&new_so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
m = SCTP_BUF_NEXT(m);
}
control = nctl;
@@ -4083,13 +4038,13 @@ sctp_add_to_readq(struct sctp_inpcb *inp,
continue;
}
prev = m;
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(m));
+ }
sctp_sballoc(stcb, sb, m);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
atomic_add_int(&control->length, SCTP_BUF_LEN(m));
m = SCTP_BUF_NEXT(m);
}
@@ -4168,13 +4123,13 @@ get_out:
prev = mm;
len += SCTP_BUF_LEN(mm);
if (sb) {
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(mm));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBALLOC, SCTP_BUF_LEN(mm));
+ }
sctp_sballoc(stcb, sb, mm);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(sb, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
}
mm = SCTP_BUF_NEXT(mm);
}
@@ -4274,11 +4229,13 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc,
return;
}
asoc->chunks_on_out_queue -= chk_cnt;
- sctp_log_mbcnt(SCTP_LOG_MBCNT_DECREASE,
- asoc->total_output_queue_size,
- tp1->book_size,
- 0,
- tp1->mbcnt);
+ if (sctp_logging_level & SCTP_MBCNT_LOGGING_ENABLE) {
+ sctp_log_mbcnt(SCTP_LOG_MBCNT_DECREASE,
+ asoc->total_output_queue_size,
+ tp1->book_size,
+ 0,
+ tp1->mbcnt);
+ }
if (asoc->total_output_queue_size >= tp1->book_size) {
atomic_add_int(&asoc->total_output_queue_size, -tp1->book_size);
} else {
@@ -4371,7 +4328,8 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
* ifa_ifwithaddr() compares the entire sockaddr struct
*/
struct sctp_ifa *
-sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int holds_lock)
+sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr,
+ int holds_lock)
{
struct sctp_laddr *laddr;
@@ -4528,13 +4486,6 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t * freed_so_far, int hold_rlock,
}
atomic_add_int(&stcb->freed_by_sorcv_sincelast, *freed_so_far);
/* Have you have freed enough to look */
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_ENTER_USER_RECV,
- (stcb->asoc.my_rwnd - stcb->asoc.my_last_reported_rwnd),
- *freed_so_far,
- stcb->freed_by_sorcv_sincelast,
- rwnd_req);
-#endif
*freed_so_far = 0;
/* Yep, its worth a look and the lock overhead */
@@ -4564,13 +4515,6 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t * freed_so_far, int hold_rlock,
SCTP_TCB_UNLOCK(stcb);
goto out;
}
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_USER_RECV_SACKS,
- stcb->asoc.my_rwnd,
- stcb->asoc.my_last_reported_rwnd,
- stcb->freed_by_sorcv_sincelast,
- dif);
-#endif
SCTP_STAT_INCR(sctps_wu_sacks_sent);
sctp_send_sack(stcb);
sctp_chunk_output(stcb->sctp_ep, stcb,
@@ -4581,13 +4525,6 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t * freed_so_far, int hold_rlock,
} else {
/* Update how much we have pending */
stcb->freed_by_sorcv_sincelast = dif;
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_USER_RECV_SACKS,
- stcb->asoc.my_rwnd,
- stcb->asoc.my_last_reported_rwnd,
- stcb->freed_by_sorcv_sincelast,
- 0);
-#endif
}
out:
if (so && r_unlocked && hold_rlock) {
@@ -4675,16 +4612,14 @@ sctp_sorecvmsg(struct socket *so,
if (rwnd_req < SCTP_MIN_RWND)
rwnd_req = SCTP_MIN_RWND;
in_eeor_mode = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR);
-#ifdef SCTP_RECV_RWND_LOGGING
- sctp_misc_ints(SCTP_SORECV_ENTER,
- rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, uio->uio_resid);
-#endif
-#ifdef SCTP_RECV_RWND_LOGGING
- sctp_misc_ints(SCTP_SORECV_ENTERPL,
- rwnd_req, block_allowed, so->so_rcv.sb_cc, uio->uio_resid);
-#endif
-
-
+ if (sctp_logging_level & SCTP_RECV_RWND_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_SORECV_ENTER,
+ rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, uio->uio_resid);
+ }
+ if (sctp_logging_level & SCTP_RECV_RWND_LOGGING_ENABLE) {
+ sctp_misc_ints(SCTP_SORECV_ENTERPL,
+ rwnd_req, block_allowed, so->so_rcv.sb_cc, uio->uio_resid);
+ }
error = sblock(&so->so_rcv, (block_allowed ? M_WAITOK : 0));
sockbuf_lock = 1;
if (error) {
@@ -4714,10 +4649,6 @@ restart_nosblocks:
}
if ((so->so_rcv.sb_cc <= held_length) && block_allowed) {
/* we need to wait for data */
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORECV_BLOCKSA,
- 0, 0, so->so_rcv.sb_cc, uio->uio_resid);
-#endif
if ((so->so_rcv.sb_cc == 0) &&
((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) {
@@ -5105,13 +5036,6 @@ get_more_data:
}
if (cp_len > 0)
error = uiomove(mtod(m, char *), cp_len, uio);
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_DOESCPY,
- so->so_rcv.sb_cc,
- cp_len,
- 0,
- 0);
-#endif
/* re-read */
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
goto release;
@@ -5130,24 +5054,10 @@ get_more_data:
(control->end_added &&
(TAILQ_NEXT(control, next) == NULL)))
) {
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_DOESLCK,
- so->so_rcv.sb_cc,
- cp_len,
- SCTP_BUF_LEN(m),
- control->length);
-#endif
SCTP_INP_READ_LOCK(inp);
hold_rlock = 1;
}
if (cp_len == SCTP_BUF_LEN(m)) {
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_DOESADJ,
- so->so_rcv.sb_cc,
- control->length,
- cp_len,
- 0);
-#endif
if ((SCTP_BUF_NEXT(m) == NULL) &&
(control->end_added)) {
out_flags |= MSG_EOR;
@@ -5164,15 +5074,15 @@ get_more_data:
copied_so_far += cp_len;
} else {
/* dispose of the mbuf */
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv,
- control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv,
+ control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
+ }
sctp_sbfree(control, stcb, &so->so_rcv, m);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv,
- control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv,
+ control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
embuf = m;
copied_so_far += cp_len;
freed_so_far += cp_len;
@@ -5180,13 +5090,6 @@ get_more_data:
if (alen < cp_len) {
panic("Control length goes negative?");
}
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_PASSBF,
- so->so_rcv.sb_cc,
- control->length,
- 0,
- 0);
-#endif
control->data = sctp_m_free(m);
m = control->data;
/*
@@ -5216,13 +5119,6 @@ get_more_data:
}
#endif
}
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_ADJD,
- so->so_rcv.sb_cc,
- control->length,
- 0,
- 0);
-#endif
}
} else {
/* Do we need to trim the mbuf? */
@@ -5232,9 +5128,9 @@ get_more_data:
if ((in_flags & MSG_PEEK) == 0) {
SCTP_BUF_RESV_UF(m, cp_len);
SCTP_BUF_LEN(m) -= cp_len;
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, cp_len);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, cp_len);
+ }
atomic_subtract_int(&so->so_rcv.sb_cc, cp_len);
if ((control->do_not_ref_stcb == 0) &&
stcb) {
@@ -5243,10 +5139,10 @@ get_more_data:
copied_so_far += cp_len;
embuf = m;
freed_so_far += cp_len;
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb,
- SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb,
+ SCTP_LOG_SBRESULT, 0);
+ }
alen = atomic_fetchadd_int(&control->length, -(cp_len));
if (alen < cp_len) {
panic("Control length goes negative2?");
@@ -5263,14 +5159,6 @@ get_more_data:
(freed_so_far >= rwnd_req)) {
sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
}
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_BOTWHILE,
- so->so_rcv.sb_cc,
- control->length,
- 0,
- 0);
-#endif
-
} /* end while(m) */
/*
* At this point we have looked at it all and we either have
@@ -5290,13 +5178,6 @@ get_more_data:
#endif
}
done_with_control:
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- sctp_misc_ints(SCTP_SORCV_FREECTL,
- so->so_rcv.sb_cc,
- 0,
- 0,
- 0);
-#endif
if (TAILQ_NEXT(control, next) == NULL) {
/*
* If we don't have a next we need a
@@ -5397,20 +5278,6 @@ wait_some_more:
SOCKBUF_LOCK(&so->so_rcv);
hold_sblock = 1;
}
-#ifdef SCTP_RECV_DETAIL_RWND_LOGGING
- if (stcb)
- sctp_misc_ints(SCTP_SORECV_BLOCKSB,
- freed_so_far,
- stcb->asoc.my_rwnd,
- so->so_rcv.sb_cc,
- uio->uio_resid);
- else
- sctp_misc_ints(SCTP_SORECV_BLOCKSB,
- freed_so_far,
- 0,
- so->so_rcv.sb_cc,
- uio->uio_resid);
-#endif
if (so->so_rcv.sb_cc <= control->held_length) {
error = sbwait(&so->so_rcv);
if (error) {
@@ -5486,16 +5353,16 @@ wait_some_more:
*mp = control->data;
m = control->data;
while (m) {
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv,
- control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv,
+ control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
+ }
sctp_sbfree(control, stcb, &so->so_rcv, m);
freed_so_far += SCTP_BUF_LEN(m);
-#ifdef SCTP_SB_LOGGING
- sctp_sblog(&so->so_rcv,
- control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
-#endif
+ if (sctp_logging_level & SCTP_SB_LOGGING_ENABLE) {
+ sctp_sblog(&so->so_rcv,
+ control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBRESULT, 0);
+ }
m = SCTP_BUF_NEXT(m);
}
control->data = control->tail_mbuf = NULL;
@@ -5566,21 +5433,21 @@ out:
/* Save the value back for next time */
stcb->freed_by_sorcv_sincelast = freed_so_far;
}
-#ifdef SCTP_RECV_RWND_LOGGING
- if (stcb) {
- sctp_misc_ints(SCTP_SORECV_DONE,
- freed_so_far,
- ((uio) ? (slen - uio->uio_resid) : slen),
- stcb->asoc.my_rwnd,
- so->so_rcv.sb_cc);
- } else {
- sctp_misc_ints(SCTP_SORECV_DONE,
- freed_so_far,
- ((uio) ? (slen - uio->uio_resid) : slen),
- 0,
- so->so_rcv.sb_cc);
+ if (sctp_logging_level & SCTP_RECV_RWND_LOGGING_ENABLE) {
+ if (stcb) {
+ sctp_misc_ints(SCTP_SORECV_DONE,
+ freed_so_far,
+ ((uio) ? (slen - uio->uio_resid) : slen),
+ stcb->asoc.my_rwnd,
+ so->so_rcv.sb_cc);
+ } else {
+ sctp_misc_ints(SCTP_SORECV_DONE,
+ freed_so_far,
+ ((uio) ? (slen - uio->uio_resid) : slen),
+ 0,
+ so->so_rcv.sb_cc);
+ }
}
-#endif
if (wakeup_read_socket) {
sctp_sorwakeup(inp, so);
}
@@ -5592,8 +5459,10 @@ out:
struct mbuf *
sctp_m_free(struct mbuf *m)
{
- if (SCTP_BUF_IS_EXTENDED(m)) {
- sctp_log_mb(m, SCTP_MBUF_IFREE);
+ if (sctp_logging_level & SCTP_MBUF_LOGGING_ENABLE) {
+ if (SCTP_BUF_IS_EXTENDED(m)) {
+ sctp_log_mb(m, SCTP_MBUF_IFREE);
+ }
}
return (m_free(m));
}
@@ -5879,7 +5748,6 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
return ((struct sctp_tcb *)NULL);
}
-
/*
* sctp_bindx(ADD) for one address.
* assumes all arguments are valid/checked by caller.
@@ -5942,7 +5810,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
*error = EINVAL;
return;
}
- *error = sctp_inpcb_bind(so, addr_touse, p);
+ *error = sctp_inpcb_bind(so, addr_touse, NULL, p);
return;
}
/*
@@ -5971,7 +5839,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
((struct sockaddr_in *)addr_touse)->sin_port = 0;
*error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
SCTP_ADD_IP_ADDRESS,
- vrf_id);
+ vrf_id, NULL);
} else {
*error = EADDRINUSE;
}
@@ -6049,7 +5917,7 @@ sctp_bindx_delete_address(struct socket *so, struct sctp_inpcb *inp,
/* delete the address */
*error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
SCTP_DEL_IP_ADDRESS,
- vrf_id);
+ vrf_id, NULL);
} else {
/*
* FIX: decide whether we allow assoc based bindx
diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h
index ad82186..5e8ff76 100644
--- a/sys/netinet/sctputil.h
+++ b/sys/netinet/sctputil.h
@@ -40,60 +40,6 @@ __FBSDID("$FreeBSD$");
#if defined(_KERNEL)
-/*-
- * Any new logging added must also define SCTP_STAT_LOGGING if
- * its not already defined.
- */
-
-#if defined(SCTP_LOG_MAXBURST) || defined(SCTP_LOG_RWND)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_CWND_LOGGING) || defined(SCTP_CWND_MONITOR) || defined(SCTP_BLK_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_STR_LOGGING) || defined(SCTP_FR_LOGGING) || defined(SCTP_MAP_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_SACK_LOGGING) || defined(SCTP_LOCK_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_RTTVAR_LOGGING) || defined(SCTP_SB_LOGGING) || defined(SCTP_EARLYFR_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_NAGLE_LOGGING) || defined(SCTP_WAKE_LOGGING) || defined(SCTP_RECV_RWND_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_SACK_RWND_LOGGING) || defined(SCTP_FLIGHT_LOGGING) || defined(SCTP_MBUF_LOGGING)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-#if defined(SCTP_LOG_SACK_ARRIVALS)
-#ifndef SCTP_STAT_LOGGING
-#define SCTP_STAT_LOGGING 1
-#endif
-#endif
-
-
#ifdef SCTP_ASOCLOG_OF_TSNS
void sctp_print_out_track_log(struct sctp_tcb *stcb);
@@ -276,7 +222,7 @@ sctp_bindx_delete_address(struct socket *so, struct sctp_inpcb *inp,
#ifdef SCTP_MBCNT_LOGGING
void
sctp_free_bufspace(struct sctp_tcb *, struct sctp_association *,
- struct sctp_tmit_chunk *);
+ struct sctp_tmit_chunk *, int);
#else
#define sctp_free_bufspace(stcb, asoc, tp1, chk_cnt) \
@@ -353,7 +299,6 @@ sctp_l_soreceive(struct socket *so,
int *flag);
-#ifdef SCTP_STAT_LOGGING
void
sctp_misc_ints(uint8_t from, uint32_t a, uint32_t b, uint32_t c, uint32_t d);
@@ -396,7 +341,6 @@ void sctp_log_map(uint32_t, uint32_t, uint32_t, int);
void sctp_clr_stat_log(void);
-#endif
#ifdef SCTP_AUDITING_ENABLED
void
OpenPOWER on IntegriCloud