sctp: improve consistency, no functional change intended

This commit is contained in:
Michael Tuexen 2021-11-26 12:53:12 +01:00
parent 054f5815c5
commit 3c1ba6f394
4 changed files with 18 additions and 18 deletions

View File

@ -1806,7 +1806,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
SCTP_INP_INFO_WLOCK();
SCTP_INP_WLOCK(stcb->sctp_ep);
SCTP_TCB_LOCK(stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
/* send up all the data */
SCTP_TCB_SEND_LOCK(stcb);

View File

@ -5832,7 +5832,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
itsn = sctp_select_initial_TSN(&inp->sctp_ep);
initack->init.initial_tsn = htonl(itsn);
SCTP_TCB_LOCK(stcb);
atomic_add_int(&asoc->refcnt, -1);
atomic_subtract_int(&asoc->refcnt, 1);
} else {
SCTP_INP_INCR_REF(inp);
SCTP_INP_RUNLOCK(inp);
@ -6648,7 +6648,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
* relock.. to unlock in the iterator timer :-0
*/
SCTP_TCB_LOCK(stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
goto no_chunk_output;
} else {
if (m) {
@ -6720,7 +6720,7 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
atomic_add_int(&stcb->asoc.refcnt, 1);
sctp_abort_an_association(stcb->sctp_ep, stcb,
op_err, false, SCTP_SO_NOT_LOCKED);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
goto no_chunk_output;
}
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
@ -12980,7 +12980,7 @@ sctp_lower_sosend(struct socket *so,
if (hold_tcblock == 0) {
SCTP_TCB_LOCK(stcb);
}
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
free_cnt_applied = 0;
/* release this lock, otherwise we hang on ourselves */
NET_EPOCH_ENTER(et);
@ -13552,7 +13552,7 @@ sctp_lower_sosend(struct socket *so,
abort_anyway:
if (free_cnt_applied) {
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
free_cnt_applied = 0;
}
SCTP_SNPRINTF(msg, sizeof(msg),
@ -13693,7 +13693,7 @@ sctp_lower_sosend(struct socket *so,
SCTP_TCB_UNLOCK(stcb);
}
if (stcb && free_cnt_applied) {
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
}
#ifdef INVARIANTS
if (stcb) {

View File

@ -4872,7 +4872,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
*/
/* re-increment the lock */
if (from_inpcbfree == SCTP_NORMAL_PROC) {
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
}
if (stcb->asoc.refcnt) {
SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE);
@ -6060,7 +6060,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
inp = stcb->sctp_ep;
atomic_add_int(&stcb->asoc.refcnt, 1);
stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, dst, stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
/* we must add the source address */
@ -6144,7 +6144,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
atomic_add_int(&stcb->asoc.refcnt, 1);
stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
dst, stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
inp == NULL) {
@ -6243,7 +6243,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
atomic_add_int(&stcb->asoc.refcnt, 1);
stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
dst, stcb);
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
if (stcb_tmp == NULL &&
(inp == stcb->sctp_ep || inp == NULL)) {
/*

View File

@ -1541,7 +1541,7 @@ sctp_iterator_work(struct sctp_iterator *it)
if (sctp_it_ctl.iterator_flags) {
/* We won't be staying here */
SCTP_INP_DECR_REF(it->inp);
atomic_add_int(&it->stcb->asoc.refcnt, -1);
atomic_subtract_int(&it->stcb->asoc.refcnt, 1);
if (sctp_it_ctl.iterator_flags &
SCTP_ITERATOR_STOP_CUR_IT) {
sctp_it_ctl.iterator_flags &= ~SCTP_ITERATOR_STOP_CUR_IT;
@ -1560,7 +1560,7 @@ sctp_iterator_work(struct sctp_iterator *it)
SCTP_INP_RLOCK(it->inp);
SCTP_INP_DECR_REF(it->inp);
SCTP_TCB_LOCK(it->stcb);
atomic_add_int(&it->stcb->asoc.refcnt, -1);
atomic_subtract_int(&it->stcb->asoc.refcnt, 1);
iteration_count = 0;
}
KASSERT(it->inp == it->stcb->sctp_ep,
@ -1780,7 +1780,7 @@ sctp_timeout_handler(void *t)
* necessary below. This is safe now that we have acquired
* the lock.
*/
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
released_asoc_reference = true;
if ((type != SCTP_TIMER_TYPE_ASOCKILL) &&
((stcb->asoc.state == SCTP_STATE_EMPTY) ||
@ -2116,7 +2116,7 @@ sctp_timeout_handler(void *t)
SCTP_INP_DECR_REF(inp);
}
if ((stcb != NULL) && !released_asoc_reference) {
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
}
if (net != NULL) {
sctp_free_remote_addr(net);
@ -2873,7 +2873,7 @@ sctp_timer_stop(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
tmr->ep = NULL;
}
if (tmr->tcb != NULL) {
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
tmr->tcb = NULL;
}
if (tmr->net != NULL) {
@ -5501,7 +5501,7 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock,
SCTP_INP_DECR_REF(stcb->sctp_ep);
no_lock:
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
return;
}
@ -6446,7 +6446,7 @@ sctp_sorecvmsg(struct socket *so,
}
/* Save the value back for next time */
stcb->freed_by_sorcv_sincelast = freed_so_far;
atomic_add_int(&stcb->asoc.refcnt, -1);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
}
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) {
if (stcb) {