From nobody Fri Sep 15 17:40:44 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RnM0r2Cfmz4tQly; Fri, 15 Sep 2023 17:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RnM0r23n0z3J01; Fri, 15 Sep 2023 17:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694799644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sQ6yAP2WHQaEmEUN7NXV7z8B6eCWQFL1lnPSo7i6V1k=; b=hHsAHitJSAA9TpKcZ/z5Iysr88ia7xlUvwYaucPBScYJtLigzKaHYL4uh4FWHACSxPp/Ft toWTGZqKfUjfashizz1O+9/Xi5DhKons97ZySm6Qxq6V1TGtrDkrckDpWEAwID/3CYbRFZ dae5UqonoYls3Rb71khBGX8zKTMWni07WZH+ePeNuAnDm0dg0HhK8XqpNFLR+l/8SaWbHN b9W6/i6GNoYTpYqYbVYB9seA7DBj6hdlhbbM5ez3HMBak0TlbU213p0nARWwOSZylFshP1 lUWzGXcbunrZets5olL2MpUXQb6sFkpy8Isd/2YzTaSLIrjG09U1OI5l65B0qA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694799644; a=rsa-sha256; cv=none; b=kulYfT09j7/byBnxANnZfczV7pou8ephyxHuDY5LajyXPMcz5EQqgG1cFzilo+GcjeGiew i8nIHP8l5QxvxUb6NKvX/cOPnwDToUrI90t6vY8M6wP1B5Gdi64WECoLIN12JsgYQNytuM Bpf4WHETq2LgUkD97z5BAgBr3gZuUi6xLhqeWQ5iwsL0cDo4OcHWHozT/Gx66I2qyweDPC uyUPARu/norKVe9WhMyweXBKHFPLWZwEBuwyGTcfFepwEj79Uk9eGwcP9V12B4qF0zyuMA 8c58FvA+faHayVD4g61EjJkCdEjFVtU29iOZStlyY+XkUuM9DlfYHFf+6fx10A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694799644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sQ6yAP2WHQaEmEUN7NXV7z8B6eCWQFL1lnPSo7i6V1k=; b=EIJx2jdzhXDD8jrGWVuNCClQ4K1yDoJMi7znHQf6DCKTm7H7zS+h8IdEneq/lt0RRmyGpf mKSaUKvixvTLYvhK+I4q+uMpnCBGSMS9dfo7Vtz/v1Fw4qMsc2Y/fluEQxyvi1ICoMRFTp y1zcgq0mnjw3pYgUarcKvkBK2duKgV32tRSmwNm0PwFgDNG7N40DAd5AkyxHrSXKbpHKNR jZE8n92Tb+kqQ0mwVwftqeYNXnSRWr3GY38abB8oj0/NJc8TAyImb9a+ls8V0zpWj1WDkU bqS3eRpjZr50X5IAJMYc9zxlD/uXAmztE7g1po8FVn7LHiZsZiHBJj6Ah5D3lQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RnM0r15SLzYTx; Fri, 15 Sep 2023 17:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38FHeidR048734; Fri, 15 Sep 2023 17:40:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38FHeiTO048731; Fri, 15 Sep 2023 17:40:44 GMT (envelope-from git) Date: Fri, 15 Sep 2023 17:40:44 GMT Message-Id: <202309151740.38FHeiTO048731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 8d7d28e8c807 - stable/14 - sctp: make sure all SCTP RESET notifications use sctp_ulp_notify() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8d7d28e8c8072b9fd8be8e79d854dca175cce4a9 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8d7d28e8c8072b9fd8be8e79d854dca175cce4a9 commit 8d7d28e8c8072b9fd8be8e79d854dca175cce4a9 Author: Michael Tuexen AuthorDate: 2023-09-08 12:19:56 +0000 Commit: Michael Tuexen CommitDate: 2023-09-15 17:38:29 +0000 sctp: make sure all SCTP RESET notifications use sctp_ulp_notify() While there, improve consistency of the notification related code. No functional change intended. --- sys/netinet/sctp_constants.h | 14 +++-- sys/netinet/sctp_input.c | 26 ++++----- sys/netinet/sctputil.c | 135 ++++++++++++++++++++++--------------------- sys/netinet/sctputil.h | 6 -- 4 files changed, 86 insertions(+), 95 deletions(-) diff --git a/sys/netinet/sctp_constants.h b/sys/netinet/sctp_constants.h index 881db9dd87cc..2054849fd5e9 100644 --- a/sys/netinet/sctp_constants.h +++ b/sys/netinet/sctp_constants.h @@ -706,12 +706,14 @@ #define SCTP_NOTIFY_STR_RESET_FAILED_IN 20 #define SCTP_NOTIFY_STR_RESET_DENIED_OUT 21 #define SCTP_NOTIFY_STR_RESET_DENIED_IN 22 -#define SCTP_NOTIFY_AUTH_NEW_KEY 23 -#define SCTP_NOTIFY_AUTH_FREE_KEY 24 -#define SCTP_NOTIFY_NO_PEER_AUTH 25 -#define SCTP_NOTIFY_SENDER_DRY 26 -#define SCTP_NOTIFY_REMOTE_ERROR 27 -#define SCTP_NOTIFY_ASSOC_TIMEDOUT 28 +#define SCTP_NOTIFY_STR_RESET_ADD 23 +#define SCTP_NOTIFY_STR_RESET_TSN 24 +#define SCTP_NOTIFY_AUTH_NEW_KEY 25 +#define SCTP_NOTIFY_AUTH_FREE_KEY 26 +#define SCTP_NOTIFY_NO_PEER_AUTH 27 +#define SCTP_NOTIFY_SENDER_DRY 28 +#define SCTP_NOTIFY_REMOTE_ERROR 29 +#define SCTP_NOTIFY_ASSOC_TIMEDOUT 30 /* This is the value for messages that are NOT completely * copied down where we will start to split the message. diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index e6dc41e08909..6937f8a2a43f 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -3510,23 +3510,19 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, asoc->strmout[i].state = SCTP_STREAM_OPEN; } asoc->streamoutcnt += num_stream; - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGE_DENIED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, SCTP_STREAM_CHANGE_DENIED, NULL, SCTP_SO_NOT_LOCKED); } else { - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGE_FAILED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, SCTP_STREAM_CHANGE_FAILED, NULL, SCTP_SO_NOT_LOCKED); } } else if (type == SCTP_STR_RESET_ADD_IN_STREAMS) { if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action == SCTP_STREAM_RESET_RESULT_DENIED) { - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGE_DENIED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, SCTP_STREAM_CHANGE_DENIED, NULL, SCTP_SO_NOT_LOCKED); } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, - SCTP_STREAM_CHANGE_FAILED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, SCTP_STREAM_CHANGE_DENIED, NULL, SCTP_SO_NOT_LOCKED); } } else if (type == SCTP_STR_RESET_TSN_REQUEST) { /** @@ -3572,13 +3568,11 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, sctp_reset_out_streams(stcb, 0, (uint16_t *)NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *)NULL); - sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), 0); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_TSN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { - sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), - SCTP_ASSOC_RESET_DENIED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_TSN, stcb, SCTP_ASSOC_RESET_DENIED, NULL, SCTP_SO_NOT_LOCKED); } else { - sctp_notify_stream_reset_tsn(stcb, stcb->asoc.sending_seq, (stcb->asoc.mapping_array_base_tsn + 1), - SCTP_ASSOC_RESET_FAILED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_TSN, stcb, SCTP_ASSOC_RESET_FAILED, NULL, SCTP_SO_NOT_LOCKED); } } /* get rid of the request and get the request flags */ @@ -3707,7 +3701,7 @@ sctp_handle_str_reset_request_tsn(struct sctp_tcb *stcb, sctp_reset_out_streams(stcb, 0, (uint16_t *)NULL); sctp_reset_in_stream(stcb, 0, (uint16_t *)NULL); asoc->last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; - sctp_notify_stream_reset_tsn(stcb, asoc->sending_seq, (asoc->mapping_array_base_tsn + 1), 0); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_TSN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } sctp_add_stream_reset_result_tsn(chk, seq, asoc->last_reset_action[0], asoc->last_sending_seq[0], asoc->last_base_tsnsent[0]); @@ -3872,7 +3866,7 @@ sctp_handle_str_reset_add_strm(struct sctp_tcb *stcb, struct sctp_tmit_chunk *ch /* update the size */ stcb->asoc.streamincnt = num_stream; stcb->asoc.last_reset_action[0] = SCTP_STREAM_RESET_RESULT_PERFORMED; - sctp_notify_stream_reset_add(stcb, stcb->asoc.streamincnt, stcb->asoc.streamoutcnt, 0); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_ADD, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } sctp_add_stream_reset_result(chk, seq, asoc->last_reset_action[0]); asoc->str_reset_seq_in++; diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index ea960a3e6376..17a5a098dd90 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -3140,9 +3140,10 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, struct mbuf *m_notify; struct sctp_assoc_change *sac; struct sctp_queued_to_read *control; + struct sctp_inpcb *inp; unsigned int notif_len; - uint16_t abort_len; unsigned int i; + uint16_t abort_len; KASSERT(abort == NULL || from_peer, ("sctp_notify_assoc_change: ABORT chunk provided for local termination")); @@ -3151,7 +3152,8 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, if (stcb == NULL) { return; } - if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVASSOCEVNT)) { + inp = stcb->sctp_ep; + if (sctp_stcb_is_feature_on(inp, stcb, SCTP_PCB_FLAGS_RECVASSOCEVNT)) { notif_len = (unsigned int)sizeof(struct sctp_assoc_change); if (abort != NULL) { abort_len = ntohs(abort->ch.chunk_length); @@ -3229,10 +3231,9 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, - so_locked); + sctp_add_to_readq(inp, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } else { sctp_m_freem(m_notify); } @@ -3242,8 +3243,8 @@ sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb, * comes in. */ set_error: - if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || - (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && + if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && ((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) { SOCK_LOCK(stcb->sctp_socket); if (from_peer) { @@ -3266,8 +3267,8 @@ set_error: SOCK_UNLOCK(stcb->sctp_socket); } /* Wake ANY sleepers */ - if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || - (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && + if (((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) && ((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) { socantrcvmore(stcb->sctp_socket); } @@ -3356,11 +3357,9 @@ sctp_notify_peer_addr_change(struct sctp_tcb *stcb, uint32_t state, control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, + sctp_add_to_readq(stcb->sctp_ep, stcb, control, &stcb->sctp_socket->so_rcv, 1, - SCTP_READ_LOCK_NOT_HELD, - so_locked); + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void @@ -3487,11 +3486,9 @@ sctp_notify_send_failed(struct sctp_tcb *stcb, uint8_t sent, uint32_t error, control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, + sctp_add_to_readq(stcb->sctp_ep, stcb, control, &stcb->sctp_socket->so_rcv, 1, - SCTP_READ_LOCK_NOT_HELD, - so_locked); + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void @@ -3585,13 +3582,13 @@ sctp_notify_send_failed2(struct sctp_tcb *stcb, uint32_t error, control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void -sctp_notify_adaptation_layer(struct sctp_tcb *stcb) +sctp_notify_adaptation_layer(struct sctp_tcb *stcb, int so_locked) { struct mbuf *m_notify; struct sctp_adaptation_event *sai; @@ -3632,9 +3629,9 @@ sctp_notify_adaptation_layer(struct sctp_tcb *stcb) control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void @@ -3702,7 +3699,7 @@ sctp_notify_partial_delivery_indication(struct sctp_tcb *stcb, uint32_t error, } static void -sctp_notify_shutdown_event(struct sctp_tcb *stcb) +sctp_notify_shutdown_event(struct sctp_tcb *stcb, int so_locked) { struct mbuf *m_notify; struct sctp_shutdown_event *sse; @@ -3749,14 +3746,13 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb) control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void -sctp_notify_sender_dry_event(struct sctp_tcb *stcb, - int so_locked) +sctp_notify_sender_dry_event(struct sctp_tcb *stcb, int so_locked) { struct mbuf *m_notify; struct sctp_sender_dry_event *event; @@ -3798,11 +3794,12 @@ sctp_notify_sender_dry_event(struct sctp_tcb *stcb, /* not that we need this */ control->tail_mbuf = m_notify; sctp_add_to_readq(stcb->sctp_ep, stcb, control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } -void -sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, uint16_t numberout, int flag) +static void +sctp_notify_stream_reset_add(struct sctp_tcb *stcb, int flag, int so_locked) { struct mbuf *m_notify; struct sctp_queued_to_read *control; @@ -3837,8 +3834,8 @@ sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, uint16_t stradd->strchange_flags = flag; stradd->strchange_length = sizeof(struct sctp_stream_change_event); stradd->strchange_assoc_id = sctp_get_associd(stcb); - stradd->strchange_instrms = numberin; - stradd->strchange_outstrms = numberout; + stradd->strchange_instrms = stcb->asoc.streamincnt; + stradd->strchange_outstrms = stcb->asoc.streamoutcnt; SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_stream_change_event); SCTP_BUF_NEXT(m_notify) = NULL; if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { @@ -3859,13 +3856,13 @@ sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, uint16_t control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } -void -sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag) +static void +sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, int flag, int so_locked) { struct mbuf *m_notify; struct sctp_queued_to_read *control; @@ -3894,8 +3891,8 @@ sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32 strasoc->assocreset_flags = flag; strasoc->assocreset_length = sizeof(struct sctp_assoc_reset_event); strasoc->assocreset_assoc_id = sctp_get_associd(stcb); - strasoc->assocreset_local_tsn = sending_tsn; - strasoc->assocreset_remote_tsn = recv_tsn; + strasoc->assocreset_local_tsn = stcb->asoc.sending_seq; + strasoc->assocreset_remote_tsn = stcb->asoc.mapping_array_base_tsn + 1; SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_assoc_reset_event); SCTP_BUF_NEXT(m_notify) = NULL; if (sctp_sbspace(&stcb->asoc, &stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) { @@ -3916,14 +3913,14 @@ sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32 control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, so_locked); } static void sctp_notify_stream_reset(struct sctp_tcb *stcb, - int number_entries, uint16_t *list, int flag) + int number_entries, uint16_t *list, int flag, int so_locked) { struct mbuf *m_notify; struct sctp_queued_to_read *control; @@ -3980,13 +3977,14 @@ sctp_notify_stream_reset(struct sctp_tcb *stcb, control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, - &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + sctp_add_to_readq(stcb->sctp_ep, stcb, control, + &stcb->sctp_socket->so_rcv, 1, + SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); } static void -sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, struct sctp_error_chunk *chunk) +sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, + struct sctp_error_chunk *chunk, int so_locked) { struct mbuf *m_notify; struct sctp_remote_error *sre; @@ -4041,10 +4039,9 @@ sctp_notify_remote_error(struct sctp_tcb *stcb, uint16_t error, struct sctp_erro control->spec_flags = M_NOTIFICATION; /* not that we need this */ control->tail_mbuf = m_notify; - sctp_add_to_readq(stcb->sctp_ep, stcb, - control, + sctp_add_to_readq(stcb->sctp_ep, stcb, control, &stcb->sctp_socket->so_rcv, 1, - SCTP_READ_LOCK_NOT_HELD, SCTP_SO_NOT_LOCKED); + SCTP_READ_LOCK_NOT_HELD, so_locked); } else { sctp_m_freem(m_notify); } @@ -4086,11 +4083,10 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, stcb->asoc.assoc_up_sent = 1; } if (stcb->asoc.adaptation_needed && (stcb->asoc.adaptation_sent == 0)) { - sctp_notify_adaptation_layer(stcb); + sctp_notify_adaptation_layer(stcb, so_locked); } if (stcb->asoc.auth_supported == 0) { - sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0, - NULL, so_locked); + sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0, NULL, so_locked); } break; case SCTP_NOTIFY_ASSOC_DOWN: @@ -4155,31 +4151,36 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, case SCTP_NOTIFY_ASSOC_RESTART: sctp_notify_assoc_change(SCTP_RESTART, stcb, error, NULL, false, false, so_locked); if (stcb->asoc.auth_supported == 0) { - sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0, - NULL, so_locked); + sctp_ulp_notify(SCTP_NOTIFY_NO_PEER_AUTH, stcb, 0, NULL, so_locked); } break; case SCTP_NOTIFY_STR_RESET_SEND: - sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_OUTGOING_SSN); + sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_OUTGOING_SSN, so_locked); break; case SCTP_NOTIFY_STR_RESET_RECV: - sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_INCOMING); + sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), SCTP_STREAM_RESET_INCOMING, so_locked); break; case SCTP_NOTIFY_STR_RESET_FAILED_OUT: sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), - (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED)); + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_FAILED), so_locked); break; case SCTP_NOTIFY_STR_RESET_DENIED_OUT: sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), - (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_DENIED)); + (SCTP_STREAM_RESET_OUTGOING_SSN | SCTP_STREAM_RESET_DENIED), so_locked); break; case SCTP_NOTIFY_STR_RESET_FAILED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), - (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED)); + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_FAILED), so_locked); break; case SCTP_NOTIFY_STR_RESET_DENIED_IN: sctp_notify_stream_reset(stcb, error, ((uint16_t *)data), - (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_DENIED)); + (SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_DENIED), so_locked); + break; + case SCTP_NOTIFY_STR_RESET_ADD: + sctp_notify_stream_reset_add(stcb, error, so_locked); + break; + case SCTP_NOTIFY_STR_RESET_TSN: + sctp_notify_stream_reset_tsn(stcb, error, so_locked); break; case SCTP_NOTIFY_ASCONF_ADD_IP: sctp_notify_peer_addr_change(stcb, SCTP_ADDR_ADDED, data, @@ -4194,7 +4195,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, error, so_locked); break; case SCTP_NOTIFY_PEER_SHUTDOWN: - sctp_notify_shutdown_event(stcb); + sctp_notify_shutdown_event(stcb, so_locked); break; case SCTP_NOTIFY_AUTH_NEW_KEY: sctp_notify_authentication(stcb, SCTP_AUTH_NEW_KEY, @@ -4212,7 +4213,7 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb, sctp_notify_sender_dry_event(stcb, so_locked); break; case SCTP_NOTIFY_REMOTE_ERROR: - sctp_notify_remote_error(stcb, error, data); + sctp_notify_remote_error(stcb, error, data, so_locked); break; default: SCTPDBG(SCTP_DEBUG_UTIL1, "%s: unknown notification %xh (%u)\n", diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h index c649611d5004..8de98b4608f8 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -80,12 +80,6 @@ int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, u void sctp_fill_random_store(struct sctp_pcb *); -void -sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin, - uint16_t numberout, int flag); -void - sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag); - /* * NOTE: sctp_timer_start() will increment the reference count of any relevant * structure the timer is referencing, in order to prevent a race condition