From nobody Fri Dec 3 20:36:52 2021 X-Original-To: dev-commits-src-main@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 F10BE18A941B; Fri, 3 Dec 2021 20:36:52 +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 4J5PkX58Bnz4lk7; Fri, 3 Dec 2021 20:36:52 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 822CF177BF; Fri, 3 Dec 2021 20:36:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B3KaqEr038450; Fri, 3 Dec 2021 20:36:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B3KaqSe038449; Fri, 3 Dec 2021 20:36:52 GMT (envelope-from git) Date: Fri, 3 Dec 2021 20:36:52 GMT Message-Id: <202112032036.1B3KaqSe038449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: f32357be53d0 - main - sctp: use the correct traffic class when sending SCTP/IPv6 packets List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: f32357be53d07622603049f9855be2d66ca6dc2b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638563812; 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=prgSO4RZiPKqrP8s3ZBolUfZGZeWHJSbBWNnqvAL8ko=; b=KD7UHw2wXiW1wH70tHOegG74PxK60Yix4co7Rg4sJ7uh1AXt88X/iFOlRcH/N8zPzqU6JI 7kZGAbl/SVQbXc23N3x8asTHVZZ1EpU57A7XegsKykF6fTFoYhCHFtFZbR97UqEppExsIu tnv0mn93pImLUA/thBw+cm3kh8fUG4DtR0AOMk/fE8hb659+3dEtm33kRKFXwvi7Revlwm crFIyAnDdPtbNe3zFrmTm5nh2YaCv646cdsKBVaZYLCN8PLrj3yWvurfsJyyl4xmx+DMn5 GhU/useow39ugQ9PBgNPTL0XeVwl6HB0fZNnU6u56/BqPfz11i1X5QiTpIBTzw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638563812; a=rsa-sha256; cv=none; b=gW/K5qIyK+uwFiRcNwlS3WKoBphM49Kn+bD5ubYRFK+1v3zG3KmrM4k1HVBBefqzD2MQ41 noEZWb7PhmVbtbepOh7nk4TSwfoLrb2H+/idD5DcisyToK8XhO+DTPtAUvAn4TLc13UbyN MNLj6i8kzi59eEjd0MbNxOp+SPUjXpJtKJxg18GhxJOZ9uVIRZyMR6TWPvDpXz0eudv8dR 0WGUZH/NCSWjCc5QQ/6hMFjrq7n182uGuzOue2oKIX+lpHccKfNkRo4RNkbopk/YQbDz9P N39E+x7FK14TX4/x6swH8QiHfAga5w4/dphNwlJfyepXlPCjSv7d2Y0aCel9iA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=f32357be53d07622603049f9855be2d66ca6dc2b commit f32357be53d07622603049f9855be2d66ca6dc2b Author: Michael Tuexen AuthorDate: 2021-12-03 20:28:47 +0000 Commit: Michael Tuexen CommitDate: 2021-12-03 20:36:44 +0000 sctp: use the correct traffic class when sending SCTP/IPv6 packets When sending packets the stcb was used to access the inp and then access the endpoint specific IPv6 level options. This fails when there exists an inp, but no stcb yet. This is the case for sending an INIT-ACK in response to an INIT when no association already exists. Fix this by just providing the inp instead of the stcb. PR: 260120 MFC after: 1 week --- sys/netinet/sctp_os_bsd.h | 42 ++++++++++++++++++++++-------------------- sys/netinet/sctp_output.c | 4 ++-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index 12a666b8eead..39c0a8cb5c2a 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -411,28 +411,30 @@ typedef struct route sctp_route_t; /* * IP output routines */ -#define SCTP_IP_OUTPUT(result, o_pak, ro, stcb, vrf_id) \ -{ \ - int o_flgs = IP_RAWOUTPUT; \ - struct sctp_tcb *local_stcb = stcb; \ - if (local_stcb && \ - local_stcb->sctp_ep && \ - local_stcb->sctp_ep->sctp_socket) \ - o_flgs |= local_stcb->sctp_ep->sctp_socket->so_options & SO_DONTROUTE; \ - m_clrprotoflags(o_pak); \ - result = ip_output(o_pak, NULL, ro, o_flgs, 0, NULL); \ +#define SCTP_IP_OUTPUT(result, o_pak, ro, _inp, vrf_id) \ +{ \ + struct sctp_inpcb *local_inp = _inp; \ + int o_flgs = IP_RAWOUTPUT; \ + \ + m_clrprotoflags(o_pak); \ + if ((local_inp != NULL) && (local_inp->sctp_socket != NULL)) { \ + o_flgs |= local_inp->sctp_socket->so_options & SO_DONTROUTE; \ + } \ + result = ip_output(o_pak, NULL, ro, o_flgs, 0, NULL); \ } -#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, stcb, vrf_id) \ -{ \ - struct sctp_tcb *local_stcb = stcb; \ - m_clrprotoflags(o_pak); \ - if (local_stcb && local_stcb->sctp_ep) \ - result = ip6_output(o_pak, \ - ((struct inpcb *)(local_stcb->sctp_ep))->in6p_outputopts, \ - (ro), 0, 0, ifp, NULL); \ - else \ - result = ip6_output(o_pak, NULL, (ro), 0, 0, ifp, NULL); \ +#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, _inp, vrf_id) \ +{ \ + struct sctp_inpcb *local_inp = _inp; \ + \ + m_clrprotoflags(o_pak); \ + if (local_inp != NULL) { \ + result = ip6_output(o_pak, \ + local_inp->ip_inp.inp.in6p_outputopts, \ + (ro), 0, 0, ifp, NULL); \ + } else { \ + result = ip6_output(o_pak, NULL, (ro), 0, 0, ifp, NULL); \ + } \ } struct mbuf * diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 9b4c9093512a..65767f9f73a9 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -4220,7 +4220,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, #endif /* send it out. table id is taken from stcb */ SCTP_PROBE5(send, NULL, stcb, ip, stcb, sctphdr); - SCTP_IP_OUTPUT(ret, o_pak, ro, stcb, vrf_id); + SCTP_IP_OUTPUT(ret, o_pak, ro, inp, vrf_id); if (port) { UDPSTAT_INC(udps_opackets); } @@ -4544,7 +4544,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, sctp_packet_log(o_pak); #endif SCTP_PROBE5(send, NULL, stcb, ip6h, stcb, sctphdr); - SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, stcb, vrf_id); + SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, inp, vrf_id); if (net) { /* for link local this must be done */ sin6->sin6_scope_id = prev_scope;