sctp: provide sac_error also for ABORT chunk being sent

Thanks to Florent Castelli for bringing this issue up for the
userland stack and providing an initial patch.

MFC:		3 days
This commit is contained in:
Michael Tuexen 2021-07-09 13:46:27 +02:00
parent 3fc12ae042
commit 84992a3251

View File

@ -4367,19 +4367,29 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
uint8_t mflowtype, uint32_t mflowid,
uint32_t vrf_id, uint16_t port)
{
struct sctp_gen_error_cause *cause;
uint32_t vtag;
uint16_t cause_code;
vtag = 0;
if (stcb != NULL) {
vtag = stcb->asoc.peer_vtag;
vrf_id = stcb->asoc.vrf_id;
if (op_err != NULL) {
/* Read the cause code from the error cause. */
cause = mtod(op_err, struct sctp_gen_error_cause *);
cause_code = ntohs(cause->code);
} else {
cause_code = 0;
}
} else {
vtag = 0;
}
sctp_send_abort(m, iphlen, src, dst, sh, vtag, op_err,
mflowtype, mflowid, inp->fibnum,
vrf_id, port);
if (stcb != NULL) {
/* We have a TCB to abort, send notification too */
sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED);
sctp_abort_notification(stcb, 0, cause_code, NULL, SCTP_SO_NOT_LOCKED);
/* Ok, now lets free it */
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
@ -4458,6 +4468,8 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
struct mbuf *op_err,
int so_locked)
{
struct sctp_gen_error_cause *cause;
uint16_t cause_code;
if (stcb == NULL) {
/* Got to have a TCB */
@ -4469,6 +4481,13 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
return;
}
if (op_err != NULL) {
/* Read the cause code from the error cause. */
cause = mtod(op_err, struct sctp_gen_error_cause *);
cause_code = ntohs(cause->code);
} else {
cause_code = 0;
}
/* notify the peer */
sctp_send_abort_tcb(stcb, op_err, so_locked);
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
@ -4478,7 +4497,7 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
/* notify the ulp */
if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) {
sctp_abort_notification(stcb, 0, 0, NULL, so_locked);
sctp_abort_notification(stcb, 0, cause_code, NULL, so_locked);
}
/* now free the asoc */
#ifdef SCTP_ASOCLOG_OF_TSNS