From 57b5ffa4079cba20b90808aab209fda93856e917 Mon Sep 17 00:00:00 2001 From: tuexen Date: Fri, 29 May 2015 12:03:02 +0000 Subject: [PATCH] MFC r276914: Minimize the usage of SCTP_BUF_IS_EXTENDED. This should help Robert... git-svn-id: svn://svn.freebsd.org/base/stable/10@283708 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/netinet/sctp_bsd_addr.c | 4 +-- sys/netinet/sctp_indata.c | 8 +---- sys/netinet/sctp_input.c | 24 ++------------ sys/netinet/sctp_output.c | 64 +++++-------------------------------- sys/netinet/sctputil.c | 22 ++++++++++--- sys/netinet/sctputil.h | 7 +++- sys/netinet6/sctp6_usrreq.c | 8 +---- 7 files changed, 38 insertions(+), 99 deletions(-) diff --git a/sys/netinet/sctp_bsd_addr.c b/sys/netinet/sctp_bsd_addr.c index 520670fa5..3d90a1849 100644 --- a/sys/netinet/sctp_bsd_addr.c +++ b/sys/netinet/sctp_bsd_addr.c @@ -402,9 +402,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IALLOC); - } + sctp_log_mb(m, SCTP_MBUF_IALLOC); } #endif return (m); diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index 4e88be52c..5a7061516 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -1493,13 +1493,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, the_len, M_NOWAIT); #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = dmbuf; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(dmbuf, SCTP_MBUF_ICOPY); } #endif } else { diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index ce740bf2b..2b4045627 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -2443,13 +2443,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m_sig; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_SPLIT); - } - } + sctp_log_mbc(m_sig, SCTP_MBUF_SPLIT); } #endif @@ -5527,13 +5521,7 @@ __attribute__((noinline)) } else { #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = SCTP_BUF_NEXT(mm); mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(SCTP_BUF_NEXT(mm), SCTP_MBUF_ICOPY); } #endif sctp_queue_op_err(stcb, mm); @@ -6038,13 +6026,7 @@ sctp_input_with_port(struct mbuf *i_pak, int off, uint16_t port) #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_INPUT); - } - } + sctp_log_mbc(m, SCTP_MBUF_INPUT); } #endif #ifdef SCTP_PACKET_LOGGING diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index bd65378ea..cec4869a6 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -3846,13 +3846,7 @@ sctp_add_cookie(struct mbuf *init, int init_offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = copy_init; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(copy_init, SCTP_MBUF_ICOPY); } #endif copy_initack = SCTP_M_COPYM(initack, initack_offset, M_COPYALL, @@ -3864,13 +3858,7 @@ sctp_add_cookie(struct mbuf *init, int init_offset, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = copy_initack; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(copy_initack, SCTP_MBUF_ICOPY); } #endif /* easy side we just drop it on the end */ @@ -6482,13 +6470,7 @@ sctp_copy_mbufchain(struct mbuf *clonechain, appendchain = SCTP_M_COPYM(clonechain, 0, M_COPYALL, M_NOWAIT); #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = appendchain; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(appendchain, SCTP_MBUF_ICOPY); } #endif } @@ -6581,13 +6563,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(m, SCTP_MBUF_ICOPY); } #endif } else { @@ -7371,13 +7347,7 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = chk->data; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(chk->data, SCTP_MBUF_ICOPY); } #endif /* Pull off the data */ @@ -8973,13 +8943,7 @@ sctp_send_cookie_echo(struct mbuf *m, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = cookie; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(cookie, SCTP_MBUF_ICOPY); } #endif break; @@ -9045,13 +9009,7 @@ sctp_send_heartbeat_ack(struct sctp_tcb *stcb, } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = outchain; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(outchain, SCTP_MBUF_ICOPY); } #endif chdr = mtod(outchain, struct sctp_chunkhdr *); @@ -9330,13 +9288,7 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) } #ifdef SCTP_MBUF_LOGGING if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m_ack; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_ICOPY); - } - } + sctp_log_mbc(m_ack, SCTP_MBUF_ICOPY); } #endif diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index edf6ae852..057fe2a2c 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -217,6 +217,7 @@ sctp_log_fr(uint32_t biggest_tsn, uint32_t biggest_new_tsn, uint32_t tsn, int fr sctp_clog.x.misc.log4); } +#ifdef SCTP_MBUF_LOGGING void sctp_log_mb(struct mbuf *m, int from) { @@ -242,6 +243,18 @@ sctp_log_mb(struct mbuf *m, int from) sctp_clog.x.misc.log4); } +void +sctp_log_mbc(struct mbuf *m, int from) +{ + struct mbuf *mat; + + for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { + sctp_log_mb(mat, from); + } +} + +#endif + void sctp_log_strm_del(struct sctp_queued_to_read *control, struct sctp_queued_to_read *poschk, int from) { @@ -413,7 +426,8 @@ sctp_log_rwnd_set(uint8_t from, uint32_t peers_rwnd, uint32_t flight_size, uint3 sctp_clog.x.misc.log4); } -void +#ifdef SCTP_MBCNT_LOGGING +static void sctp_log_mbcnt(uint8_t from, uint32_t total_oq, uint32_t book, uint32_t total_mbcnt_q, uint32_t mbcnt) { struct sctp_cwnd_log sctp_clog; @@ -431,6 +445,8 @@ sctp_log_mbcnt(uint8_t from, uint32_t total_oq, uint32_t book, uint32_t total_mb sctp_clog.x.misc.log4); } +#endif + void sctp_misc_ints(uint8_t from, uint32_t a, uint32_t b, uint32_t c, uint32_t d) { @@ -6157,9 +6173,7 @@ struct mbuf * sctp_m_free(struct mbuf *m) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - if (SCTP_BUF_IS_EXTENDED(m)) { - sctp_log_mb(m, SCTP_MBUF_IFREE); - } + sctp_log_mb(m, SCTP_MBUF_IFREE); } return (m_free(m)); } diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h index 559daa376..2ffbc2aa5 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -349,9 +349,15 @@ void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t, void sctp_log_nagle_event(struct sctp_tcb *stcb, int action); +#ifdef SCTP_MBUF_LOGGING void sctp_log_mb(struct mbuf *m, int from); +void + sctp_log_mbc(struct mbuf *m, int from); + +#endif + void sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr); @@ -369,7 +375,6 @@ void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from); void sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *, int, int, uint8_t); void sctp_log_block(uint8_t, struct sctp_association *, int); void sctp_log_rwnd(uint8_t, uint32_t, uint32_t, uint32_t); -void sctp_log_mbcnt(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t); void sctp_log_rwnd_set(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t); int sctp_fill_stat_log(void *, size_t *); void sctp_log_fr(uint32_t, uint32_t, uint32_t, int); diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index ed5f84222..c5de14dbf 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -94,13 +94,7 @@ sctp6_input_with_port(struct mbuf **i_pak, int *offp, uint16_t port) #ifdef SCTP_MBUF_LOGGING /* Log in any input mbufs */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) { - struct mbuf *mat; - - for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) { - if (SCTP_BUF_IS_EXTENDED(mat)) { - sctp_log_mb(mat, SCTP_MBUF_INPUT); - } - } + sctp_log_mbc(m, SCTP_MBUF_INPUT); } #endif #ifdef SCTP_PACKET_LOGGING -- 2.45.0