From nobody Wed Apr 17 13:47:41 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 4VKMfj2xtCz5Gwdt; Wed, 17 Apr 2024 13:47:41 +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 4VKMfj2BPkz4n4F; Wed, 17 Apr 2024 13:47:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713361661; 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=iaqmVMmDEm/SRsSxD0pps4wovWbpNYVaXYcIJJVyxdE=; b=pUEdn1tr+bDYqKY9Khhf4BNWaUO2O5xkl5xUOO37Gk6W8l3H63z9TmvsYF3fs3uF2sgqpG yu/E2p2JGz/bpVDxEQvnZJ2hk9tSKt0ic7AUO2Wno8Q2CAmKdJGjx5Swo014lY0lM8id5+ 2aL3ObcWR1hx/TXJswAO83hr8nRYwK4h4amdbNgZCmcu6ctRDnVc8TaEgJWCeVKCeRIYJJ E2RfXCrIbEB6bumLtqKuyuQOz3403vl4/reHUsmfIRbPZgX1wHk8/Hv2xmKD4RGzH9JZei Q3Ws8i1RQ7NmAS+5dTDWsNsnFmkzVuXEC5VhlfLmaNSM4X4pzSYtz7aYOsVoLg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713361661; a=rsa-sha256; cv=none; b=Y0fD/ZxnJl1XExzG1TDW3H00dYI3q1mO2yw1IhOLYwPDpHdQCUXWa5PcG5qHfdu2aYin2T TtMgyXRj4NTutYYAFZ7aPm75vWksShF6q8l606WUNZAzWeFsBKgaoyYoqbqg6JbhXMa+rw oE8ViSEOO+z0Rhup0MIYhlISBxgQOXo9EBPVJ7+hEOYP/xSX70to1oD6vwAlv2tMTGJ8/6 oP+6V118cRdo5eLccEAMsyzX4ga/1ZgXAsnDllGRSbYEjp2Nw/YuHQATGOsDRp5LxVWcs5 iSe3g4kxjfC9HHO2lccYILn7ejv21HwnqGfyN0UQYMOamvpkYP9NBsGSCoHx0Q== 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=1713361661; 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=iaqmVMmDEm/SRsSxD0pps4wovWbpNYVaXYcIJJVyxdE=; b=AwhZvlXfbIaqvwgZ53fw+8AWJkgu/BSViJmT4so7kArded1yFZdi82Lwcureb7YYusPPpo h+Mcv+UrkfBMtP3TtH0PI1ci8cnO16mfRwjvyfMR+hmhEu39ufk6FzXAuwdVSaYlpjX4jo HGPZeaWaAi6C14efSGXz7Mx/sgbx8lpsq+XGMkWX5DJXNqlqLt7Iw2UrVa1TtjZVhVqNwC eJXjAJ8uYZDTO5DwCAzhbr0Vg6wz7Ec/rglN+Vff2mx9++PxMpsK5NUYpB79mb9XHktjr0 yFRPfcQfWlVv3nDHyfcOxqJZ63mjaS6kDtoMjuMq045SbiGQyhBAiGRwpxfwZw== 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 4VKMfj1nkmzSyB; Wed, 17 Apr 2024 13:47:41 +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 43HDlfZO020344; Wed, 17 Apr 2024 13:47:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43HDlfmq020341; Wed, 17 Apr 2024 13:47:41 GMT (envelope-from git) Date: Wed, 17 Apr 2024 13:47:41 GMT Message-Id: <202404171347.43HDlfmq020341@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: be7586fe468f - stable/14 - sctp: improve sending of packets containing an INIT ACK chunk 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: be7586fe468f5c3afbe8fc413e160bb9626d0497 Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=be7586fe468f5c3afbe8fc413e160bb9626d0497 commit be7586fe468f5c3afbe8fc413e160bb9626d0497 Author: Michael Tuexen AuthorDate: 2024-02-24 18:16:36 +0000 Commit: Michael Tuexen CommitDate: 2024-04-17 13:47:17 +0000 sctp: improve sending of packets containing an INIT ACK chunk If the peer announced support of zero checksums, do so when sending packets containing an INIT ACK chunk. (cherry picked from commit 644cffe67f61ad5b36b60d621d1c630ff2a50412) --- sys/netinet/sctp_input.c | 2 +- sys/netinet/sctp_output.c | 36 ++++++++++++++++++++++++++++++++---- sys/netinet/sctp_output.h | 4 +++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 6937f8a2a43f..a55ef5ac1eab 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -406,7 +406,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset, op_err = sctp_arethere_unrecognized_parameters(m, (offset + sizeof(struct sctp_init_chunk)), &abort_flag, (struct sctp_chunkhdr *)cp, - &nat_friendly, &cookie_found); + &nat_friendly, &cookie_found, NULL); if (abort_flag) { /* Send an abort and notify peer */ sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index c988a8426fe8..a8facff6b917 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -4918,7 +4918,8 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, int param_offset, int *abort_processing, struct sctp_chunkhdr *cp, int *nat_friendly, - int *cookie_found) + int *cookie_found, + uint32_t *edmid) { /* * Given a mbuf containing an INIT or INIT-ACK with the param_offset @@ -4934,8 +4935,8 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, * hoped that this routine may be reused in the future by new * features. */ + struct sctp_zero_checksum_acceptable zero_chksum, *zero_chksum_p; struct sctp_paramhdr *phdr, params; - struct mbuf *mat, *m_tmp, *op_err, *op_err_last; int at, limit, pad_needed; uint16_t ptype, plen, padded_size; @@ -4944,6 +4945,9 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, if (cookie_found != NULL) { *cookie_found = 0; } + if (edmid != NULL) { + *edmid = SCTP_EDMID_NONE; + } mat = in_initpkt; limit = ntohs(cp->chunk_length) - sizeof(struct sctp_init_chunk); at = param_offset; @@ -4999,6 +5003,22 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt, } at += padded_size; break; + case SCTP_ZERO_CHECKSUM_ACCEPTABLE: + if (padded_size != sizeof(struct sctp_zero_checksum_acceptable)) { + SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error checksum acceptable %d\n", plen); + goto invalid_size; + } + if (edmid != NULL) { + phdr = sctp_get_next_param(mat, at, + (struct sctp_paramhdr *)&zero_chksum, + sizeof(struct sctp_zero_checksum_acceptable)); + if (phdr != NULL) { + zero_chksum_p = (struct sctp_zero_checksum_acceptable *)phdr; + *edmid = ntohl(zero_chksum_p->edmid); + } + } + at += padded_size; + break; case SCTP_RANDOM: if (padded_size > (sizeof(struct sctp_auth_random) + SCTP_RANDOM_MAX_SIZE)) { SCTPDBG(SCTP_DEBUG_OUTPUT1, "Invalid size - error random %d\n", plen); @@ -5513,7 +5533,9 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int nat_friendly = 0; int error; struct socket *so; + uint32_t edmid; uint16_t num_ext, chunk_len, padding_len, parameter_len; + bool use_zero_crc; if (stcb) { asoc = &stcb->asoc; @@ -5554,7 +5576,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb, (offset + sizeof(struct sctp_init_chunk)), &abort_flag, (struct sctp_chunkhdr *)init_chk, - &nat_friendly, NULL); + &nat_friendly, NULL, &edmid); if (abort_flag) { do_a_abort: if (op_err == NULL) { @@ -6155,12 +6177,18 @@ do_a_abort: over_addr = NULL; } + if (asoc != NULL) { + use_zero_crc = (asoc->rcv_edmid != SCTP_EDMID_NONE) && (asoc->rcv_edmid == edmid); + } else { + use_zero_crc = (inp->rcv_edmid != SCTP_EDMID_NONE) && (inp->rcv_edmid == edmid); + } + if ((error = sctp_lowlevel_chunk_output(inp, NULL, NULL, to, m, 0, NULL, 0, 0, 0, 0, inp->sctp_lport, sh->src_port, init_chk->init.initiate_tag, port, over_addr, mflowtype, mflowid, - false, /* XXXMT: Improve this! */ + use_zero_crc, SCTP_SO_NOT_LOCKED))) { SCTPDBG(SCTP_DEBUG_OUTPUT4, "Gak send error %d\n", error); if (error == ENOBUFS) { diff --git a/sys/netinet/sctp_output.h b/sys/netinet/sctp_output.h index 1a1d17221b02..88c12367346a 100644 --- a/sys/netinet/sctp_output.h +++ b/sys/netinet/sctp_output.h @@ -80,7 +80,9 @@ sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf * sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *, - struct sctp_chunkhdr *, int *, int *); + struct sctp_chunkhdr *, int *, int *, + uint32_t *); + void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *); int