svn commit: r231039 - in stable/9/sys: netinet netinet6
Michael Tuexen
tuexen at FreeBSD.org
Sun Feb 5 19:52:56 UTC 2012
Author: tuexen
Date: Sun Feb 5 19:52:55 2012
New Revision: 231039
URL: http://svn.freebsd.org/changeset/base/231039
Log:
MFC 228907:
Address issues found by clang. While there, fix also some style
issues.
Modified:
stable/9/sys/netinet/sctp_asconf.c
stable/9/sys/netinet/sctp_auth.c
stable/9/sys/netinet/sctp_cc_functions.c
stable/9/sys/netinet/sctp_constants.h
stable/9/sys/netinet/sctp_indata.c
stable/9/sys/netinet/sctp_input.c
stable/9/sys/netinet/sctp_output.c
stable/9/sys/netinet/sctp_pcb.c
stable/9/sys/netinet/sctp_ss_functions.c
stable/9/sys/netinet/sctp_sysctl.c
stable/9/sys/netinet/sctp_timer.c
stable/9/sys/netinet/sctp_usrreq.c
stable/9/sys/netinet/sctp_var.h
stable/9/sys/netinet/sctputil.c
stable/9/sys/netinet6/sctp6_usrreq.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/netinet/sctp_asconf.c
==============================================================================
--- stable/9/sys/netinet/sctp_asconf.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_asconf.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -138,7 +138,7 @@ sctp_asconf_success_response(uint32_t id
if (m_reply == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_success_response: couldn't get mbuf!\n");
- return NULL;
+ return (NULL);
}
aph = mtod(m_reply, struct sctp_asconf_paramhdr *);
aph->correlation_id = id;
@@ -147,7 +147,7 @@ sctp_asconf_success_response(uint32_t id
SCTP_BUF_LEN(m_reply) = aph->ph.param_length;
aph->ph.param_length = htons(aph->ph.param_length);
- return m_reply;
+ return (m_reply);
}
static struct mbuf *
@@ -166,7 +166,7 @@ sctp_asconf_error_response(uint32_t id,
if (m_reply == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_error_response: couldn't get mbuf!\n");
- return NULL;
+ return (NULL);
}
aph = mtod(m_reply, struct sctp_asconf_paramhdr *);
error = (struct sctp_error_cause *)(aph + 1);
@@ -183,7 +183,7 @@ sctp_asconf_error_response(uint32_t id,
"asconf_error_response: tlv_length (%xh) too big\n",
tlv_length);
sctp_m_freem(m_reply); /* discard */
- return NULL;
+ return (NULL);
}
if (error_tlv != NULL) {
tlv = (uint8_t *) (error + 1);
@@ -193,7 +193,7 @@ sctp_asconf_error_response(uint32_t id,
error->length = htons(error->length);
aph->ph.param_length = htons(aph->ph.param_length);
- return m_reply;
+ return (m_reply);
}
static struct mbuf *
@@ -231,7 +231,7 @@ sctp_process_asconf_add_ip(struct mbuf *
case SCTP_IPV4_ADDRESS:
if (param_length != sizeof(struct sctp_ipv4addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v4addr = (struct sctp_ipv4addr_param *)ph;
sin = (struct sockaddr_in *)&sa_store;
@@ -254,7 +254,7 @@ sctp_process_asconf_add_ip(struct mbuf *
case SCTP_IPV6_ADDRESS:
if (param_length != sizeof(struct sctp_ipv6addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v6addr = (struct sctp_ipv6addr_param *)ph;
sin6 = (struct sockaddr_in6 *)&sa_store;
@@ -277,7 +277,7 @@ sctp_process_asconf_add_ip(struct mbuf *
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_INVALID_PARAM, (uint8_t *) aph,
aparam_length);
- return m_reply;
+ return (m_reply);
} /* end switch */
/* if 0.0.0.0/::0, add the source address instead */
@@ -314,7 +314,7 @@ sctp_process_asconf_add_ip(struct mbuf *
sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
}
}
- return m_reply;
+ return (m_reply);
}
static int
@@ -326,7 +326,7 @@ sctp_asconf_del_remote_addrs_except(stru
src_net = sctp_findnet(stcb, src);
if (src_net == NULL) {
/* not found */
- return -1;
+ return (-1);
}
/* delete all destination addresses except the source */
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
@@ -342,7 +342,7 @@ sctp_asconf_del_remote_addrs_except(stru
(struct sockaddr *)&net->ro._l_addr, SCTP_SO_NOT_LOCKED);
}
}
- return 0;
+ return (0);
}
static struct mbuf *
@@ -382,7 +382,7 @@ sctp_process_asconf_delete_ip(struct mbu
case SCTP_IPV4_ADDRESS:
if (param_length != sizeof(struct sctp_ipv4addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v4addr = (struct sctp_ipv4addr_param *)ph;
sin = (struct sockaddr_in *)&sa_store;
@@ -402,7 +402,7 @@ sctp_process_asconf_delete_ip(struct mbu
case SCTP_IPV6_ADDRESS:
if (param_length != sizeof(struct sctp_ipv6addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v6addr = (struct sctp_ipv6addr_param *)ph;
sin6 = (struct sockaddr_in6 *)&sa_store;
@@ -423,7 +423,7 @@ sctp_process_asconf_delete_ip(struct mbu
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
aparam_length);
- return m_reply;
+ return (m_reply);
}
/* make sure the source address is not being deleted */
@@ -433,7 +433,7 @@ sctp_process_asconf_delete_ip(struct mbu
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_DELETING_SRC_ADDR, (uint8_t *) aph,
aparam_length);
- return m_reply;
+ return (m_reply);
}
/* if deleting 0.0.0.0/::0, delete all addresses except src addr */
if (zero_address && SCTP_BASE_SYSCTL(sctp_nat_friendly)) {
@@ -452,7 +452,7 @@ sctp_process_asconf_delete_ip(struct mbu
m_reply =
sctp_asconf_success_response(aph->correlation_id);
}
- return m_reply;
+ return (m_reply);
}
/* delete the address */
result = sctp_del_remote_addr(stcb, sa);
@@ -474,7 +474,7 @@ sctp_process_asconf_delete_ip(struct mbu
/* notify upper layer */
sctp_ulp_notify(SCTP_NOTIFY_ASCONF_DELETE_IP, stcb, 0, sa, SCTP_SO_NOT_LOCKED);
}
- return m_reply;
+ return (m_reply);
}
static struct mbuf *
@@ -511,7 +511,7 @@ sctp_process_asconf_set_primary(struct m
case SCTP_IPV4_ADDRESS:
if (param_length != sizeof(struct sctp_ipv4addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v4addr = (struct sctp_ipv4addr_param *)ph;
sin = (struct sockaddr_in *)&sa_store;
@@ -529,7 +529,7 @@ sctp_process_asconf_set_primary(struct m
case SCTP_IPV6_ADDRESS:
if (param_length != sizeof(struct sctp_ipv6addr_param)) {
/* invalid param size */
- return NULL;
+ return (NULL);
}
v6addr = (struct sctp_ipv6addr_param *)ph;
sin6 = (struct sockaddr_in6 *)&sa_store;
@@ -548,7 +548,7 @@ sctp_process_asconf_set_primary(struct m
m_reply = sctp_asconf_error_response(aph->correlation_id,
SCTP_CAUSE_UNRESOLVABLE_ADDR, (uint8_t *) aph,
aparam_length);
- return m_reply;
+ return (m_reply);
}
/* if 0.0.0.0/::0, use the source address instead */
@@ -620,7 +620,7 @@ sctp_process_asconf_set_primary(struct m
aparam_length);
}
- return m_reply;
+ return (m_reply);
}
/*
@@ -2530,9 +2530,9 @@ sctp_is_addr_pending(struct sctp_tcb *st
*/
if (add_cnt > del_cnt ||
(add_cnt == del_cnt && last_param_type == SCTP_ADD_IP_ADDRESS)) {
- return 1;
+ return (1);
}
- return 0;
+ return (0);
}
static struct sockaddr *
Modified: stable/9/sys/netinet/sctp_auth.c
==============================================================================
--- stable/9/sys/netinet/sctp_auth.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_auth.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -469,7 +469,6 @@ sctp_compute_hashkey(sctp_key_t * key1,
}
if (sctp_get_keylen(key2)) {
bcopy(key2->key, key_ptr, key2->keylen);
- key_ptr += key2->keylen;
}
} else {
/* key is shared + key2 + key1 */
@@ -483,7 +482,6 @@ sctp_compute_hashkey(sctp_key_t * key1,
}
if (sctp_get_keylen(key1)) {
bcopy(key1->key, key_ptr, key1->keylen);
- key_ptr += key1->keylen;
}
}
return (new_key);
Modified: stable/9/sys/netinet/sctp_cc_functions.c
==============================================================================
--- stable/9/sys/netinet/sctp_cc_functions.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_cc_functions.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -80,7 +80,6 @@ sctp_set_initial_cc_param(struct sctp_tc
}
}
net->ssthresh = assoc->peers_rwnd;
-
SDT_PROBE(sctp, cwnd, net, init,
stcb->asoc.my_vtag, ((stcb->sctp_ep->sctp_lport << 16) | (stcb->rport)), net,
0, net->cwnd);
@@ -339,7 +338,6 @@ cc_bw_same(struct sctp_tcb *stcb, struct
((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
net->flight_size,
probepoint);
-
if ((net->cc_mod.rtcc.steady_step) && (inst_ind != SCTP_INST_LOOSING)) {
if (net->cc_mod.rtcc.last_step_state == 5)
net->cc_mod.rtcc.step_cnt++;
@@ -389,7 +387,6 @@ cc_bw_decrease(struct sctp_tcb *stcb, st
((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
net->flight_size,
probepoint);
-
if (net->cc_mod.rtcc.ret_from_eq) {
/*
* Switch over to CA if we are less
@@ -408,7 +405,6 @@ cc_bw_decrease(struct sctp_tcb *stcb, st
((net->cc_mod.rtcc.lbw_rtt << 32) | net->rtt),
net->flight_size,
probepoint);
-
/* Someone else - fight for more? */
if (net->cc_mod.rtcc.steady_step) {
oth = net->cc_mod.rtcc.vol_reduce;
@@ -553,7 +549,8 @@ cc_bw_increase(struct sctp_tcb *stcb, st
static int
cc_bw_limit(struct sctp_tcb *stcb, struct sctp_nets *net, uint64_t nbw)
{
- uint64_t bw_offset, rtt_offset, rtt, vtag, probepoint;
+ uint64_t bw_offset, rtt_offset;
+ uint64_t probepoint, rtt, vtag;
uint64_t bytes_for_this_rtt, inst_bw;
uint64_t div, inst_off;
int bw_shift;
@@ -619,15 +616,15 @@ cc_bw_limit(struct sctp_tcb *stcb, struc
inst_ind = SCTP_INST_NEUTRAL;
probepoint |= ((0xb << 16) | inst_ind);
} else {
+ inst_ind = net->cc_mod.rtcc.last_inst_ind;
inst_bw = bytes_for_this_rtt / (uint64_t) (net->rtt);
/* Can't determine do not change */
- inst_ind = net->cc_mod.rtcc.last_inst_ind;
probepoint |= ((0xc << 16) | inst_ind);
}
} else {
+ inst_ind = net->cc_mod.rtcc.last_inst_ind;
inst_bw = bytes_for_this_rtt;
/* Can't determine do not change */
- inst_ind = net->cc_mod.rtcc.last_inst_ind;
probepoint |= ((0xd << 16) | inst_ind);
}
SDT_PROBE(sctp, cwnd, net, rttvar,
@@ -702,15 +699,18 @@ sctp_cwnd_update_after_sack_common(struc
}
}
}
- if (t_ucwnd_sbw == 0) {
- t_ucwnd_sbw = 1;
- }
if (t_path_mptcp > 0) {
mptcp_like_alpha = max_path / (t_path_mptcp * t_path_mptcp);
} else {
mptcp_like_alpha = 1;
}
}
+ if (t_ssthresh == 0) {
+ t_ssthresh = 1;
+ }
+ if (t_ucwnd_sbw == 0) {
+ t_ucwnd_sbw = 1;
+ }
/******************************/
/* update cwnd and Early FR */
/******************************/
@@ -1012,6 +1012,9 @@ sctp_cwnd_update_after_timeout(struct sc
t_ucwnd_sbw += (uint64_t) lnet->cwnd / (uint64_t) srtt;
}
}
+ if (t_ssthresh < 1) {
+ t_ssthresh = 1;
+ }
if (t_ucwnd_sbw < 1) {
t_ucwnd_sbw = 1;
}
@@ -1841,19 +1844,19 @@ static int use_bandwidth_switch = 1;
static inline int
between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
{
- return seq3 - seq2 >= seq1 - seq2;
+ return (seq3 - seq2 >= seq1 - seq2);
}
static inline uint32_t
htcp_cong_time(struct htcp *ca)
{
- return sctp_get_tick_count() - ca->last_cong;
+ return (sctp_get_tick_count() - ca->last_cong);
}
static inline uint32_t
htcp_ccount(struct htcp *ca)
{
- return htcp_cong_time(ca) / ca->minRTT;
+ return (htcp_cong_time(ca) / ca->minRTT);
}
static inline void
@@ -1873,7 +1876,7 @@ htcp_cwnd_undo(struct sctp_tcb *stcb, st
net->cc_mod.htcp_ca.last_cong = net->cc_mod.htcp_ca.undo_last_cong;
net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.undo_maxRTT;
net->cc_mod.htcp_ca.old_maxB = net->cc_mod.htcp_ca.undo_old_maxB;
- return max(net->cwnd, ((net->ssthresh / net->mtu << 7) / net->cc_mod.htcp_ca.beta) * net->mtu);
+ return (max(net->cwnd, ((net->ssthresh / net->mtu << 7) / net->cc_mod.htcp_ca.beta) * net->mtu));
}
#endif
@@ -2017,7 +2020,7 @@ static uint32_t
htcp_recalc_ssthresh(struct sctp_nets *net)
{
htcp_param_update(net);
- return max(((net->cwnd / net->mtu * net->cc_mod.htcp_ca.beta) >> 7) * net->mtu, 2U * net->mtu);
+ return (max(((net->cwnd / net->mtu * net->cc_mod.htcp_ca.beta) >> 7) * net->mtu, 2U * net->mtu));
}
static void
@@ -2087,7 +2090,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, s
static uint32_t
htcp_min_cwnd(struct sctp_tcb *stcb, struct sctp_nets *net)
{
- return net->ssthresh;
+ return (net->ssthresh);
}
#endif
Modified: stable/9/sys/netinet/sctp_constants.h
==============================================================================
--- stable/9/sys/netinet/sctp_constants.h Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_constants.h Sun Feb 5 19:52:55 2012 (r231039)
@@ -396,7 +396,7 @@ __FBSDID("$FreeBSD$");
/* SCTP chunk types are moved sctp.h for application (NAT, FW) use */
/* align to 32-bit sizes */
-#define SCTP_SIZE32(x) ((((x)+3) >> 2) << 2)
+#define SCTP_SIZE32(x) ((((x) + 3) >> 2) << 2)
#define IS_SCTP_CONTROL(a) ((a)->chunk_type != SCTP_DATA)
#define IS_SCTP_DATA(a) ((a)->chunk_type == SCTP_DATA)
@@ -933,7 +933,7 @@ __FBSDID("$FreeBSD$");
} else { \
gap = (MAX_TSN - mapping_tsn) + tsn + 1; \
} \
- } while(0)
+ } while (0)
#define SCTP_RETRAN_DONE -1
Modified: stable/9/sys/netinet/sctp_indata.c
==============================================================================
--- stable/9/sys/netinet/sctp_indata.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_indata.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -845,7 +845,7 @@ sctp_queue_data_for_reasm(struct sctp_tc
struct sctp_tmit_chunk *chk, int *abort_flag)
{
struct mbuf *oper;
- uint32_t cum_ackp1, last_tsn, prev_tsn, post_tsn;
+ uint32_t cum_ackp1, prev_tsn, post_tsn;
struct sctp_tmit_chunk *at, *prev, *next;
prev = next = NULL;
@@ -1032,7 +1032,6 @@ sctp_queue_data_for_reasm(struct sctp_tc
sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
return;
} else {
- last_tsn = at->rec.data.TSN_seq;
prev = at;
if (TAILQ_NEXT(at, sctp_next) == NULL) {
/*
@@ -1698,12 +1697,10 @@ sctp_process_a_data_chunk(struct sctp_tc
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
struct mbuf *mat;
- mat = dmbuf;
- while (mat) {
+ for (mat = dmbuf; mat; mat = SCTP_BUF_NEXT(mat)) {
if (SCTP_BUF_IS_EXTENDED(mat)) {
sctp_log_mb(mat, SCTP_MBUF_ICOPY);
}
- mat = SCTP_BUF_NEXT(mat);
}
}
#endif
@@ -1724,10 +1721,8 @@ sctp_process_a_data_chunk(struct sctp_tc
struct mbuf *lat;
l_len = 0;
- lat = dmbuf;
- while (lat) {
+ for (lat = dmbuf; lat; lat = SCTP_BUF_NEXT(lat)) {
l_len += SCTP_BUF_LEN(lat);
- lat = SCTP_BUF_NEXT(lat);
}
}
if (l_len > the_len) {
@@ -1804,15 +1799,10 @@ failed_express_del:
if (tsn == (control->sinfo_tsn + 1)) {
/* Yep, we can add it on */
int end = 0;
- uint32_t cumack;
if (chunk_flags & SCTP_DATA_LAST_FRAG) {
end = 1;
}
- cumack = asoc->cumulative_tsn;
- if ((cumack + 1) == tsn)
- cumack = tsn;
-
if (sctp_append_to_readq(stcb->sctp_ep, stcb, control, dmbuf, end,
tsn,
&stcb->sctp_socket->so_rcv)) {
@@ -2634,7 +2624,7 @@ sctp_process_data(struct mbuf **mm, int
if (length - *offset < chk_length) {
/* all done, mutulated chunk */
stop_proc = 1;
- break;
+ continue;
}
if (ch->ch.chunk_type == SCTP_DATA) {
if ((size_t)chk_length < sizeof(struct sctp_data_chunk) + 1) {
@@ -2690,7 +2680,7 @@ sctp_process_data(struct mbuf **mm, int
* drop rep space left.
*/
stop_proc = 1;
- break;
+ continue;
}
} else {
/* not a data chunk in the data region */
@@ -2698,7 +2688,7 @@ sctp_process_data(struct mbuf **mm, int
case SCTP_INITIATION:
case SCTP_INITIATION_ACK:
case SCTP_SELECTIVE_ACK:
- case SCTP_NR_SELECTIVE_ACK: /* EY */
+ case SCTP_NR_SELECTIVE_ACK:
case SCTP_HEARTBEAT_REQUEST:
case SCTP_HEARTBEAT_ACK:
case SCTP_ABORT_ASSOCIATION:
@@ -2772,7 +2762,7 @@ sctp_process_data(struct mbuf **mm, int
} /* else skip this bad chunk and
* continue... */
break;
- }; /* switch of chunk type */
+ } /* switch of chunk type */
}
*offset += SCTP_SIZE32(chk_length);
if ((*offset >= length) || stop_proc) {
@@ -2785,10 +2775,9 @@ sctp_process_data(struct mbuf **mm, int
if (ch == NULL) {
*offset = length;
stop_proc = 1;
- break;
-
+ continue;
}
- } /* while */
+ }
if (break_flag) {
/*
* we need to report rwnd overrun drops.
@@ -3598,7 +3587,8 @@ sctp_strike_gap_ack_chunks(struct sctp_t
* this guy had a RTO calculation pending on
* it, cancel it
*/
- if (tp1->whoTo->rto_needed == 0) {
+ if ((tp1->whoTo != NULL) &&
+ (tp1->whoTo->rto_needed == 0)) {
tp1->whoTo->rto_needed = 1;
}
tp1->do_rtt = 0;
Modified: stable/9/sys/netinet/sctp_input.c
==============================================================================
--- stable/9/sys/netinet/sctp_input.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_input.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -1418,7 +1418,6 @@ sctp_process_cookie_existing(struct mbuf
struct sctp_nets *net;
struct mbuf *op_err;
struct sctp_paramhdr *ph;
- int chk_length;
int init_offset, initack_offset, i;
int retval;
int spec_flag = 0;
@@ -1468,7 +1467,6 @@ sctp_process_cookie_existing(struct mbuf
/* could not pull a INIT chunk in cookie */
return (NULL);
}
- chk_length = ntohs(init_cp->ch.chunk_length);
if (init_cp->ch.chunk_type != SCTP_INITIATION) {
return (NULL);
}
@@ -1476,7 +1474,7 @@ sctp_process_cookie_existing(struct mbuf
* find and validate the INIT-ACK chunk in the cookie (my info) the
* INIT-ACK follows the INIT chunk
*/
- initack_offset = init_offset + SCTP_SIZE32(chk_length);
+ initack_offset = init_offset + SCTP_SIZE32(ntohs(init_cp->ch.chunk_length));
initack_cp = (struct sctp_init_ack_chunk *)
sctp_m_getptr(m, initack_offset, sizeof(struct sctp_init_ack_chunk),
(uint8_t *) & initack_buf);
@@ -1484,7 +1482,6 @@ sctp_process_cookie_existing(struct mbuf
/* could not pull INIT-ACK chunk in cookie */
return (NULL);
}
- chk_length = ntohs(initack_cp->ch.chunk_length);
if (initack_cp->ch.chunk_type != SCTP_INITIATION_ACK) {
return (NULL);
}
@@ -1984,11 +1981,9 @@ sctp_process_cookie_new(struct mbuf *m,
struct sockaddr_storage sa_store;
struct sockaddr *initack_src = (struct sockaddr *)&sa_store;
struct sctp_association *asoc;
- int chk_length;
int init_offset, initack_offset, initack_limit;
int retval;
int error = 0;
- uint32_t old_tag;
uint8_t auth_chunk_buf[SCTP_PARAM_BUFFER_SIZE];
#ifdef INET
@@ -2020,12 +2015,11 @@ sctp_process_cookie_new(struct mbuf *m,
"process_cookie_new: could not pull INIT chunk hdr\n");
return (NULL);
}
- chk_length = ntohs(init_cp->ch.chunk_length);
if (init_cp->ch.chunk_type != SCTP_INITIATION) {
SCTPDBG(SCTP_DEBUG_INPUT1, "HUH? process_cookie_new: could not find INIT chunk!\n");
return (NULL);
}
- initack_offset = init_offset + SCTP_SIZE32(chk_length);
+ initack_offset = init_offset + SCTP_SIZE32(ntohs(init_cp->ch.chunk_length));
/*
* find and validate the INIT-ACK chunk in the cookie (my info) the
* INIT-ACK follows the INIT chunk
@@ -2038,7 +2032,6 @@ sctp_process_cookie_new(struct mbuf *m,
SCTPDBG(SCTP_DEBUG_INPUT1, "process_cookie_new: could not pull INIT-ACK chunk hdr\n");
return (NULL);
}
- chk_length = ntohs(initack_cp->ch.chunk_length);
if (initack_cp->ch.chunk_type != SCTP_INITIATION_ACK) {
return (NULL);
}
@@ -2115,7 +2108,6 @@ sctp_process_cookie_new(struct mbuf *m,
return (NULL);
}
/* process the INIT-ACK info (my info) */
- old_tag = asoc->my_vtag;
asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams);
@@ -2702,10 +2694,9 @@ sctp_handle_cookie_echo(struct mbuf *m,
*/
if (netl == NULL) {
/* TSNH! Huh, why do I need to add this address here? */
- int ret;
-
- ret = sctp_add_remote_addr(*stcb, to, NULL, SCTP_DONOT_SETSCOPE,
- SCTP_IN_COOKIE_PROC);
+ if (sctp_add_remote_addr(*stcb, to, NULL, SCTP_DONOT_SETSCOPE, SCTP_IN_COOKIE_PROC)) {
+ return (NULL);
+ }
netl = sctp_findnet(*stcb, to);
}
if (netl) {
@@ -3003,7 +2994,7 @@ sctp_handle_ecn_echo(struct sctp_ecne_ch
struct sctp_nets *net;
struct sctp_tmit_chunk *lchk;
struct sctp_ecne_chunk bkup;
- uint8_t override_bit = 0;
+ uint8_t override_bit;
uint32_t tsn, window_data_tsn;
int len;
unsigned int pkt_cnt;
@@ -3050,27 +3041,33 @@ sctp_handle_ecn_echo(struct sctp_ecne_ch
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
if (tsn == net->last_cwr_tsn) {
/* Found him, send it off */
- goto out;
+ break;
}
}
- /*
- * If we reach here, we need to send a special CWR that says
- * hey, we did this a long time ago and you lost the
- * response.
- */
- net = TAILQ_FIRST(&stcb->asoc.nets);
- override_bit = SCTP_CWR_REDUCE_OVERRIDE;
+ if (net == NULL) {
+ /*
+ * If we reach here, we need to send a special CWR
+ * that says hey, we did this a long time ago and
+ * you lost the response.
+ */
+ net = TAILQ_FIRST(&stcb->asoc.nets);
+ if (net == NULL) {
+ /* TSNH */
+ return;
+ }
+ override_bit = SCTP_CWR_REDUCE_OVERRIDE;
+ } else {
+ override_bit = 0;
+ }
+ } else {
+ override_bit = 0;
}
-out:
if (SCTP_TSN_GT(tsn, net->cwr_window_tsn) &&
((override_bit & SCTP_CWR_REDUCE_OVERRIDE) == 0)) {
/*
* JRS - Use the congestion control given in the pluggable
* CC module
*/
- int ocwnd;
-
- ocwnd = net->cwnd;
stcb->asoc.cc_functions.sctp_cwnd_update_after_ecn_echo(stcb, net, 0, pkt_cnt);
/*
* We reduce once every RTT. So we will only lower cwnd at
@@ -5074,7 +5071,6 @@ process_control_chunks:
}
SCTPDBG(SCTP_DEBUG_INPUT3,
"GAK, null buffer\n");
- auth_skipped = 0;
*offset = length;
return (NULL);
}
@@ -5697,7 +5693,8 @@ sctp_common_input_processing(struct mbuf
*/
}
/* take care of ecn */
- if ((stcb->asoc.ecn_allowed == 1) &&
+ if ((data_processed == 1) &&
+ (stcb->asoc.ecn_allowed == 1) &&
((ecn_bits & SCTP_CE_BITS) == SCTP_CE_BITS)) {
/* Yep, we need to add a ECNE */
sctp_send_ecn_echo(stcb, net, high_tsn);
@@ -5807,12 +5804,10 @@ sctp_input_with_port(struct mbuf *i_pak,
#ifdef SCTP_MBUF_LOGGING
/* Log in any input mbufs */
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
- mat = m;
- while (mat) {
+ for (mat = m; mat; mat = SCTP_BUF_NEXT(mat)) {
if (SCTP_BUF_IS_EXTENDED(mat)) {
sctp_log_mb(mat, SCTP_MBUF_INPUT);
}
- mat = SCTP_BUF_NEXT(mat);
}
}
#endif
Modified: stable/9/sys/netinet/sctp_output.c
==============================================================================
--- stable/9/sys/netinet/sctp_output.c Sun Feb 5 19:49:34 2012 (r231038)
+++ stable/9/sys/netinet/sctp_output.c Sun Feb 5 19:52:55 2012 (r231039)
@@ -2156,23 +2156,20 @@ skip_count:
}
cnt++;
}
- if (cnt > SCTP_ADDRESS_LIMIT) {
- limit_out = 1;
- }
/*
* To get through a NAT we only list addresses if we have
* more than one. That way if you just bind a single address
* we let the source of the init dictate our address.
*/
if (cnt > 1) {
+ cnt = cnt_inits_to;
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
- cnt = 0;
if (laddr->ifa == NULL) {
continue;
}
- if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED)
+ if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) {
continue;
-
+ }
if (sctp_is_address_in_scope(laddr->ifa,
scope->ipv4_addr_legal,
scope->ipv6_addr_legal,
@@ -3758,7 +3755,6 @@ sctp_add_cookie(struct mbuf *init, int i
/* tack the INIT and then the INIT-ACK onto the chain */
cookie_sz = 0;
- m_at = mret;
for (m_at = mret; m_at; m_at = SCTP_BUF_NEXT(m_at)) {
cookie_sz += SCTP_BUF_LEN(m_at);
if (SCTP_BUF_NEXT(m_at) == NULL) {
@@ -3766,7 +3762,6 @@ sctp_add_cookie(struct mbuf *init, int i
break;
}
}
-
for (m_at = copy_init; m_at; m_at = SCTP_BUF_NEXT(m_at)) {
cookie_sz += SCTP_BUF_LEN(m_at);
if (SCTP_BUF_NEXT(m_at) == NULL) {
@@ -3774,7 +3769,6 @@ sctp_add_cookie(struct mbuf *init, int i
break;
}
}
-
for (m_at = copy_initack; m_at; m_at = SCTP_BUF_NEXT(m_at)) {
cookie_sz += SCTP_BUF_LEN(m_at);
if (SCTP_BUF_NEXT(m_at) == NULL) {
@@ -4792,7 +4786,6 @@ sctp_send_initiate(struct sctp_inpcb *in
SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len);
}
}
- m_at = m;
/* now the addresses */
{
struct sctp_scoping scp;
@@ -4801,9 +4794,10 @@ sctp_send_initiate(struct sctp_inpcb *in
* To optimize this we could put the scoping stuff into a
* structure and remove the individual uint8's from the
* assoc structure. Then we could just sifa in the address
- * within the stcb.. but for now this is a quick hack to get
+ * within the stcb. But for now this is a quick hack to get
* the address stuff teased apart.
*/
+
scp.ipv4_addr_legal = stcb->asoc.ipv4_addr_legal;
scp.ipv6_addr_legal = stcb->asoc.ipv6_addr_legal;
scp.loopback_scope = stcb->asoc.loopback_scope;
@@ -4811,7 +4805,7 @@ sctp_send_initiate(struct sctp_inpcb *in
scp.local_scope = stcb->asoc.local_scope;
scp.site_scope = stcb->asoc.site_scope;
- m_at = sctp_add_addresses_to_i_ia(inp, stcb, &scp, m_at, cnt_inits_to);
+ sctp_add_addresses_to_i_ia(inp, stcb, &scp, m, cnt_inits_to);
}
/* calulate the size and update pkt header and chunk header */
@@ -4841,7 +4835,6 @@ sctp_send_initiate(struct sctp_inpcb *in
sctp_m_freem(m);
return;
}
- p_len += padval;
}
SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n");
ret = sctp_lowlevel_chunk_output(inp, stcb, net,
@@ -5062,7 +5055,6 @@ sctp_arethere_unrecognized_parameters(st
return (NULL);
}
m_copyback(op_err, err_at, plen, (caddr_t)phdr);
- err_at += plen;
}
return (op_err);
break;
@@ -5305,6 +5297,7 @@ sctp_are_there_new_addresses(struct sctp
p4 = (struct sctp_ipv4addr_param *)phdr;
sin4.sin_addr.s_addr = p4->addr;
sa_touse = (struct sockaddr *)&sin4;
+ break;
}
#endif
#ifdef INET6
@@ -5322,10 +5315,12 @@ sctp_are_there_new_addresses(struct sctp
memcpy((caddr_t)&sin6.sin6_addr, p6->addr,
sizeof(p6->addr));
sa_touse = (struct sockaddr *)&sin6;
+ break;
}
#endif
default:
sa_touse = NULL;
+ break;
}
if (sa_touse) {
/* ok, sa_touse points to one to check */
@@ -5534,7 +5529,7 @@ do_a_abort:
default:
goto do_a_abort;
break;
- };
+ }
if (net == NULL) {
to = (struct sockaddr *)&store;
@@ -5954,6 +5949,7 @@ do_a_abort:
llen = 0;
ol = op_err;
+
while (ol) {
llen += SCTP_BUF_LEN(ol);
ol = SCTP_BUF_NEXT(ol);
@@ -6023,15 +6019,11 @@ do_a_abort:
padval = p_len % 4;
if ((padval) && (mp_last)) {
/* see my previous comments on mp_last */
- int ret;
-
- ret = sctp_add_pad_tombuf(mp_last, (4 - padval));
- if (ret) {
+ if (sctp_add_pad_tombuf(mp_last, (4 - padval))) {
/* Houston we have a problem, no space */
sctp_m_freem(m);
return;
}
- p_len += padval;
}
if (stc.loopback_scope) {
over_addr = &store1;
@@ -6230,7 +6222,7 @@ sctp_msg_append(struct sctp_tcb *stcb,
struct mbuf *m,
struct sctp_sndrcvinfo *srcv, int hold_stcb_lock)
{
- int error = 0, holds_lock;
+ int error = 0;
struct mbuf *at;
struct sctp_stream_queue_pending *sp = NULL;
struct sctp_stream_out *strm;
@@ -6239,7 +6231,6 @@ sctp_msg_append(struct sctp_tcb *stcb,
* Given an mbuf chain, put it into the association send queue and
* place it on the wheel
*/
- holds_lock = hold_stcb_lock;
if (srcv->sinfo_stream >= stcb->asoc.streamoutcnt) {
/* Invalid stream number */
SCTP_LTRACE_ERR_RET_PKT(m, NULL, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
@@ -6308,7 +6299,9 @@ sctp_msg_append(struct sctp_tcb *stcb,
sctp_auth_key_acquire(stcb, sp->auth_keyid);
sp->holds_key_ref = 1;
}
- SCTP_TCB_SEND_LOCK(stcb);
+ if (hold_stcb_lock == 0) {
+ SCTP_TCB_SEND_LOCK(stcb);
+ }
sctp_snd_sb_alloc(stcb, sp->length);
atomic_add_int(&stcb->asoc.stream_queue_cnt, 1);
TAILQ_INSERT_TAIL(&strm->outqueue, sp, next);
@@ -6318,7 +6311,9 @@ sctp_msg_append(struct sctp_tcb *stcb,
}
stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc, strm, sp, 1);
m = NULL;
- SCTP_TCB_SEND_UNLOCK(stcb);
+ if (hold_stcb_lock == 0) {
+ SCTP_TCB_SEND_UNLOCK(stcb);
+ }
out_now:
if (m) {
sctp_m_freem(m);
@@ -7585,7 +7580,6 @@ dont_do_it:
out_of:
if (send_lock_up) {
SCTP_TCB_SEND_UNLOCK(stcb);
- send_lock_up = 0;
}
return (to_move);
}
@@ -7600,7 +7594,7 @@ sctp_fill_outqueue(struct sctp_tcb *stcb
)
{
struct sctp_association *asoc;
- struct sctp_stream_out *strq, *strqn;
+ struct sctp_stream_out *strq;
int goal_mtu, moved_how_much, total_moved = 0, bail = 0;
int locked, giveup;
@@ -7629,7 +7623,6 @@ sctp_fill_outqueue(struct sctp_tcb *stcb
strq = stcb->asoc.ss_functions.sctp_ss_select_stream(stcb, net, asoc);
locked = 0;
}
- strqn = strq;
while ((goal_mtu > 0) && strq) {
giveup = 0;
bail = 0;
@@ -7942,7 +7935,7 @@ again_one_more_time:
*/
continue;
}
- ctl_cnt = bundle_at = 0;
+ bundle_at = 0;
endoutchain = outchain = NULL;
no_fragmentflg = 1;
one_chunk = 0;
@@ -8640,7 +8633,6 @@ again_one_more_time:
chk->window_probe = 0;
data_list[bundle_at++] = chk;
if (bundle_at >= SCTP_MAX_DATA_BUNDLING) {
- mtu = 0;
break;
}
if (chk->sent == SCTP_DATAGRAM_UNSENT) {
@@ -8757,7 +8749,7 @@ no_data_fill:
} else {
asoc->ifp_had_enobuf = 0;
}
- outchain = endoutchain = NULL;
+ endoutchain = NULL;
auth = NULL;
auth_offset = 0;
if (bundle_at || hbflag) {
@@ -9221,7 +9213,7 @@ sctp_send_asconf_ack(struct sctp_tcb *st
*/
struct sctp_tmit_chunk *chk;
struct sctp_asconf_ack *ack, *latest_ack;
- struct mbuf *m_ack, *m;
+ struct mbuf *m_ack;
struct sctp_nets *net = NULL;
SCTP_TCB_LOCK_ASSERT(stcb);
@@ -9300,7 +9292,6 @@ sctp_send_asconf_ack(struct sctp_tcb *st
chk->data = m_ack;
chk->send_size = 0;
/* Get size */
- m = m_ack;
chk->send_size = ack->len;
chk->rec.chunk_id.id = SCTP_ASCONF_ACK;
chk->rec.chunk_id.can_take_data = 1;
@@ -9393,7 +9384,6 @@ sctp_chunk_retransmission(struct sctp_in
ctl_cnt++;
if (chk->rec.chunk_id.id == SCTP_FORWARD_CUM_TSN) {
fwd_tsn = 1;
- fwd = chk;
}
/*
* Add an AUTH chunk, if chunk requires it save the
@@ -9431,7 +9421,7 @@ sctp_chunk_retransmission(struct sctp_in
SCTP_STAT_INCR(sctps_lowlevelerr);
return (error);
}
- m = endofchain = NULL;
+ endofchain = NULL;
auth = NULL;
auth_offset = 0;
/*
@@ -9601,16 +9591,13 @@ one_chunk_around:
* now are there anymore forward from chk to pick
* up?
*/
- fwd = TAILQ_NEXT(chk, sctp_next);
- while (fwd) {
+ for (fwd = TAILQ_NEXT(chk, sctp_next); fwd != NULL; fwd = TAILQ_NEXT(fwd, sctp_next)) {
if (fwd->sent != SCTP_DATAGRAM_RESEND) {
/* Nope, not for retran */
- fwd = TAILQ_NEXT(fwd, sctp_next);
continue;
}
if (fwd->whoTo != net) {
/* Nope, not the net in question */
- fwd = TAILQ_NEXT(fwd, sctp_next);
continue;
}
if (data_auth_reqd && (auth == NULL)) {
@@ -9658,7 +9645,6 @@ one_chunk_around:
if (bundle_at >= SCTP_MAX_DATA_BUNDLING) {
break;
}
- fwd = TAILQ_NEXT(fwd, sctp_next);
} else {
/* can't fit so we are done */
break;
@@ -9690,7 +9676,7 @@ one_chunk_around:
SCTP_STAT_INCR(sctps_lowlevelerr);
return (error);
}
- m = endofchain = NULL;
+ endofchain = NULL;
auth = NULL;
auth_offset = 0;
/* For HB's */
@@ -10252,12 +10238,14 @@ sctp_fill_in_rest:
* we report.
*/
at = TAILQ_FIRST(&asoc->sent_queue);
- for (i = 0; i < cnt_of_skipped; i++) {
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-stable-9
mailing list