From nobody Thu Jan 11 12:56:23 2024 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 4T9l6H4H75z55gHY; Thu, 11 Jan 2024 12:56:23 +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 4T9l6H2tzyz4CtF; Thu, 11 Jan 2024 12:56:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704977783; 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=8ndre7O1YVCSuieaBl7mwKuegmeVTrwzvQt/PrBzOqM=; b=DABlJXkHqxS+J/doyYX65nSCDNXSL+hb5yH9Pm5RIt981aGqf2tbdbxoJvflUBkrAOLoFw ws3o9HldTj7h62LDz31PBWwOkyQMvm3XOUHcAIHaa+MVX7XpQX1HguVgl4AKdq8oXKui7U C7tzWp/7qQxxLt+V8eu3DataSvE4h6yxBFkR1GvwZNiSeKLAf7Sn53mYubu2Zwx9oZXt/T UZNIErvuBFjDwiyalEZ669lXe73WwR9h+uGid6JOC52LtK0EwgVscUwp5/qtdlODRV2zZW 7dFKuEsMaG5hDT3HmBg6beNjnUr8zAD5UGm0BYiWO6swpN2z2/Y17Y+RBbZg6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704977783; 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=8ndre7O1YVCSuieaBl7mwKuegmeVTrwzvQt/PrBzOqM=; b=KQ/9lDOMxD98PLLhtVuTgPHY0rivnzPAjEwRQXDoBOSg7uIgcInz9ZALeBNE/5+8vQqKp5 3QcKvFJIGIDfWJ0ZahIz2jYF6hGy2/mK/wOS+4/lTzTS5yg2bUpp+126RSkwzzVrLfOwNR XumyIMk3OHZFaPpX9PTxQ9UgwX+ANl6bDnTIkbI2Zvo9GFa7oPXVxHWI8ykJ+GSsDQvvuM anj0/lTLf/Q87TkfCirH5JMpHfo7uAxZm0/ws53SZ6Rqk9LrAkkygI+URBFRxTxVBkXlib kdkj8fZfapq9f40oc2YdIy4l1Ufwwsl6+ZI2Ppr3l+4/IsRbBUPSuy+vY0Xk5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704977783; a=rsa-sha256; cv=none; b=DFjPhC6z2WupPiv7XBLBEZONLc85bPXk/CzRRfIUHqqcAAatMtu/OgMdJQv2a27OIepQId ebcpR+tpLCPZYBMa+Tp1nJxONI3lHKrzuj23E7ZawU12fv/stz+uDT48tNlGc2U7wnz81K 7GISCwkRUh94TbRo8JRviB5wVwBRyONElHAro25AfDjiQmU3UEaYqrfmqtPy9j/duvNgbg cQeWXXTWxXrpG8smgD7aN1GX8lIBmsS6A/hTSaEmjVc8qo3mc5XpS0ZHCjqSJaEh8jxsp0 kdSo7YLRRnY1bTCxso5vc8NWQv8TYrGTnSHbbdZmehjYyr3xSY7AeClL+iEadQ== 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 4T9l6H1ymJzJpD; Thu, 11 Jan 2024 12:56:23 +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 40BCuNSJ054248; Thu, 11 Jan 2024 12:56:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40BCuNXF054245; Thu, 11 Jan 2024 12:56:23 GMT (envelope-from git) Date: Thu, 11 Jan 2024 12:56:23 GMT Message-Id: <202401111256.40BCuNXF054245@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: c813c96d678a - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: c813c96d678a01d19f2124f0db376fdafa8ac6f2 Auto-Submitted: auto-generated The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c813c96d678a01d19f2124f0db376fdafa8ac6f2 commit c813c96d678a01d19f2124f0db376fdafa8ac6f2 Author: Michael Tuexen AuthorDate: 2023-09-08 12:19:56 +0000 Commit: Michael Tuexen CommitDate: 2024-01-11 12:55:56 +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. (cherry picked from commit 3ac7664774ad038b208cbb31eb52d1608efbd451) --- 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 05e804100aa2..d11fe11d5e8f 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 5d2a3dd26384..7ad9eec07897 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -3508,23 +3508,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) { /** @@ -3570,13 +3566,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 */ @@ -3705,7 +3699,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]); @@ -3870,7 +3864,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 f4013a4816c7..b378a55250e0 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -3138,9 +3138,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")); @@ -3149,7 +3150,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); @@ -3227,10 +3229,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); } @@ -3240,8 +3241,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) { @@ -3264,8 +3265,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); } @@ -3354,11 +3355,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 @@ -3485,11 +3484,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 @@ -3583,13 +3580,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; @@ -3630,9 +3627,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 @@ -3700,7 +3697,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; @@ -3747,14 +3744,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; @@ -3796,11 +3792,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; @@ -3835,8 +3832,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)) { @@ -3857,13 +3854,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; @@ -3892,8 +3889,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)) { @@ -3914,14 +3911,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; @@ -3978,13 +3975,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; @@ -4039,10 +4037,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); } @@ -4084,11 +4081,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: @@ -4153,31 +4149,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, @@ -4192,7 +4193,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, @@ -4210,7 +4211,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